X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=include%2Furcu%2Fstatic%2Furcu-qsbr.h;h=de798831bb5c1ac7aaa950351171b17c750053bb;hb=HEAD;hp=b8788771c33103f44981cac1ad381fe525dcf3ce;hpb=014775106c60f02818ca755b331f887030bd440f;p=urcu.git diff --git a/include/urcu/static/urcu-qsbr.h b/include/urcu/static/urcu-qsbr.h index b878877..de79883 100644 --- a/include/urcu/static/urcu-qsbr.h +++ b/include/urcu/static/urcu-qsbr.h @@ -1,31 +1,17 @@ +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2009 Paul E. McKenney, IBM Corporation. +// +// SPDX-License-Identifier: LGPL-2.1-or-later + #ifndef _URCU_QSBR_STATIC_H #define _URCU_QSBR_STATIC_H /* - * urcu-qsbr-static.h - * * Userspace RCU QSBR header. * * TO BE INCLUDED ONLY IN CODE THAT IS TO BE RECOMPILED ON EACH LIBURCU * RELEASE. See urcu.h for linking dynamically with the userspace rcu library. * - * Copyright (c) 2009 Mathieu Desnoyers - * Copyright (c) 2009 Paul E. McKenney, IBM Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * * IBM's contributions to this file may be relicensed under LGPLv2 or later. */ @@ -35,6 +21,7 @@ #include #include +#include #include #include #include @@ -96,11 +83,14 @@ static inline void urcu_qsbr_wake_up_gp(void) } } -static inline enum urcu_state urcu_qsbr_reader_state(unsigned long *ctr) +static inline enum urcu_state urcu_qsbr_reader_state(unsigned long *ctr, + cmm_annotate_t *group) { unsigned long v; - v = CMM_LOAD_SHARED(*ctr); + v = uatomic_load(ctr, CMM_RELAXED); + cmm_annotate_group_mem_acquire(group, ctr); + if (!v) return URCU_READER_INACTIVE; if (v == urcu_qsbr_gp.ctr) @@ -155,9 +145,9 @@ static inline int _urcu_qsbr_read_ongoing(void) */ static inline void _urcu_qsbr_quiescent_state_update_and_wakeup(unsigned long gp_ctr) { - cmm_smp_mb(); - _CMM_STORE_SHARED(URCU_TLS(urcu_qsbr_reader).ctr, gp_ctr); - cmm_smp_mb(); /* write URCU_TLS(urcu_qsbr_reader).ctr before read futex */ + uatomic_store(&URCU_TLS(urcu_qsbr_reader).ctr, gp_ctr, CMM_SEQ_CST); + + /* write URCU_TLS(urcu_qsbr_reader).ctr before read futex */ urcu_qsbr_wake_up_gp(); cmm_smp_mb(); } @@ -179,7 +169,8 @@ static inline void _urcu_qsbr_quiescent_state(void) unsigned long gp_ctr; urcu_assert_debug(URCU_TLS(urcu_qsbr_reader).registered); - if ((gp_ctr = CMM_LOAD_SHARED(urcu_qsbr_gp.ctr)) == URCU_TLS(urcu_qsbr_reader).ctr) + gp_ctr = uatomic_load(&urcu_qsbr_gp.ctr, CMM_RELAXED); + if (gp_ctr == URCU_TLS(urcu_qsbr_reader).ctr) return; _urcu_qsbr_quiescent_state_update_and_wakeup(gp_ctr); } @@ -195,9 +186,8 @@ static inline void _urcu_qsbr_quiescent_state(void) static inline void _urcu_qsbr_thread_offline(void) { urcu_assert_debug(URCU_TLS(urcu_qsbr_reader).registered); - cmm_smp_mb(); - CMM_STORE_SHARED(URCU_TLS(urcu_qsbr_reader).ctr, 0); - cmm_smp_mb(); /* write URCU_TLS(urcu_qsbr_reader).ctr before read futex */ + uatomic_store(&URCU_TLS(urcu_qsbr_reader).ctr, 0, CMM_SEQ_CST); + /* write URCU_TLS(urcu_qsbr_reader).ctr before read futex */ urcu_qsbr_wake_up_gp(); cmm_barrier(); /* Ensure the compiler does not reorder us with mutex */ } @@ -212,9 +202,14 @@ static inline void _urcu_qsbr_thread_offline(void) */ static inline void _urcu_qsbr_thread_online(void) { + unsigned long *pctr = &URCU_TLS(urcu_qsbr_reader).ctr; + unsigned long ctr; + urcu_assert_debug(URCU_TLS(urcu_qsbr_reader).registered); cmm_barrier(); /* Ensure the compiler does not reorder us with mutex */ - _CMM_STORE_SHARED(URCU_TLS(urcu_qsbr_reader).ctr, CMM_LOAD_SHARED(urcu_qsbr_gp.ctr)); + ctr = uatomic_load(&urcu_qsbr_gp.ctr, CMM_RELAXED); + cmm_annotate_mem_acquire(&urcu_qsbr_gp.ctr); + uatomic_store(pctr, ctr, CMM_RELAXED); cmm_smp_mb(); }