RCU: Better explain the condition parameter of rcu_dereference_check()
PATCH 1/1 RCU: Better explain the condition parameter of rcu_dereference_check()
Better explain the condition parameter of rcu_dereference_check() that describes the conditions under which the dereference is permitted to take place. This condition is only checked under lockdep proving.
---
include/linux/rcupdate.h | 28 +++++++++++++++++++++++----- 1 files changed, 23 insertions(+), 5 deletions(-)
include/linux/rcupdate.h +23 -5
@@ -195,12 +195,30 @@ static inline int rcu_read_lock_sched_held(void)/** * rcu_dereference_check - rcu_dereference with debug checking +* @p: The pointer to read, prior to dereferencing +* @c: The conditions under which the dereference will take place * -* Do an rcu_dereference(), but check that the context is correct. -* For example, rcu_dereference_check(gp, rcu_read_lock_held()) to -* ensure that the rcu_dereference_check() executes within an RCU -* read-side critical section. It is also possible to check for -* locks being held, for example, by using lockdep_is_held(). +* Do an rcu_dereference(), but check that the conditions under which the +* dereference will take place are correct. Typically the conditions indicate +* the various locking conditions that should be held at that point. The check +* should return true if the conditions are satisfied. +* +* For example: +* +* bar = rcu_dereference_check(foo->bar, rcu_read_lock_held() || +* lockdep_is_held(&foo->lock)); +* +* could be used to indicate to lockdep that foo->bar may only be dereferenced +* if either the RCU read lock is held, or that the lock required to replace +* the bar struct at foo->bar is held. +* +* Note that the list of conditions may also include indications of when a lock +* need not be held, for example during initialisation or destruction of the +* target struct: +* +* bar = rcu_dereference_check(foo->bar, rcu_read_lock_held() || +* lockdep_is_held(&foo->lock), +* atomic_read(&foo->usage) == 0); */ #define rcu_dereference_check (p, c) \ ({ \
Quoted 3 lines · David Howells
Better explain the condition parameter of
rcu_dereference_check()that describes the conditions under which the dereference is permitted to take place. This condition is only checked under lockdep proving.
Very good, I have queued this. Thank you!
Thanx, Paul
Quoted 47 lines
Signed-off-by David Howells <[email protected]>---
include/linux/rcupdate.h | 28 +++++++++++++++++++++++----- 1 files changed, 23 insertions(+), 5 deletions(-)include/linux/rcupdate.h +23
-5@@ -195,12 +195,30 @@ static inline int rcu_read_lock_sched_held(void)/** * rcu_dereference_check - rcu_dereference with debug checking +* @p: The pointer to read, prior to dereferencing +* @c: The conditions under which the dereference will take place * -* Do an rcu_dereference(), but check that the context is correct. -* For example, rcu_dereference_check(gp, rcu_read_lock_held()) to -* ensure that the rcu_dereference_check() executes within an RCU -* read-side critical section. It is also possible to check for -* locks being held, for example, by using lockdep_is_held(). +* Do an rcu_dereference(), but check that the conditions under which the +* dereference will take place are correct. Typically the conditions indicate +* the various locking conditions that should be held at that point. The check +* should return true if the conditions are satisfied. +* +* For example: +* +* bar = rcu_dereference_check(foo->bar, rcu_read_lock_held() || +* lockdep_is_held(&foo->lock)); +* +* could be used to indicate to lockdep that foo->bar may only be dereferenced +* if either the RCU read lock is held, or that the lock required to replace +* the bar struct at foo->bar is held. +* +* Note that the list of conditions may also include indications of when a lock +* need not be held, for example during initialisation or destruction of the +* target struct: +* +* bar = rcu_dereference_check(foo->bar, rcu_read_lock_held() || +* lockdep_is_held(&foo->lock), +* atomic_read(&foo->usage) == 0); */ #define rcu_dereference_check (p, c) \ ({ \
Quoted 36 lines · David Howells
Better explain the condition parameter of
rcu_dereference_check()that describes the conditions under which the dereference is permitted to take place. This condition is only checked under lockdep proving.Signed-off-by David Howells <[email protected]>---
include/linux/rcupdate.h | 28 +++++++++++++++++++++++----- 1 files changed, 23 insertions(+), 5 deletions(-)include/linux/rcupdate.h +12
-5@@ -195,12 +195,30 @@ static inline int rcu_read_lock_sched_held(void)/** * rcu_dereference_check - rcu_dereference with debug checking +* @p: The pointer to read, prior to dereferencing +* @c: The conditions under which the dereference will take place * -* Do an rcu_dereference(), but check that the context is correct. -* For example, rcu_dereference_check(gp, rcu_read_lock_held()) to -* ensure that the rcu_dereference_check() executes within an RCU -* read-side critical section. It is also possible to check for -* locks being held, for example, by using lockdep_is_held(). +* Do an rcu_dereference(), but check that the conditions under which the +* dereference will take place are correct. Typically the conditions indicate +* the various locking conditions that should be held at that point. The check +* should return true if the conditions are satisfied. +* +* For example: +* +* bar = rcu_dereference_check(foo->bar, rcu_read_lock_held() || +* lockdep_is_held(&foo->lock)); +*
include/linux/rcupdate.h static inline int rcu_read_lock_sched_held(void) · line 220
Quoted 10 lines
include/linux/rcupdate.h +10
-0+* could be used to indicate to lockdep that foo->bar may only be dereferenced +* if either the RCU read lock is held, or that the lock required to replace +* the bar struct at foo->bar is held. +* +* Note that the list of conditions may also include indications of when a lock +* need not be held, for example during initialisation or destruction of the +* target struct: +* +* bar = rcu_dereference_check(foo->bar, rcu_read_lock_held() || +* lockdep_is_held(&foo->lock),
^^ || ?
Thanks,
Yong
Quoted 10 lines
include/linux/rcupdate.h +1
-1+* atomic_read(&foo->usage) == 0); */ #define rcu_dereference_check (p, c) \ ({ \ --To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 41 lines · Yong Zhang
Quoted 40 lines · David Howells
Better explain the condition parameter of
rcu_dereference_check()that describes the conditions under which the dereference is permitted to take place. This condition is only checked under lockdep proving.Signed-off-by David Howells <[email protected]>---
include/linux/rcupdate.h | 28 +++++++++++++++++++++++----- 1 files changed, 23 insertions(+), 5 deletions(-)include/linux/rcupdate.h +16
-5@@ -195,12 +195,30 @@ static inline int rcu_read_lock_sched_held(void)/** * rcu_dereference_check - rcu_dereference with debug checking +* @p: The pointer to read, prior to dereferencing +* @c: The conditions under which the dereference will take place * -* Do an rcu_dereference(), but check that the context is correct. -* For example, rcu_dereference_check(gp, rcu_read_lock_held()) to -* ensure that the rcu_dereference_check() executes within an RCU -* read-side critical section. It is also possible to check for -* locks being held, for example, by using lockdep_is_held(). +* Do an rcu_dereference(), but check that the conditions under which the +* dereference will take place are correct. Typically the conditions indicate +* the various locking conditions that should be held at that point. The check +* should return true if the conditions are satisfied. +* +* For example: +* +* bar = rcu_dereference_check(foo->bar, rcu_read_lock_held() || +* lockdep_is_held(&foo->lock)); +* +* could be used to indicate to lockdep that foo->bar may only be dereferenced +* if either the RCU read lock is held, or that the lock required to replace +* the bar struct at foo->bar is held. +*
Quoted 8 lines
include/linux/rcupdate.h static inline int rcu_read_lock_sched_held(void) · line 220
Quoted 6 lines
include/linux/rcupdate.h +6
-0+* Note that the list of conditions may also include indications of when a lock +* need not be held, for example during initialisation or destruction of the +* target struct: +* +* bar = rcu_dereference_check(foo->bar, rcu_read_lock_held() || +* lockdep_is_held(&foo->lock), ^^ || ?
Good catch, fixed!
Thanx, Paul
Quoted 13 lines
Thanks,
YongQuoted 10 lines
include/linux/rcupdate.h +1
-1+* atomic_read(&foo->usage) == 0); */ #define rcu_dereference_check (p, c) \ ({ \ --To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/