From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12726 invoked by alias); 23 Jun 2010 18:59:41 -0000 Received: (qmail 12708 invoked by uid 22791); 23 Jun 2010 18:59:38 -0000 X-SWARE-Spam-Status: No, hits=-5.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_CP,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 23 Jun 2010 18:59:32 +0000 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5NIxUx3024696 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 23 Jun 2010 14:59:31 -0400 Received: from stone.twiddle.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5NIxUKY010337; Wed, 23 Jun 2010 14:59:30 -0400 Message-ID: <4C22597E.3030009@redhat.com> Date: Wed, 23 Jun 2010 19:29:00 -0000 From: Richard Henderson User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100621 Fedora/3.0.5-1.fc13 Thunderbird/3.0.5 MIME-Version: 1.0 To: Aldy Hernandez CC: gcc-patches@gcc.gnu.org Subject: Re: [trans-mem] implement _ITM_dropReferences References: <20100623171245.GA19259@redhat.com> In-Reply-To: <20100623171245.GA19259@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2010-06/txt/msg02367.txt.bz2 On 06/23/2010 10:12 AM, Aldy Hernandez wrote: > +void ITM_REGPARM > +_ITM_dropReferences (const void *ptr, size_t len) > +{ > + gtm_transaction *tx = gtm_tx(); > + tx->drop_references_local (ptr, len); > + tx->drop_references_allocations (ptr); > +} The primary thing missing here is dropping references inside the actual transactional memory backend, i.e. gtm_dispatch. > +/* Forget any references to PTR in the allocations tree. > + > + ?? We ignore the chunk length. Pray this doesn't wreck havoc. */ > + > +void > +gtm_transaction::drop_references_allocations (const void *ptr) > +{ > + uintptr_t iptr = (uintptr_t) ptr; > + > + gtm_alloc_action *a = this->alloc_actions.find(iptr); > + if (a == 0) > + { > + a = this->alloc_actions.insert(iptr); > + a->free_fn = NULL; > + a->allocated = false; > + } > + > + a->ignore = true; > +} Why add the ignore field when you could simply alloc_actions.erase? > @@ -65,13 +66,36 @@ gtm_transaction::rollback_local (void) > for (i = n; i-- > 0; ) > { > gtm_local_undo *u = local_undo[i]; > - memcpy (u->addr, u->saved, u->len); > + if (!u->ignore) > + memcpy (u->addr, u->saved, u->len); > free (u); > } > this->n_local_undo = 0; > } > } > > +/* Forget any references to PTR in the local log. */ > + > +void > +gtm_transaction::drop_references_local (const void *ptr, size_t len) > +{ > + gtm_local_undo **local_undo = this->local_undo; > + size_t i, n = this->n_local_undo; > + > + if (n > 0) > + { > + for (i = n; i > 0; i--) > + { > + gtm_local_undo *u = local_undo[i]; > + /* ?? Do we need such granularity, or can we get away with > + just comparing PTR and LEN. ?? */ > + if ((const char *)u->addr >= (const char *)ptr > + && ((const char *)u->addr + u->len <= (const char *)ptr + len)) > + u->ignore = true; > + } > + } > +} Similarly, it seems easy enough to free the one element and test instead in rollback_local for u == NULL. r~