From a30e960328fc60e066967d1224ecd5b6e173cda3 Mon Sep 17 00:00:00 2001 From: Wilco Dijkstra Date: Tue, 13 Sep 2022 11:58:07 +0100 Subject: Use relaxed atomics since there is no MO dependence Replace the 3 uses of atomic_bit_set and atomic_bit_test_set with atomic_fetch_or_relaxed. Using relaxed MO is correct since the atomics are used to ensure memory is released only once. Reviewed-by: Florian Weimer --- nptl/nptl_free_tcb.c | 3 ++- nptl/pthread_create.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'nptl') diff --git a/nptl/nptl_free_tcb.c b/nptl/nptl_free_tcb.c index 0d31143ac8..86a8904898 100644 --- a/nptl/nptl_free_tcb.c +++ b/nptl/nptl_free_tcb.c @@ -24,7 +24,8 @@ void __nptl_free_tcb (struct pthread *pd) { /* The thread is exiting now. */ - if (atomic_bit_test_set (&pd->cancelhandling, TERMINATED_BIT) == 0) + if ((atomic_fetch_or_relaxed (&pd->cancelhandling, TERMINATED_BITMASK) + & TERMINATED_BITMASK) == 0) { /* Free TPP data. */ if (pd->tpp != NULL) diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index e7e4ede6b2..ee29cb375d 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -487,7 +487,7 @@ start_thread (void *arg) /* The thread is exiting now. Don't set this bit until after we've hit the event-reporting breakpoint, so that td_thr_get_info on us while at the breakpoint reports TD_THR_RUN state rather than TD_THR_ZOMBIE. */ - atomic_bit_set (&pd->cancelhandling, EXITING_BIT); + atomic_fetch_or_relaxed (&pd->cancelhandling, EXITING_BITMASK); if (__glibc_unlikely (atomic_decrement_and_test (&__nptl_nthreads))) /* This was the last thread. */ -- cgit 1.4.1