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]

Re: [patch] libitm: Fix race condition in dispatch choice at transaction begin.


On Mon, 2012-02-13 at 15:12 -0800, Richard Henderson wrote:
> On 02/13/2012 03:03 PM, Torvald Riegel wrote:
> > -// The default TM method used when starting a new transaction.
> > -static GTM::abi_dispatch* default_dispatch = 0;
> > +// The default TM method used when starting a new transaction.  Initialized
> > +// in number_of_threads_changed() below.
> > +static std::atomic<GTM::abi_dispatch*> default_dispatch;
> 
> I see nothing but memory_order_relaxed uses of default_dispatch?

That is fine based on the assumptions we already had about when dispatch
objects are constructed.  I add several comments to the patch to explain
this, updated version is attached.  Better?

I also addressed another corner case in decide_retry_strategy(): after
method group reinit, if another thread would change default dispatch to
something like serialirr, the code wasn't properly reacquiring serial
mode before (and not setting tx->state properly).  Delegating to the
decide_begin_dispatch() as the current patch does should fix this.

BTW, why can we assume that the dispatch objects are initialized before
we run any transactions (e.g., from within a constructor of another
static object)?  Or is this the library initialization problem that we
still have to deal with at some point?

Attachment: patch5
Description: Text document


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