This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[trans-mem] unlock serial_lock when committing transaction


There's this sporadic failure on testsuite/libitm.c/simple-2.c in which
we're deadlocking because serial_lock never gets unlocked on a
successful transaction.  Also, decide_retry_strategy is not updating the
state when switching to serial mode.

I caught this by inserting printfs in the library and noticing there
were a lot more locks than unlocks :).

I have fixed both of these problems.

Unfortunately... there's an unrelated problem with the Linux futex
implementation on the library.  So I had to test with
--disable-linux-futex and use the pthreads mutex code for locks.

Tested by running "make check-target-libitm" (--disable-linux-futex) in
an infinite loop to see if we ever fail.  We haven't in the last 10
minutes :).

I will be working on fixing the Linux futex code next.

OK for branch?

	* retry.cc (decide_retry_strategy): Set state to STATE_SERIAL when
	switching to serial mode.
	* beginend.cc (trycommit_and_finalize): Unlock serial_lock.

Index: retry.cc
===================================================================
--- retry.cc	(revision 156783)
+++ retry.cc	(working copy)
@@ -44,6 +44,7 @@ GTM::gtm_transaction::decide_retry_strat
       // acquired with the read.
       if ((this->state & STATE_SERIAL) == 0)
 	{
+	  this->state |= STATE_SERIAL;
 	  serial_lock.read_unlock ();
 	  serial_lock.write_lock ();
 	}
Index: beginend.cc
===================================================================
--- beginend.cc	(revision 156783)
+++ beginend.cc	(working copy)
@@ -212,6 +212,10 @@ GTM::gtm_transaction::trycommit_and_fina
       gtm_disp()->fini ();
       set_gtm_tx (this->prev);
       free_tx (this);
+      if (this->state & gtm_transaction::STATE_SERIAL)
+	gtm_transaction::serial_lock.write_unlock ();
+      else
+	gtm_transaction::serial_lock.read_unlock ();
       return true;
     }
   return false;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]