Message ID | 1314657235.14756.1465.camel@triegel.csb |
---|---|
State | New |
Headers | show |
> Add support for TM-method-specific begin code. > > * libitm_i.h (GTM::gtm_restart_reason): Re-arrange and clean up > declarations. > * dispatch.h (GTM::abi_dispatch::begin_or_restart): New. > * method-serial.cc: Implement begin_or_restart(). > * beginend.cc (GTM::gtm_thread::begin_transaction): Call > dispatch-specific begin_or_restart(). > (GTM::gtm_thread::restart): Same. Ok except, > + // Run dispatch-specific restart code. Retry until we succeed. > + GTM::gtm_restart_reason rr; > + while ((rr = disp->begin_or_restart()) > + != NUM_RESTARTS) Please add NO_RESTART = NUM_RESTARTS (or it's own number *after* NUM_RESTARTS, or -1, or something) to the enumeration and use that name. Using num_restarts here is confusing. > Fixed gtm_thread::serialirr_mode to actually use serialirr, not serial. > > * method-serial.cc (GTM::gtm_thread::serialirr_mode): Fixed: Use > serial-irrevocable dispatch, not serial. Ok. > Do not free transaction-local memory when committing a nested transaction. > > * alloc.cc (commit_allocations_2): Do not free transaction-local > memory when committing a nested transaction. Ok. > Handle re-initialization of the current method group. > > * retry.cc (GTM::gtm_thread::decide_retry_strategy): Handle > re-initialization of the current method group. > * libitm_i.h (GTM::gtm_restart_reason): Add restart reason for this. Ok. > Undo log is used for both thread-local and shared data. > > * libitm_i.h: Renamed gtm_local_undo to gtm_undolog_entry. > (GTM::gtm_thread): Renamed local_undo to undolog. Renamed > undolog-related member functions from *_local to *_undolog. > * local.cc (gtm_thread::commit_undolog): Same. > * beginend.cc (GTM::gtm_thread::trycommit): Same. > (GTM::gtm_thread::rollback): Roll back undolog before > dispatch-specific rollback. Ok. > Ensure privatization safety if requested by a TM method. > > * beginend.cc (GTM::gtm_thread::trycommit): Ensure privatization > safety if requested by a TM method. > * dispatch.h (GTM::abi_dispatch::trycommit): Add parameter for > privatization safety. > * method-serial.cc: Same. Ok. > Add gl_wt TM method. > > * libitm_i.h: Add gl_wt dispatch. > * retry.cc (parse_default_method): Same. > * method-gl.cc: New file. > * Makefile.am: Use method-gl.cc. > * Makefile.in: Rebuild. Ok with... > Fix gl_wt commit/rollback when serial lock has been acquired. > > * method-gl.cc (gl_wt_dispatch::trycommit): Fix interaction with > gtm_thread::shared_state when the serial lock is acquired. > (gl_wt_dispatch::rollback): Same. ... this merged with the previous commit. > Fix TLS read accesses on Linux/x86. > > * config/linux/x86/tls.h (abi_disp): Make TLS slot read volatile. > (gtm_thr): Same. Ok. r~
Committed with the changes below. On Wed, 2011-10-19 at 12:17 -0700, Richard Henderson wrote: > > Add support for TM-method-specific begin code. > > > > * libitm_i.h (GTM::gtm_restart_reason): Re-arrange and clean up > > declarations. > > * dispatch.h (GTM::abi_dispatch::begin_or_restart): New. > > * method-serial.cc: Implement begin_or_restart(). > > * beginend.cc (GTM::gtm_thread::begin_transaction): Call > > dispatch-specific begin_or_restart(). > > (GTM::gtm_thread::restart): Same. > > Ok except, > > > + // Run dispatch-specific restart code. Retry until we succeed. > > + GTM::gtm_restart_reason rr; > > + while ((rr = disp->begin_or_restart()) > > + != NUM_RESTARTS) > > Please add > > NO_RESTART = NUM_RESTARTS > > (or it's own number *after* NUM_RESTARTS, or -1, or something) > to the enumeration and use that name. Using num_restarts here is confusing. > > > Fixed gtm_thread::serialirr_mode to actually use serialirr, not serial. > > > > * method-serial.cc (GTM::gtm_thread::serialirr_mode): Fixed: Use > > serial-irrevocable dispatch, not serial. > > Ok. > > > Do not free transaction-local memory when committing a nested transaction. > > > > * alloc.cc (commit_allocations_2): Do not free transaction-local > > memory when committing a nested transaction. > > Ok. > > > Handle re-initialization of the current method group. > > > > * retry.cc (GTM::gtm_thread::decide_retry_strategy): Handle > > re-initialization of the current method group. > > * libitm_i.h (GTM::gtm_restart_reason): Add restart reason for this. > > Ok. > > > Undo log is used for both thread-local and shared data. > > > > * libitm_i.h: Renamed gtm_local_undo to gtm_undolog_entry. > > (GTM::gtm_thread): Renamed local_undo to undolog. Renamed > > undolog-related member functions from *_local to *_undolog. > > * local.cc (gtm_thread::commit_undolog): Same. > > * beginend.cc (GTM::gtm_thread::trycommit): Same. > > (GTM::gtm_thread::rollback): Roll back undolog before > > dispatch-specific rollback. > > Ok. > > > Ensure privatization safety if requested by a TM method. > > > > * beginend.cc (GTM::gtm_thread::trycommit): Ensure privatization > > safety if requested by a TM method. > > * dispatch.h (GTM::abi_dispatch::trycommit): Add parameter for > > privatization safety. > > * method-serial.cc: Same. > > Ok. > > > Add gl_wt TM method. > > > > * libitm_i.h: Add gl_wt dispatch. > > * retry.cc (parse_default_method): Same. > > * method-gl.cc: New file. > > * Makefile.am: Use method-gl.cc. > > * Makefile.in: Rebuild. > > Ok with... > > > Fix gl_wt commit/rollback when serial lock has been acquired. > > > > * method-gl.cc (gl_wt_dispatch::trycommit): Fix interaction with > > gtm_thread::shared_state when the serial lock is acquired. > > (gl_wt_dispatch::rollback): Same. > > ... this merged with the previous commit. > > > Fix TLS read accesses on Linux/x86. > > > > * config/linux/x86/tls.h (abi_disp): Make TLS slot read volatile. > > (gtm_thr): Same. > > Ok. > > > r~ >
diff --git a/libitm/beginend.cc b/libitm/beginend.cc index cc25d17..1770dad 100644 --- a/libitm/beginend.cc +++ b/libitm/beginend.cc @@ -269,6 +269,15 @@ GTM::gtm_thread::begin_transaction (uint32_t prop, const gtm_jmpbuf *jb) #endif } + // Run dispatch-specific restart code. Retry until we succeed. + GTM::gtm_restart_reason rr; + while ((rr = disp->begin_or_restart()) + != NUM_RESTARTS) + { + tx->decide_retry_strategy(rr); + disp = abi_disp(); + } + // Determine the code path to run. Only irrevocable transactions cannot be // restarted, so all other transactions need to save live variables. ret = choose_code_path(prop, disp); @@ -458,9 +467,17 @@ GTM::gtm_thread::restart (gtm_restart_reason r) rollback (); decide_retry_strategy (r); - GTM_longjmp (&this->jb, - choose_code_path(prop, abi_disp()) | a_restoreLiveVariables, - this->prop); + // Run dispatch-specific restart code. Retry until we succeed. + abi_dispatch* disp = abi_disp(); + GTM::gtm_restart_reason rr; + while ((rr = disp->begin_or_restart()) != NUM_RESTARTS) + { + decide_retry_strategy(rr); + disp = abi_disp(); + } + + GTM_longjmp (&jb, + choose_code_path(prop, disp) | a_restoreLiveVariables, prop); } void ITM_REGPARM diff --git a/libitm/dispatch.h b/libitm/dispatch.h index 9c33684..2f6fdd7 100644 --- a/libitm/dispatch.h +++ b/libitm/dispatch.h @@ -260,6 +260,16 @@ private: abi_dispatch& operator=(const abi_dispatch &) = delete; public: + // Starts or restarts a transaction. Is called right before executing the + // transactional application code (by either returning from + // gtm_thread::begin_transaction or doing the longjmp when restarting). + // Returns NUM_RESTARTS if the transaction started successfully. Returns + // a real restart reason if it couldn't start and does need to abort. This + // allows TM methods to just give up and delegate ensuring progress to the + // restart mechanism. If it returns a restart reason, this call must be + // idempotent because it will trigger the restart mechanism, which could + // switch to a different TM method. + virtual gtm_restart_reason begin_or_restart() = 0; // Tries to commit the transaction. Iff this returns true, the transaction // got committed and all per-transaction data will have been reset. // Currently, this is called only for the commit of the outermost diff --git a/libitm/libitm_i.h b/libitm/libitm_i.h index ea89870..2e1913a 100644 --- a/libitm/libitm_i.h +++ b/libitm/libitm_i.h @@ -53,22 +53,6 @@ template<> struct sized_integral<8> { typedef uint64_t type; }; typedef unsigned int gtm_word __attribute__((mode (word))); -} // namespace GTM - -#include "target.h" -#include "rwlock.h" -#include "aatree.h" -#include "cacheline.h" -#include "cachepage.h" -#include "stmlock.h" -#include "dispatch.h" -#include "containers.h" - -namespace GTM HIDDEN { - -// A dispatch table parameterizes the implementation of the STM. -struct abi_dispatch; - // These values are given to GTM_restart_transaction and indicate the // reason for the restart. The reason is used to decide what STM // implementation should be used during the next iteration. @@ -86,6 +70,19 @@ enum gtm_restart_reason NUM_RESTARTS }; +} // namespace GTM + +#include "target.h" +#include "rwlock.h" +#include "aatree.h" +#include "cacheline.h" +#include "cachepage.h" +#include "stmlock.h" +#include "dispatch.h" +#include "containers.h" + +namespace GTM HIDDEN { + // This type is private to alloc.c, but needs to be defined so that // the template used inside gtm_thread can instantiate. struct gtm_alloc_action diff --git a/libitm/method-serial.cc b/libitm/method-serial.cc index 4621345..133b964 100644 --- a/libitm/method-serial.cc +++ b/libitm/method-serial.cc @@ -90,6 +90,7 @@ class serialirr_dispatch : public abi_dispatch CREATE_DISPATCH_METHODS(virtual, ) CREATE_DISPATCH_METHODS_MEM() + virtual gtm_restart_reason begin_or_restart() { return NUM_RESTARTS; } virtual bool trycommit() { return true; } virtual void rollback(gtm_transaction_cp *cp) { abort(); } @@ -141,6 +142,7 @@ public: ::memset(dst, c, size); } + virtual gtm_restart_reason begin_or_restart() { return NUM_RESTARTS; } virtual bool trycommit() { return true; } // Local undo will handle this. // trydropreference() need not be changed either.