Patchwork [trans-mem] add hashtable lock comments

login
register
mail settings
Submitter Aldy Hernandez
Date June 24, 2010, 6:24 p.m.
Message ID <20100624182413.GA29198@redhat.com>
Download mbox | patch
Permalink /patch/56814/
State New
Headers show

Comments

Aldy Hernandez - June 24, 2010, 6:24 p.m.
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.

Patch

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);
     }