Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/drm2/include/linux RCU pointer fixes.
details: https://anonhg.NetBSD.org/src/rev/e97df2cae972
branches: trunk
changeset: 1027930:e97df2cae972
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Dec 19 01:18:02 2021 +0000
description:
RCU pointer fixes.
- Use __typeof__, not typeof.
- Use membar_exit, not membar_producer.
=> We want a store-release, not store/store barrier.
=> Consider:
foo->x = 42;
assert(foo->x == 42);
rcu_assign_pointer(globalfoo, foo);
The foo->x load can be reordered past the store/store barrier
(membar_producer), and happen after another thread has clobbered
foo->x.
- Put the evaluation of the right-hand side before the barrier.
diffstat:
sys/external/bsd/drm2/include/linux/rcupdate.h | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diffs (26 lines):
diff -r fb9ae7d2dd13 -r e97df2cae972 sys/external/bsd/drm2/include/linux/rcupdate.h
--- a/sys/external/bsd/drm2/include/linux/rcupdate.h Sun Dec 19 01:17:54 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/rcupdate.h Sun Dec 19 01:18:02 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rcupdate.h,v 1.8 2021/12/19 01:17:54 riastradh Exp $ */
+/* $NetBSD: rcupdate.h,v 1.9 2021/12/19 01:18:02 riastradh Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -41,12 +41,13 @@
#define RCU_INIT_POINTER(P, V) ((P) = (V))
#define rcu_assign_pointer(P, V) do { \
- membar_producer(); \
- (P) = (V); \
+ __typeof__(*(P)) *__rcu_assign_pointer_tmp = (V); \
+ membar_exit(); \
+ (P) = __rcu_assign_pointer_tmp; \
} while (0)
#define rcu_dereference(P) ({ \
- typeof(*(P)) *__rcu_dereference_tmp = (P); \
+ __typeof__(*(P)) *__rcu_dereference_tmp = (P); \
membar_datadep_consumer(); \
__rcu_dereference_tmp; \
})
Home |
Main Index |
Thread Index |
Old Index