Skip to content

Commit 6692fa5

Browse files
committed
Address review feedback.
* Add comment to CAS while loop, yielding is unnecessary. * Use "relaxed" memory ordering, seq-cst is overkill.
1 parent dd6c824 commit 6692fa5

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎Objects/memoryobject.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ flags_test_and_set(int *flags, int bit)
109109
#ifdef Py_GIL_DISABLED
110110
int prev = _Py_atomic_load_int_relaxed(flags);
111111
while (!_Py_atomic_compare_exchange_int(flags, &prev, prev | bit)) {
112-
// Compare-exchange updates prev.
112+
// Compare-exchange updates prev. Note that retries are bounded by the
113+
// number of flag bits being concurrently set. So, yielding here is
114+
// unnecessary.
113115
}
114116
#else
115117
int prev = *flags;
@@ -121,7 +123,7 @@ flags_test_and_set(int *flags, int bit)
121123
static inline int
122124
mv_get_flags(PyMemoryViewObject *mv)
123125
{
124-
return FT_ATOMIC_LOAD_INT(mv->flags);
126+
return FT_ATOMIC_LOAD_INT_RELAXED(mv->flags);
125127
}
126128

127129
static inline int

0 commit comments

Comments
 (0)