[Git][ghc/ghc][wip/tsan/fixes] 3 commits: Fix acquire fences on indirections
Ben Gamari (@bgamari)
gitlab at gitlab.haskell.org
Mon Apr 24 09:43:56 UTC 2023
Ben Gamari pushed to branch wip/tsan/fixes at Glasgow Haskell Compiler / GHC
Commits:
9d911f17 by Ubuntu at 2023-04-24T09:35:15+00:00
Fix acquire fences on indirections
- - - - -
39446503 by Ubuntu at 2023-04-24T09:36:09+00:00
STM
- - - - -
3caadbd5 by Ubuntu at 2023-04-24T09:36:29+00:00
comment fixes
- - - - -
3 changed files:
- rts/STM.c
- rts/StgMiscClosures.cmm
- rts/include/stg/SMP.h
Changes:
=====================================
rts/STM.c
=====================================
@@ -294,7 +294,7 @@ static StgClosure *lock_tvar(Capability *cap,
StgInfoTable *info;
do {
result = ACQUIRE_LOAD(&s->current_value);
- info = GET_INFO_RELAXED(UNTAG_CLOSURE(result));
+ info = GET_INFO(UNTAG_CLOSURE(result));
} while (info == &stg_TREC_HEADER_info);
} while (cas((void *) &s->current_value,
(StgWord)result, (StgWord)trec) != (StgWord)result);
=====================================
rts/StgMiscClosures.cmm
=====================================
@@ -521,6 +521,7 @@ INFO_TABLE(stg_IND,1,0,IND,"IND","IND")
(P_ node)
{
TICK_ENT_DYN_IND(); /* tick */
+ ACQUIRE_FENCE_ON(node + OFFSET_StgHeader_info);
node = %acquire StgInd_indirectee(node);
node = UNTAG(node);
TICK_ENT_VIA_NODE();
@@ -530,6 +531,7 @@ INFO_TABLE(stg_IND,1,0,IND,"IND","IND")
/* explicit stack */
{
TICK_ENT_DYN_IND(); /* tick */
+ ACQUIRE_FENCE_ON(R1 + OFFSET_StgHeader_info);
P_ p;
p = %acquire StgInd_indirectee(R1);
R1 = UNTAG(p);
@@ -542,6 +544,7 @@ INFO_TABLE(stg_IND_STATIC,1,0,IND_STATIC,"IND_STATIC","IND_STATIC")
/* explicit stack */
{
TICK_ENT_STATIC_IND(); /* tick */
+ ACQUIRE_FENCE_ON(R1 + OFFSET_StgHeader_info);
P_ p;
p = %acquire StgInd_indirectee(R1);
R1 = UNTAG(p);
@@ -569,7 +572,7 @@ INFO_TABLE(stg_BLACKHOLE,1,0,BLACKHOLE,"BLACKHOLE","BLACKHOLE")
retry:
// Synchronizes with the SET_INFO_RELEASE in
// updateWithIndirection
- ACQUIRE_FENCE_ON(StgHeader_info(node));
+ ACQUIRE_FENCE_ON(node + OFFSET_StgHeader_info);
// Synchronizes with the release-store in
// updateWithIndirection.
@@ -678,7 +681,7 @@ loop:
// defined in CMM.
goto loop;
}
- ACQUIRE_FENCE_ON(StgHeader_info(node));
+ ACQUIRE_FENCE_ON(node + OFFSET_StgHeader_info);
jump %ENTRY_CODE(info) (node);
#else
ccall barf("WHITEHOLE object (%p) entered!", R1) never returns;
=====================================
rts/include/stg/SMP.h
=====================================
@@ -277,7 +277,7 @@ EXTERN_INLINE void load_load_barrier(void);
* U1. use a release-store to place the new indirectee into the thunk's
* indirectee field
*
- * U2. use a relaxed-store to set the info table to stg_BLACKHOLE (which
+ * U2. use a release-store to set the info table to stg_BLACKHOLE (which
* represents an indirection)
*
* Blackholing a thunk (either eagerly, by GHC.StgToCmm.Bind.emitBlackHoleCode,
@@ -299,7 +299,7 @@ EXTERN_INLINE void load_load_barrier(void);
*
* E4. enter the indirectee (or block if the indirectee is a TSO)
*
- * The acquire-fence in step (E2) is somewhat surprising but is necessary as
+ * The release/acquire pair (U2)/(E2) is somewhat surprising but is necessary as
* the C11 memory model does not guarantee that the store (U1) is visible to
* (E3) despite (U1) preceding (U2) in program-order (due to the relaxed
* ordering of (E3)). This is demonstrated by the following CppMem model:
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e1bd66c4aa70f2a0130820cbac48a017f76eacf9...3caadbd50211ef5fddbcefcba17b4c5baaa1793e
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e1bd66c4aa70f2a0130820cbac48a017f76eacf9...3caadbd50211ef5fddbcefcba17b4c5baaa1793e
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230424/7d6247cc/attachment-0001.html>
More information about the ghc-commits
mailing list