diff options
author | Torvald Riegel <triegel@redhat.com> | 2013-06-20 16:40:38 +0000 |
---|---|---|
committer | Torvald Riegel <torvald@gcc.gnu.org> | 2013-06-20 16:40:38 +0000 |
commit | b1db457bf9ac2c086273c8863b94b3bf814a6dd9 (patch) | |
tree | 8928a26da25237053ba123d609fec2b28f64361d /libitm/beginend.cc | |
parent | dcef09b5d11f5c12d6e42a93bbf99d5b7b413080 (diff) | |
download | gcc-b1db457bf9ac2c086273c8863b94b3bf814a6dd9.tar.gz |
libitm: Fix handling of reentrancy in the HTM fastpath.
PR libitm/57643
* beginend.cc (gtm_thread::begin_transaction): Handle reentrancy in
the HTM fastpath.
From-SVN: r200250
Diffstat (limited to 'libitm/beginend.cc')
-rw-r--r-- | libitm/beginend.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libitm/beginend.cc b/libitm/beginend.cc index 93e702efc9e..a3bf5492153 100644 --- a/libitm/beginend.cc +++ b/libitm/beginend.cc @@ -197,6 +197,8 @@ GTM::gtm_thread::begin_transaction (uint32_t prop, const gtm_jmpbuf *jb) // We are executing a transaction now. // Monitor the writer flag in the serial-mode lock, and abort // if there is an active or waiting serial-mode transaction. + // Note that this can also happen due to an enclosing + // serial-mode transaction; we handle this case below. if (unlikely(serial_lock.is_write_locked())) htm_abort(); else @@ -219,6 +221,14 @@ GTM::gtm_thread::begin_transaction (uint32_t prop, const gtm_jmpbuf *jb) tx = new gtm_thread(); set_gtm_thr(tx); } + // Check whether there is an enclosing serial-mode transaction; + // if so, we just continue as a nested transaction and don't + // try to use the HTM fastpath. This case can happen when an + // outermost relaxed transaction calls unsafe code that starts + // a transaction. + if (tx->nesting > 0) + break; + // Another thread is running a serial-mode transaction. Wait. serial_lock.read_lock(tx); serial_lock.read_unlock(tx); // TODO We should probably reset the retry count t here, unless |