From patchwork Thu Jun 24 18:24:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 56814 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 9CC34B6F1C for ; Fri, 25 Jun 2010 04:24:37 +1000 (EST) Received: (qmail 6033 invoked by alias); 24 Jun 2010 18:24:31 -0000 Received: (qmail 6024 invoked by uid 22791); 24 Jun 2010 18:24:30 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, 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; Thu, 24 Jun 2010 18:24:20 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5OIOJQJ001905 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 24 Jun 2010 14:24:19 -0400 Received: from redhat.com (vpn-10-175.rdu.redhat.com [10.11.10.175]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5OIOG1c030876 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 24 Jun 2010 14:24:18 -0400 Date: Thu, 24 Jun 2010 14:24:15 -0400 From: Aldy Hernandez To: gcc-patches@gcc.gnu.org Cc: rth@redhat.com Subject: [trans-mem] add hashtable lock comments Message-ID: <20100624182413.GA29198@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-08-17) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org I'm a bit stuck implementing dropReferences() in the runtime, and have been getting better acquainted with how we cache memory in the runtime. Here are some comments for the writeback code. Richard okayed the comments. Committing. * method-wbetl.cc (struct w_entry): Add comments. (trycommit): Same. (rollback): Same. Index: method-wbetl.cc =================================================================== --- method-wbetl.cc (revision 161318) +++ method-wbetl.cc (working copy) @@ -45,8 +45,15 @@ class wbetl_dispatch : public gtm_dispat struct w_entry { + /* There's a hashtable where the locks are held, so multiple + cachelines can hash to a given bucket. This link points to the + possible next cacheline that also hashes to this bucket. */ struct w_entry *next; + + /* Every entry in this bucket (accessed by NEXT) has the same LOCK + address below. */ gtm_stmlock *lock; + gtm_cacheline *addr; gtm_cacheline *value; gtm_version version; @@ -442,6 +449,9 @@ wbetl_dispatch::trycommit () for (size_t i = 0; i < n; ++i) { w_entry *w = &m_wset_entries[i]; + + /* Every link along the chain has the same lock, but only + bother dropping the lock once per bucket (at the end). */ if (w->next == NULL) *w->lock = gtm_stmlock_set_version (t); } @@ -459,6 +469,9 @@ wbetl_dispatch::rollback () for (size_t i = 0; i < n; ++i) { w_entry *w = &m_wset_entries[i]; + + /* Every link along the chain has the same lock, but only + bother dropping the lock once per bucket (at the end). */ if (w->next == NULL) *w->lock = gtm_stmlock_set_version (w->version); }