v5 add lockdep-based diagnostics to rcu_dereference()
Subsystems (22)
cover v5 add lockdep-based diagnostics to rcu_dereference()
Hello!
This patch series adds lockdep-based checking to the rcu_dereference() primitive in order to flag misuses of RCU. The first four patches put the RCU infrastructure in place, the next eight use this infrastructure in the net, sched, vfs, radix-tree, idr, and security subsystems, and the last patch documents how to use the new lockdep-checked rcu_dereference() primitives. The remaining five patches are other changes that also need to be applied.
The new (and default-disabled) CONFIG_PROVE_RCU makes this safe to include in tip/core/rcu -- unlike v2, your system won't complain about RCU misuse unless you ask it to. There are still several situations that trigger on systems I have access to (and I have email out on a couple of them), some of the remaining will be triggered only by hardware I don't have access to and kernel features I am unfamiliar with. So this is ready for some more-general testing.
Changes since v4 (http://lkml.org/lkml/2010/2/11/356)
o Apply review comments from Peter Ziljstra.
o Another documentation update.
o Fixes that avoid overflowing signed integers.
o Rebased Thomas Gleixner's raw-spinlock patch on this series.
(Thomas's original at http://lkml.org/lkml/2010/2/17/182.)
Changes since v3 (http://lkml.org/lkml/2010/1/14/505)
o Fix a few more issues identified by the checking.
o Add a documentation update.
o Accelerate RCU grace periods when the current CPU is the last
non-dyntick-idle CPU in the system, which is important for some multi-core battery-powered devices.
Changes since v2 (http://lkml.org/lkml/2010/1/4/496):
o Removed references to the check condition for the non-lockdep
version of rcu_dereference_check(), thus preventing numerous build errors.
o Create a CONFIG_PROVE_RCU (default disabled) so that developers
who want to use lockdep only to debug locks aren't bothered by RCU-specific lockdep complaints that will no doubt persist for a little bit while some of the more obscure uses of RCU are reverse-engineered.
o Fix a few more issues identified by the checking.
o Add documentation in Documentation/RCU/lockdep.txt.
Changes since v1 (http://lkml.org/lkml/2009/12/15/553):
o Made SRCU have per-srcu_struct lockdep maps to prevent lockdep
from conflating independent uses of SRCU, and updated the rcu_dereference() checking in rcutorture to match.
o Fix a few issues identified by the checking.
o Disable checking within RCU list macros, RCU radix trees, and
IDR.
PATCH 1/18 rcu: introduce lockdep-based checking to RCU read-side primitives
Inspection is proving insufficient to catch all RCU misuses, which is understandable given that rcu_dereference() might be protected by any of four different flavors of RCU (RCU, RCU-bh, RCU-sched, and SRCU), and might also/instead be protected by any of a number of locking primitives. It is therefore time to enlist the aid of lockdep.
This set of patches is inspired by earlier work by Peter Zijlstra and Thomas Gleixner, and takes the following approach:
o Set up separate lockdep classes for RCU, RCU-bh, and RCU-sched.
o Set up separate lockdep classes for each instance of SRCU.
o Create primitives that check for being in an RCU read-side
critical section. These return exact answers if lockdep is fully enabled, but if unsure, report being in an RCU read-side critical section. (We want to avoid false positives!) The primitives are:
For RCU: rcu_read_lock_held(void)
For RCU-bh: rcu_read_lock_bh_held(void)
For RCU-sched: rcu_read_lock_sched_held(void)
For SRCU: srcu_read_lock_held(struct srcu_struct *sp)
o Add rcu_dereference_check(), which takes a second argument
in which one places a boolean expression based on the above primitives and/or lockdep_is_held().
o A new kernel configuration parameter, CONFIG_PROVE_RCU, enables
rcu_dereference_check(). This depends on CONFIG_PROVE_LOCKING, and should be quite helpful during the transition period while CONFIG_PROVE_RCU-unaware patches are in flight.
The existing rcu_dereference() primitive does no checking, but upcoming patches will change that.
--- include/linux/rcupdate.h | 126 ++++++++++++++++++++++++++++++++++++++++++---- include/linux/srcu.h | 87 +++++++++++++++++++++++++++++++- kernel/rcupdate.c | 10 ++++ kernel/rcutorture.c | 12 ++++- kernel/srcu.c | 50 ++++++++++++------ lib/Kconfig.debug | 12 ++++ lib/debug_locks.c | 1 + 7 files changed, 267 insertions(+), 31 deletions(-)
include/linux/rcupdate.h +116 -10
@@ -78,14 +78,120 @@ extern void rcu_init(void); } while (0)#ifdef CONFIG_DEBUG_LOCK_ALLOC +extern struct lockdep_map rcu_lock_map; -# define rcu_read_acquire () \ - lock_acquire(&rcu_lock_map, 0, 0, 2, 1, NULL, _THIS_IP_) +# define rcu_read_acquire () \ + lock_acquire(&rcu_lock_map, 0, 0, 2, 1, NULL, _THIS_IP_)# define rcu_read_release () lock_release(&rcu_lock_map, 1, _THIS_IP_) -#else -# define rcu_read_acquire () do { } while (0) -# define rcu_read_release () do { } while (0) -#endif + +extern struct lockdep_map rcu_bh_lock_map; +# define rcu_read_acquire_bh () \ + lock_acquire(&rcu_bh_lock_map, 0, 0, 2, 1, NULL, _THIS_IP_) +# define rcu_read_release_bh () lock_release(&rcu_bh_lock_map, 1, _THIS_IP_) + +extern struct lockdep_map rcu_sched_lock_map; +# define rcu_read_acquire_sched () \ + lock_acquire(&rcu_sched_lock_map, 0, 0, 2, 1, NULL, _THIS_IP_) +# define rcu_read_release_sched () \ + lock_release(&rcu_sched_lock_map, 1, _THIS_IP_) + +/** +* rcu_read_lock_held - might we be in RCU read-side critical section? +* +* If CONFIG_PROVE_LOCKING is selected and enabled, returns nonzero iff in +* an RCU read-side critical section. In absence of CONFIG_PROVE_LOCKING, +* this assumes we are in an RCU read-side critical section unless it can +* prove otherwise. +*/ +static inline int rcu_read_lock_held (void ) +{ +if (debug_locks) +return lock_is_held (&rcu_lock_map); +return 1 ; +} + +/** +* rcu_read_lock_bh_held - might we be in RCU-bh read-side critical section? +* +* If CONFIG_PROVE_LOCKING is selected and enabled, returns nonzero iff in +* an RCU-bh read-side critical section. In absence of CONFIG_PROVE_LOCKING, +* this assumes we are in an RCU-bh read-side critical section unless it can +* prove otherwise. +*/ +static inline int rcu_read_lock_bh_held (void ) +{ +if (debug_locks) +return lock_is_held (&rcu_bh_lock_map); +return 1 ; +} + +/** +* rcu_read_lock_sched_held - might we be in RCU-sched read-side critical section? +* +* If CONFIG_PROVE_LOCKING is selected and enabled, returns nonzero iff in an +* RCU-sched read-side critical section. In absence of CONFIG_PROVE_LOCKING, +* this assumes we are in an RCU-sched read-side critical section unless it +* can prove otherwise. Note that disabling of preemption (including +* disabling irqs) counts as an RCU-sched read-side critical section. +*/ +static inline int rcu_read_lock_sched_held (void ) +{ +int lockdep_opinion =0 ; + +if (debug_locks) + lockdep_opinion =lock_is_held (&rcu_sched_lock_map); +return lockdep_opinion ||preempt_count () !=0 ; +} + +#else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */ + +# define rcu_read_acquire () do { } while (0) +# define rcu_read_release () do { } while (0) +# define rcu_read_acquire_bh () do { } while (0) +# define rcu_read_release_bh () do { } while (0) +# define rcu_read_acquire_sched () do { } while (0) +# define rcu_read_release_sched () do { } while (0) + +static inline int rcu_read_lock_held (void ) +{ +return 1 ; +} + +static inline int rcu_read_lock_bh_held (void ) +{ +return 1 ; +} + +static inline int rcu_read_lock_sched_held (void ) +{ +return preempt_count () !=0 ; +} + +#endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */ + +#ifdef CONFIG_PROVE_RCU + +/** +* rcu_dereference_check - rcu_dereference with debug checking +* +* 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(). +*/ +#define rcu_dereference_check (p, c) \ + ({ \ + if (debug_locks) \ + WARN_ON_ONCE(!(c)); \ + rcu_dereference(p); \ + }) + +#else /* #ifdef CONFIG_PROVE_RCU */ + +#define rcu_dereference_check (p, c) rcu_dereference(p) + +#endif /* #else #ifdef CONFIG_PROVE_RCU */ /** * rcu_read_lock - mark the beginning of an RCU read-side critical section.
@@ -160,7 +266,7 @@ static inline void rcu_read_lock_bh(void) {__rcu_read_lock_bh ();__acquire (RCU_BH ); -rcu_read_acquire (); +rcu_read_acquire_bh (); }/*
@@ -170,7 +276,7 @@ static inline void rcu_read_lock_bh(void)*/ static inline void rcu_read_unlock_bh (void ) { -rcu_read_release (); +rcu_read_release_bh ();__release (RCU_BH );__rcu_read_unlock_bh (); }
@@ -188,7 +294,7 @@ static inline void rcu_read_lock_sched(void) {preempt_disable ();__acquire (RCU_SCHED ); -rcu_read_acquire (); +rcu_read_acquire_sched (); }/* Used by lockdep and tracing: cannot be traced, cannot call lockdep. */
@@ -205,7 +311,7 @@ static inline notrace void rcu_read_lock_sched_notrace(void)*/ static inline void rcu_read_unlock_sched (void ) { -rcu_read_release (); +rcu_read_release_sched ();__release (RCU_SCHED );preempt_enable (); }
include/linux/srcu.h +85 -2
103 lines not on this page · raw message
kernel/rcupdate.c +10 -0
@@ -50,6 +50,16 @@ static struct lock_class_key rcu_lock_key;struct lockdep_map rcu_lock_map =STATIC_LOCKDEP_MAP_INIT ("rcu_read_lock" , &rcu_lock_key);EXPORT_SYMBOL_GPL (rcu_lock_map); + +static struct lock_class_key rcu_bh_lock_key; +struct lockdep_map rcu_bh_lock_map = +STATIC_LOCKDEP_MAP_INIT ("rcu_read_lock_bh" , &rcu_bh_lock_key); +EXPORT_SYMBOL_GPL (rcu_bh_lock_map); + +static struct lock_class_key rcu_sched_lock_key; +struct lockdep_map rcu_sched_lock_map = +STATIC_LOCKDEP_MAP_INIT ("rcu_read_lock_sched" , &rcu_sched_lock_key); +EXPORT_SYMBOL_GPL (rcu_sched_lock_map);#endif /*
kernel/rcutorture.c +10 -2
@@ -796,7 +796,11 @@ static void rcu_torture_timer(unsigned long unused) idx = cur_ops->readlock (); completed = cur_ops->completed (); - p =rcu_dereference (rcu_torture_current); + p =rcu_dereference_check (rcu_torture_current, +rcu_read_lock_held () || +rcu_read_lock_bh_held () || +rcu_read_lock_sched_held () || +srcu_read_lock_held (&srcu_ctl));if (p ==NULL ) {/* Leave because rcu_torture_writer is not yet underway */ cur_ops->readunlock (idx);
@@ -853,7 +857,11 @@ rcu_torture_reader(void *arg) } idx = cur_ops->readlock (); completed = cur_ops->completed (); - p =rcu_dereference (rcu_torture_current); + p =rcu_dereference_check (rcu_torture_current, +rcu_read_lock_held () || +rcu_read_lock_bh_held () || +rcu_read_lock_sched_held () || +srcu_read_lock_held (&srcu_ctl));if (p ==NULL ) {/* Wait for rcu_torture_writer to get underway */ cur_ops->readunlock (idx);
kernel/srcu.c +33 -17
93 lines not on this page · raw message
lib/Kconfig.debug +12 -0
@@ -499,6 +499,18 @@ config PROVE_LOCKING For more details, see Documentation/lockdep-design.txt. +config PROVE_RCU + bool "RCU debugging: prove RCU correctness" + depends on PROVE_LOCKING + default n + help + This feature enables lockdep extensions that check for correct + use of RCU APIs. This is currently under development. Say Y + if you want to debug RCU usage or help work on the PROVE_RCU + feature. + + Say N if you are unsure. + config LOCKDEP bool depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
lib/debug_locks.c +1 -0
@@ -23,6 +23,7 @@* shut up after that. */ int debug_locks =1 ; +EXPORT_SYMBOL_GPL (debug_locks);/* * The locking-testsuite uses <debug_locks_silent> to get a
Signature · 1 line
1.6.6
PATCH 2/18 rcu: add lockdep-enabled variants of rcu_dereference()
In reply to Paul E. McKenneyMake rcu_dereference() check for being in an RCU read-side critical section, and create rcu_dereference_bh(), rcu_dereference_sched(), and srcu_dereference() to check for the other flavors of RCU. Also create rcu_dereference_raw() to avoid checking, and make rcu_dereference_check() use rcu_dereference_raw().
--- include/linux/rcupdate.h | 41 ++++++++++++++++++++++++++++++++++------- include/linux/srcu.h | 8 ++++++++ 2 files changed, 42 insertions(+), 7 deletions(-)
include/linux/rcupdate.h +34 -7
@@ -184,12 +184,12 @@ static inline int rcu_read_lock_sched_held(void) ({ \if (debug_locks) \WARN_ON_ONCE (!(c)); \ -rcu_dereference (p); \ +rcu_dereference_raw (p); \ })#else /* #ifdef CONFIG_PROVE_RCU */ -#define rcu_dereference_check (p, c) rcu_dereference(p) +#define rcu_dereference_check (p, c) rcu_dereference_raw(p)#endif /* #else #ifdef CONFIG_PROVE_RCU */
@@ -325,22 +325,49 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)/** -* rcu_dereference - fetch an RCU-protected pointer in an -* RCU read-side critical section. This pointer may later -* be safely dereferenced. +* rcu_dereference_raw - fetch an RCU-protected pointer +* +* The caller must be within some flavor of RCU read-side critical +* section, or must be otherwise preventing the pointer from changing, +* for example, by holding an appropriate lock. This pointer may later +* be safely dereferenced. It is the caller's responsibility to have +* done the right thing, as this primitive does no checking of any kind. * * Inserts memory barriers on architectures that require them * (currently only the Alpha), and, more importantly, documents * exactly which pointers are protected by RCU. */ - -#define rcu_dereference (p) ({ \ +#define rcu_dereference_raw (p) ({ \ typeof(p) _________p1 = ACCESS_ONCE(p); \ smp_read_barrier_depends(); \ (_________p1); \ })/** +* rcu_dereference - fetch an RCU-protected pointer, checking for RCU +* +* Makes rcu_dereference_check() do the dirty work. +*/ +#define rcu_dereference (p) \ + rcu_dereference_check(p, rcu_read_lock_held()) + +/** +* rcu_dereference_bh - fetch an RCU-protected pointer, checking for RCU-bh +* +* Makes rcu_dereference_check() do the dirty work. +*/ +#define rcu_dereference_bh (p) \ + rcu_dereference_check(p, rcu_read_lock_bh_held()) + +/** +* rcu_dereference_sched - fetch RCU-protected pointer, checking for RCU-sched +* +* Makes rcu_dereference_check() do the dirty work. +*/ +#define rcu_dereference_sched (p) \ + rcu_dereference_check(p, rcu_read_lock_sched_held()) + +/** * rcu_assign_pointer - assign (publicize) a pointer to a newly * initialized structure that will be dereferenced by RCU read-side * critical sections. Returns the value assigned.
include/linux/srcu.h +8 -0
@@ -106,6 +106,14 @@ static inline int srcu_read_lock_held(struct srcu_struct *sp)#endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */ /** +* srcu_dereference - fetch SRCU-protected pointer with checking +* +* Makes rcu_dereference_check() do the dirty work. +*/ +#define srcu_dereference (p, sp) \ + rcu_dereference_check(p, srcu_read_lock_held(sp)) + +/** * srcu_read_lock - register a new reader for an SRCU-protected structure. * @sp: srcu_struct in which to register the new reader. *
Signature · 1 line
1.6.6
PATCH 3/18 rcu: integrate rcu_dereference_check() message into lockdep
In reply to Paul E. McKenneyMake rcu_dereference_check() print the list of held locks in addition to the stack dump to ease debugging.
--- include/linux/lockdep.h | 4 ++++ include/linux/rcupdate.h | 4 ++-- kernel/lockdep.c | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-)
include/linux/lockdep.h +4 -0
@@ -534,4 +534,8 @@ do { \# define might_lock_read (lock) do { } while (0)#endif +#ifdef CONFIG_PROVE_RCU +extern void lockdep_rcu_dereference (const char *file,const int line); +#endif +#endif /* __LINUX_LOCKDEP_H */
include/linux/rcupdate.h +2 -2
@@ -182,8 +182,8 @@ static inline int rcu_read_lock_sched_held(void)*/ #define rcu_dereference_check (p, c) \ ({ \ - if (debug_locks) \ - WARN_ON_ONCE(!(c)); \ + if (debug_locks && !(c)) \ + lockdep_rcu_dereference(__FILE__, __LINE__); \ rcu_dereference_raw(p); \ })
kernel/lockdep.c +18 -0
@@ -3809,3 +3809,21 @@ void lockdep_sys_exit(void)lockdep_print_held_locks (curr); } } + +void lockdep_rcu_dereference (const char *file,const int line) +{ +struct task_struct *curr = current; + +if (!debug_locks_off ()) +return ; +printk ("\n==============================================\n" ); +printk ("[ BUG: Unsafe rcu_dereference_check() usage! ]\n" ); +printk ("----------------------------------------------\n" ); +printk ("%s:%d invoked rcu_dereference_check() without protection!\n" , + file, line); +printk ("\nother info that might help us debug this:\n\n" ); +lockdep_print_held_locks (curr); +printk ("\nstack backtrace:\n" ); +dump_stack (); +} +EXPORT_SYMBOL_GPL (lockdep_rcu_dereference);
Signature · 1 line
1.6.6
PATCH 4/18 rcu: disable lockdep checking in RCU list-traversal primitives
In reply to Paul E. McKenneyThe theory is that use of bare rcu_dereference() is more prone to error than use of the RCU list-traversal primitives. Therefore, disable lockdep RCU read-side critical-section checking in these primitives for the time being. Once all of the rcu_dereference() uses have been dealt with, it may be time to re-enable lockdep checking for the RCU list-traversal primitives.
--- include/linux/rculist.h | 14 +++++++------- include/linux/rculist_nulls.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-)
include/linux/rculist.h +7 -7
@@ -208,7 +208,7 @@ static inline void list_splice_init_rcu(struct list_head *list,* primitives such as list_add_rcu() as long as it's guarded by rcu_read_lock(). */ #define list_entry_rcu (ptr, type, member) \ - container_of(rcu_dereference(ptr), type, member) + container_of(rcu_dereference_raw(ptr), type, member)/** * list_first_entry_rcu - get the first element from a list
@@ -225,9 +225,9 @@ static inline void list_splice_init_rcu(struct list_head *list, list_entry_rcu((ptr)->next, type, member)#define __list_for_each_rcu (pos, head) \ - for (pos = rcu_dereference((head)->next); \ + for (pos = rcu_dereference_raw((head)->next); \ pos != (head); \ - pos = rcu_dereference(pos->next)) + pos = rcu_dereference_raw(pos->next))/** * list_for_each_entry_rcu - iterate over rcu list of given type
@@ -257,9 +257,9 @@ static inline void list_splice_init_rcu(struct list_head *list,* as long as the traversal is guarded by rcu_read_lock(). */ #define list_for_each_continue_rcu (pos, head) \ - for ((pos) = rcu_dereference((pos)->next); \ + for ((pos) = rcu_dereference_raw((pos)->next); \ prefetch((pos)->next), (pos) != (head); \ - (pos) = rcu_dereference((pos)->next)) + (pos) = rcu_dereference_raw((pos)->next))/** * list_for_each_entry_continue_rcu - continue iteration over list of given type
@@ -418,10 +418,10 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev,* as long as the traversal is guarded by rcu_read_lock(). */ #define hlist_for_each_entry_rcu (tpos, pos, head, member) \ - for (pos = rcu_dereference((head)->first); \ + for (pos = rcu_dereference_raw((head)->first); \ pos && ({ prefetch(pos->next); 1; }) && \ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); \ - pos = rcu_dereference(pos->next)) + pos = rcu_dereference_raw(pos->next))#endif /* __KERNEL__ */ #endif
include/linux/rculist_nulls.h +2 -2
@@ -101,10 +101,10 @@ static inline void hlist_nulls_add_head_rcu(struct hlist_nulls_node *n,* */ #define hlist_nulls_for_each_entry_rcu (tpos, pos, head, member) \ - for (pos = rcu_dereference((head)->first); \ + for (pos = rcu_dereference_raw((head)->first); \ (!is_a_nulls(pos)) && \ ({ tpos = hlist_nulls_entry(pos, typeof(*tpos), member); 1; }); \ - pos = rcu_dereference(pos->next)) + pos = rcu_dereference_raw(pos->next))#endif #endif
Signature · 1 line
1.6.6
PATCH 5/18 net: add checking to rcu_dereference() primitives
In reply to Paul E. McKenneyUpdate rcu_dereference() primitives to use new lockdep-based checking. The rcu_dereference() in __in6_dev_get() may be protected either by rcu_read_lock() or RTNL, per Eric Dumazet. The rcu_dereference() in __sk_free() is protected by the fact that it is never reached if an update could change it. Check for this by using rcu_dereference_check() to verify that the struct sock's ->sk_wmem_alloc counter is zero.
--- include/linux/rtnetlink.h | 3 +++ include/net/addrconf.h | 4 +++- net/core/dev.c | 2 +- net/core/filter.c | 6 +++--- net/core/rtnetlink.c | 8 ++++++++ net/core/sock.c | 3 ++- net/decnet/dn_route.c | 14 +++++++------- net/ipv4/route.c | 14 +++++++------- net/packet/af_packet.c | 2 +- 9 files changed, 35 insertions(+), 21 deletions(-)
include/linux/rtnetlink.h +3 -0
@@ -735,6 +735,9 @@ extern void rtnl_lock(void);extern void rtnl_unlock (void );extern int rtnl_trylock (void );extern int rtnl_is_locked (void ); +#ifdef CONFIG_PROVE_LOCKING +extern int lockdep_rtnl_is_held (void ); +#endif /* #ifdef CONFIG_PROVE_LOCKING */ extern void rtnetlink_init (void );extern void __rtnl_unlock (void );
include/net/addrconf.h +3 -1
@@ -177,7 +177,9 @@ extern int unregister_inet6addr_notifier(struct notifier_block *nb);static inline struct inet6_dev *__in6_dev_get (struct net_device *dev) { -return rcu_dereference (dev->ip6_ptr); +return rcu_dereference_check (dev->ip6_ptr, +rcu_read_lock_held () || +lockdep_rtnl_is_held ()); } static inline struct inet6_dev *
net/core/dev.c +1 -1
@@ -2041,7 +2041,7 @@ gso:rcu_read_lock_bh (); txq =dev_pick_tx (dev, skb); - q =rcu_dereference (txq->qdisc); + q =rcu_dereference_bh (txq->qdisc);#ifdef CONFIG_NET_CLS_ACT skb->tc_verd =SET_TC_AT (skb->tc_verd,AT_EGRESS );
net/core/filter.c +3 -3
@@ -86,7 +86,7 @@ int sk_filter(struct sock *sk, struct sk_buff *skb)return err;rcu_read_lock_bh (); - filter =rcu_dereference (sk->sk_filter); + filter =rcu_dereference_bh (sk->sk_filter);if (filter) {unsigned int pkt_len =sk_run_filter (skb, filter->insns, filter->len);
@@ -521,7 +521,7 @@ int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk) }rcu_read_lock_bh (); - old_fp =rcu_dereference (sk->sk_filter); + old_fp =rcu_dereference_bh (sk->sk_filter);rcu_assign_pointer (sk->sk_filter, fp);rcu_read_unlock_bh ();
@@ -536,7 +536,7 @@ int sk_detach_filter(struct sock *sk)struct sk_filter *filter;rcu_read_lock_bh (); - filter =rcu_dereference (sk->sk_filter); + filter =rcu_dereference_bh (sk->sk_filter);if (filter) {rcu_assign_pointer (sk->sk_filter,NULL );sk_filter_delayed_uncharge (sk, filter);
net/core/rtnetlink.c +8 -0
@@ -89,6 +89,14 @@ int rtnl_is_locked(void) }EXPORT_SYMBOL (rtnl_is_locked); +#ifdef CONFIG_PROVE_LOCKING +int lockdep_rtnl_is_held (void ) +{ +return lockdep_is_held (&rtnl_mutex); +} +EXPORT_SYMBOL (lockdep_rtnl_is_held); +#endif /* #ifdef CONFIG_PROVE_LOCKING */ +static struct rtnl_link *rtnl_msg_handlers[NPROTO ];static inline int rtm_msgindex (int msgtype)
net/core/sock.c +2 -1
@@ -1073,7 +1073,8 @@ static void __sk_free(struct sock *sk)if (sk->sk_destruct) sk->sk_destruct (sk); - filter =rcu_dereference (sk->sk_filter); + filter =rcu_dereference_check (sk->sk_filter, +atomic_read (&sk->sk_wmem_alloc) ==0 );if (filter) {sk_filter_uncharge (sk, filter);rcu_assign_pointer (sk->sk_filter,NULL );
net/decnet/dn_route.c +7 -7
@@ -1155,8 +1155,8 @@ static int __dn_route_output_key(struct dst_entry **pprt, const struct flowi *flif (!(flags &MSG_TRYHARD )) {rcu_read_lock_bh (); -for (rt =rcu_dereference (dn_rt_hash_table[hash].chain); rt; - rt =rcu_dereference (rt->u.dst.dn_next)) { +for (rt =rcu_dereference_bh (dn_rt_hash_table[hash].chain); rt; + rt =rcu_dereference_bh (rt->u.dst.dn_next)) { if ((flp->fld_dst == rt->fl.fld_dst) && (flp->fld_src == rt->fl.fld_src) && (flp->mark == rt->fl.mark) &&
@@ -1618,9 +1618,9 @@ int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb)if (h > s_h) s_idx =0 ;rcu_read_lock_bh (); -for (rt =rcu_dereference (dn_rt_hash_table[h].chain), idx =0 ; +for (rt =rcu_dereference_bh (dn_rt_hash_table[h].chain), idx =0 ; rt; - rt =rcu_dereference (rt->u.dst.dn_next), idx++) { + rt =rcu_dereference_bh (rt->u.dst.dn_next), idx++) {if (idx < s_idx)continue ;skb_dst_set (skb,dst_clone (&rt->u.dst));
@@ -1654,12 +1654,12 @@ static struct dn_route *dn_rt_cache_get_first(struct seq_file *seq)for (s->bucket = dn_rt_hash_mask; s->bucket >=0 ; --s->bucket) {rcu_read_lock_bh (); - rt = dn_rt_hash_table[s->bucket].chain; + rt =rcu_dereference_bh (dn_rt_hash_table[s->bucket].chain);if (rt)break ;rcu_read_unlock_bh (); } -return rcu_dereference (rt); +return rt; }static struct dn_route *dn_rt_cache_get_next (struct seq_file *seq,struct dn_route *rt)
@@ -1674,7 +1674,7 @@ static struct dn_route *dn_rt_cache_get_next(struct seq_file *seq, struct dn_rourcu_read_lock_bh (); rt = dn_rt_hash_table[s->bucket].chain; } -return rcu_dereference (rt); +return rcu_dereference_bh (rt); }static void *dn_rt_cache_seq_start (struct seq_file *seq,loff_t *pos)
net/ipv4/route.c +7 -7
@@ -287,12 +287,12 @@ static struct rtable *rt_cache_get_first(struct seq_file *seq)if (!rt_hash_table[st->bucket].chain)continue ;rcu_read_lock_bh (); - r =rcu_dereference (rt_hash_table[st->bucket].chain); + r =rcu_dereference_bh (rt_hash_table[st->bucket].chain);while (r) {if (dev_net (r->u.dst.dev) ==seq_file_net (seq) && r->rt_genid == st->genid)return r; - r =rcu_dereference (r->u.dst.rt_next); + r =rcu_dereference_bh (r->u.dst.rt_next); }rcu_read_unlock_bh (); }
@@ -314,7 +314,7 @@ static struct rtable *__rt_cache_get_next(struct seq_file *seq,rcu_read_lock_bh (); r = rt_hash_table[st->bucket].chain; } -return rcu_dereference (r); +return rcu_dereference_bh (r); } static struct rtable *rt_cache_get_next(struct seq_file *seq,
@@ -2687,8 +2687,8 @@ int __ip_route_output_key(struct net *net, struct rtable **rp, hash =rt_hash (flp->fl4_dst, flp->fl4_src, flp->oif,rt_genid (net));rcu_read_lock_bh (); -for (rth =rcu_dereference (rt_hash_table[hash].chain); rth; - rth =rcu_dereference (rth->u.dst.rt_next)) { +for (rth =rcu_dereference_bh (rt_hash_table[hash].chain); rth; + rth =rcu_dereference_bh (rth->u.dst.rt_next)) { if (rth->fl.fl4_dst == flp->fl4_dst && rth->fl.fl4_src == flp->fl4_src && rth->fl.iif == 0 &&
@@ -3006,8 +3006,8 @@ int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb)if (!rt_hash_table[h].chain)continue ;rcu_read_lock_bh (); -for (rt =rcu_dereference (rt_hash_table[h].chain), idx =0 ; rt; - rt =rcu_dereference (rt->u.dst.rt_next), idx++) { +for (rt =rcu_dereference_bh (rt_hash_table[h].chain), idx =0 ; rt; + rt =rcu_dereference_bh (rt->u.dst.rt_next), idx++) {if (!net_eq (dev_net (rt->u.dst.dev), net) || idx < s_idx)continue ;if (rt_is_expired (rt))
net/packet/af_packet.c +1 -1
@@ -508,7 +508,7 @@ static inline unsigned int run_filter(struct sk_buff *skb, struct sock *sk,struct sk_filter *filter;rcu_read_lock_bh (); - filter =rcu_dereference (sk->sk_filter); + filter =rcu_dereference_bh (sk->sk_filter);if (filter !=NULL ) res =sk_run_filter (skb, filter->insns, filter->len);rcu_read_unlock_bh ();
Signature · 1 line
1.6.6
PATCH 6/18 sched: use lockdep-based checking on rcu_dereference()
In reply to Paul E. McKenneyUpdate the rcu_dereference() usages to take advantage of the new lockdep-based checking.
--- include/linux/cgroup.h | 5 ++++- include/linux/cred.h | 2 +- init/main.c | 2 ++ kernel/cgroup.c | 12 ++++++++++++ kernel/exit.c | 14 +++++++++++--- kernel/fork.c | 1 + kernel/notifier.c | 6 +++--- kernel/pid.c | 2 +- kernel/sched.c | 11 ++++++++--- 9 files changed, 43 insertions(+), 12 deletions(-)
include/linux/cgroup.h +4 -1
@@ -28,6 +28,7 @@ struct css_id;extern int cgroup_init_early (void );extern int cgroup_init (void );extern void cgroup_lock (void ); +extern int cgroup_lock_is_held (void );extern bool cgroup_lock_live_group (struct cgroup *cgrp);extern void cgroup_unlock (void );extern void cgroup_fork (struct task_struct *p);
@@ -486,7 +487,9 @@ static inline struct cgroup_subsys_state *cgroup_subsys_state(static inline struct cgroup_subsys_state *task_subsys_state (struct task_struct *task,int subsys_id) { -return rcu_dereference (task->cgroups->subsys[subsys_id]); +return rcu_dereference_check (task->cgroups->subsys[subsys_id], +rcu_read_lock_held () || +cgroup_lock_is_held ()); } static inline struct cgroup* task_cgroup(struct task_struct *task,
include/linux/cred.h +1 -1
@@ -280,7 +280,7 @@ static inline void put_cred(const struct cred *_cred)* task or by holding tasklist_lock to prevent it from being unlinked. */ #define __task_cred (task) \ - ((const struct cred *)(rcu_dereference((task)->real_cred))) + ((const struct cred *)(rcu_dereference_check((task)->real_cred, rcu_read_lock_held() || lockdep_is_held(&tasklist_lock))))/** * get_task_cred - Get another task's objective credentials
init/main.c +2 -0
@@ -416,7 +416,9 @@ static noinline void __init_refok rest_init(void)kernel_thread (kernel_init,NULL ,CLONE_FS |CLONE_SIGHAND );numa_default_policy (); pid =kernel_thread (kthreadd,NULL ,CLONE_FS |CLONE_FILES ); +rcu_read_lock (); kthreadd_task =find_task_by_pid_ns (pid, &init_pid_ns); +rcu_read_unlock ();unlock_kernel ();/*
kernel/cgroup.c +12 -0
@@ -166,6 +166,18 @@ static DEFINE_SPINLOCK(hierarchy_id_lock);*/ static int need_forkexit_callback__read_mostly ; +#ifdef CONFIG_PROVE_LOCKING +int cgroup_lock_is_held (void ) +{ +return lockdep_is_held (&cgroup_mutex); +} +#else /* #ifdef CONFIG_PROVE_LOCKING */ +int cgroup_lock_is_held (void ) +{ +return mutex_is_locked (&cgroup_mutex); +} +#endif /* #else #ifdef CONFIG_PROVE_LOCKING */ +/* convenient tests for these bits */ inline int cgroup_is_removed (const struct cgroup *cgrp) {
kernel/exit.c +11 -3
@@ -85,7 +85,9 @@ static void __exit_signal(struct task_struct *tsk)BUG_ON (!sig);BUG_ON (!atomic_read (&sig->count)); - sighand =rcu_dereference (tsk->sighand); + sighand =rcu_dereference_check (tsk->sighand, +rcu_read_lock_held () || +lockdep_is_held (&tasklist_lock));spin_lock (&sighand->siglock);posix_cpu_timers_exit (tsk);
@@ -170,8 +172,10 @@ void release_task(struct task_struct * p) repeat:tracehook_prepare_release_task (p);/* don't need to get the RCU readlock here - the process is dead and -* can't be modifying its own credentials */ +* can't be modifying its own credentials. But shut RCU-lockdep up */ +rcu_read_lock ();atomic_dec (&__task_cred (p)->user->processes); +rcu_read_unlock ();proc_flush_task (p);
@@ -473,9 +477,11 @@ static void close_files(struct files_struct * files)/* * It is safe to dereference the fd table without RCU or * ->file_lock because this is the last reference to the -* files structure. +* files structure. But use RCU to shut RCU-lockdep up. */ +rcu_read_lock (); fdt =files_fdtable (files); +rcu_read_unlock ();for (;;) {unsigned long set; i = j * __NFDBITS;
@@ -521,10 +527,12 @@ void put_files_struct(struct files_struct *files)* at the end of the RCU grace period. Otherwise, * you can free files immediately. */ +rcu_read_lock (); fdt =files_fdtable (files);if (fdt != &files->fdtab)kmem_cache_free (files_cachep, files);free_fdtable (fdt); +rcu_read_unlock (); } }
kernel/fork.c +1 -0
@@ -86,6 +86,7 @@ int max_threads; /* tunable limit on nr_threads */ DEFINE_PER_CPU(unsigned long, process_counts) = 0;__cacheline_aligned DEFINE_RWLOCK (tasklist_lock );/* outer */ +EXPORT_SYMBOL_GPL (tasklist_lock);int nr_processes (void ) {
kernel/notifier.c +3 -3
@@ -78,10 +78,10 @@ static int __kprobes notifier_call_chain(struct notifier_block **nl,int ret =NOTIFY_DONE ;struct notifier_block *nb, *next_nb; - nb =rcu_dereference (*nl); + nb =rcu_dereference_raw (*nl);while (nb && nr_to_call) { - next_nb =rcu_dereference (nb->next); + next_nb =rcu_dereference_raw (nb->next);#ifdef CONFIG_DEBUG_NOTIFIERS if (unlikely (!func_ptr_is_kernel_text (nb->notifier_call))) {
@@ -309,7 +309,7 @@ int __blocking_notifier_call_chain(struct blocking_notifier_head *nh,* racy then it does not matter what the result of the test * is, we re-check the list after having taken the lock anyway: */ -if (rcu_dereference (nh->head)) { +if (rcu_dereference_raw (nh->head)) {down_read (&nh->rwsem); ret =notifier_call_chain (&nh->head, val, v, nr_to_call, nr_calls);
kernel/pid.c +1 -1
@@ -367,7 +367,7 @@ struct task_struct *pid_task(struct pid *pid, enum pid_type type)struct task_struct *result =NULL ;if (pid) {struct hlist_node *first; - first =rcu_dereference (pid->tasks[type].first); + first =rcu_dereference_check (pid->tasks[type].first,rcu_read_lock_held () ||lockdep_is_held (&tasklist_lock));if (first) result = hlist_entry(first, struct task_struct, pids[(type)].node); }
kernel/sched.c +8 -3
@@ -645,6 +645,11 @@ static inline int cpu_of(struct rq *rq)#endif } +#define for_each_domain_rd (p) \ + rcu_dereference_check((p), \ + rcu_read_lock_sched_held() || \ + lockdep_is_held(&sched_domains_mutex)) +/* * The domain tree (rq->sd) is protected by RCU's quiescent state transition. * See detach_destroy_domains: synchronize_sched for details.
@@ -653,7 +658,7 @@ static inline int cpu_of(struct rq *rq)* preempt-disabled sections. */ #define for_each_domain (cpu, __sd) \ - for (__sd = rcu_dereference(cpu_rq(cpu)->sd); __sd; __sd = __sd->parent) + for (__sd = for_each_domain_rd(cpu_rq(cpu)->sd); __sd; __sd = __sd->parent)#define cpu_rq (cpu) (&per_cpu(runqueues, (cpu)))#define this_rq () (&__get_cpu_var(runqueues))
@@ -1531,7 +1536,7 @@ static unsigned long target_load(int cpu, int type)static struct sched_group *group_of (int cpu) { -struct sched_domain *sd =rcu_dereference (cpu_rq (cpu)->sd); +struct sched_domain *sd =rcu_dereference_sched (cpu_rq (cpu)->sd);if (!sd)return NULL ;
@@ -4877,7 +4882,7 @@ static void run_rebalance_domains(struct softirq_action *h)static inline int on_null_domain (int cpu) { -return !rcu_dereference (cpu_rq (cpu)->sd); +return !rcu_dereference_sched (cpu_rq (cpu)->sd); }/*
Signature · 1 line
1.6.6
PATCH 7/18 sched: better name for for_each_domain_rd
In reply to Paul E. McKenneyAs suggested by Peter Ziljstra, make better choice of name for for_each_domain_rd(), containing "rcu_dereference", given that it is but a wrapper for rcu_dereference_check(). The name rcu_dereference_check_sched_domain() does that and provides a separate per-subsystem name space.
--- kernel/sched.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
kernel/sched.c +2 -2
@@ -645,7 +645,7 @@ static inline int cpu_of(struct rq *rq)#endif } -#define for_each_domain_rd (p) \ +#define rcu_dereference_check_sched_domain (p) \ rcu_dereference_check((p), \ rcu_read_lock_sched_held() || \ lockdep_is_held(&sched_domains_mutex))
@@ -658,7 +658,7 @@ static inline int cpu_of(struct rq *rq)* preempt-disabled sections. */ #define for_each_domain (cpu, __sd) \ - for (__sd = for_each_domain_rd(cpu_rq(cpu)->sd); __sd; __sd = __sd->parent) + for (__sd = rcu_dereference_check_sched_domain(cpu_rq(cpu)->sd); __sd; __sd = __sd->parent)#define cpu_rq (cpu) (&per_cpu(runqueues, (cpu)))#define this_rq () (&__get_cpu_var(runqueues))
Signature · 1 line
1.6.6
PATCH 8/18 vfs: apply lockdep-based checking to rcu_dereference() uses
In reply to Paul E. McKenneyAdd lockdep-ified RCU primitives to alloc_fd(), files_fdtable() and fcheck_files().
--- fs/file.c | 2 +- fs/proc/array.c | 2 ++ fs/proc/base.c | 6 +++++- include/linux/fdtable.h | 8 ++++++-- 4 files changed, 14 insertions(+), 4 deletions(-)
fs/file.c +1 -1
@@ -478,7 +478,7 @@ repeat: error = fd;#if 1 /* Sanity check */ -if (rcu_dereference (fdt->fd[fd]) !=NULL ) { +if (rcu_dereference_raw (fdt->fd[fd]) !=NULL ) {printk (KERN_WARNING "alloc_fd: slot %d not NULL!\n" , fd);rcu_assign_pointer (fdt->fd[fd],NULL ); }
fs/proc/array.c +2 -0
@@ -270,7 +270,9 @@ static inline void task_sig(struct seq_file *m, struct task_struct *p) blocked = p->blocked;collect_sigign_sigcatch (p, &ignored, &caught); num_threads =atomic_read (&p->signal->count); +rcu_read_lock ();/* FIXME: is this correct? */ qsize =atomic_read (&__task_cred (p)->user->sigpending); +rcu_read_unlock (); qlim = p->signal->rlim[RLIMIT_SIGPENDING ].rlim_cur;unlock_task_sighand (p, &flags); }
fs/proc/base.c +5 -1
@@ -1095,8 +1095,12 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,if (!capable (CAP_AUDIT_CONTROL ))return -EPERM ; -if (current !=pid_task (proc_pid (inode),PIDTYPE_PID )) +rcu_read_lock (); +if (current !=pid_task (proc_pid (inode),PIDTYPE_PID )) { +rcu_read_unlock ();return -EPERM ; + } +rcu_read_unlock ();if (count >=PAGE_SIZE ) count =PAGE_SIZE -1 ;
include/linux/fdtable.h +6 -2
@@ -57,7 +57,11 @@ struct files_struct {struct file * fd_array[NR_OPEN_DEFAULT ]; }; -#define files_fdtable (files) (rcu_dereference((files)->fdt)) +#define files_fdtable (files) \ + (rcu_dereference_check((files)->fdt, \ + rcu_read_lock_held() || \ + lockdep_is_held(&(files)->file_lock) || \ + atomic_read(&files->count) == 1))struct file_operations ;struct vfsmount ;
@@ -78,7 +82,7 @@ static inline struct file * fcheck_files(struct files_struct *files, unsigned instruct fdtable *fdt =files_fdtable (files);if (fd < fdt->max_fds) - file =rcu_dereference (fdt->fd[fd]); + file =rcu_dereference_check (fdt->fd[fd],rcu_read_lock_held () ||lockdep_is_held (&files->file_lock) ||atomic_read (&files->count) ==1 );return file; }
Signature · 1 line
1.6.6
PATCH 9/18 vfs: abstract rcu_dereference_check for files-fdtable use
In reply to Paul E. McKenneyCreate an rcu_dereference_check_fdtable() that encapsulates the rcu_dereference_check() condition for fcheck_files() use. This has the beneficial side-effect of getting rid of a very long line.
--- include/linux/fdtable.h | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-)
include/linux/fdtable.h +7 -4
@@ -57,11 +57,14 @@ struct files_struct {struct file * fd_array[NR_OPEN_DEFAULT ]; }; -#define files_fdtable (files) \ - (rcu_dereference_check((files)->fdt, \ +#define rcu_dereference_check_fdtable (files, fdtfd) \ + (rcu_dereference_check((fdtfd), \ rcu_read_lock_held() || \ lockdep_is_held(&(files)->file_lock) || \ - atomic_read(&files->count) == 1)) + atomic_read(&(files)->count) == 1)) + +#define files_fdtable (files) \ + (rcu_dereference_check_fdtable((files), (files)->fdt))struct file_operations ;struct vfsmount ;
@@ -82,7 +85,7 @@ static inline struct file * fcheck_files(struct files_struct *files, unsigned instruct fdtable *fdt =files_fdtable (files);if (fd < fdt->max_fds) - file =rcu_dereference_check (fdt->fd[fd],rcu_read_lock_held () ||lockdep_is_held (&files->file_lock) ||atomic_read (&files->count) ==1 ); + file =rcu_dereference_check_fdtable (files, fdt->fd[fd]);return file; }
Signature · 1 line
1.6.6
PATCH 10/18 radix-tree: disable RCU lockdep checking in radix tree
In reply to Paul E. McKenneyBecause the radix tree is used with many different locking designs, we cannot do any effective checking without changing the radix-tree APIs. It might make sense to do this later, but only if the RCU lockdep checking proves itself sufficiently valuable.
--- lib/radix-tree.c | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-)
lib/radix-tree.c +12 -12
@@ -364,7 +364,7 @@ static void *radix_tree_lookup_element(struct radix_tree_root *root,unsigned int height, shift;struct radix_tree_node *node, **slot; - node =rcu_dereference (root->rnode); + node =rcu_dereference_raw (root->rnode);if (node ==NULL )return NULL ;
@@ -384,7 +384,7 @@ static void *radix_tree_lookup_element(struct radix_tree_root *root, do { slot = (struct radix_tree_node **) (node->slots + ((index>>shift) & RADIX_TREE_MAP_MASK)); - node = rcu_dereference(*slot); + node = rcu_dereference_raw(*slot); if (node == NULL) return NULL;
@@ -568,7 +568,7 @@ int radix_tree_tag_get(struct radix_tree_root *root,if (!root_tag_get (root, tag))return 0 ; - node =rcu_dereference (root->rnode); + node =rcu_dereference_raw (root->rnode);if (node ==NULL )return 0 ;
@@ -602,7 +602,7 @@ int radix_tree_tag_get(struct radix_tree_root *root,BUG_ON (ret && saw_unset_tag);return !!ret; } - node =rcu_dereference (node->slots[offset]); + node =rcu_dereference_raw (node->slots[offset]); shift -=RADIX_TREE_MAP_SHIFT ; height--; }
@@ -711,7 +711,7 @@ __lookup(struct radix_tree_node *slot, void ***results, unsigned long index, } shift -=RADIX_TREE_MAP_SHIFT ; - slot =rcu_dereference (slot->slots[i]); + slot =rcu_dereference_raw (slot->slots[i]);if (slot ==NULL ) goto out; }
@@ -758,7 +758,7 @@ radix_tree_gang_lookup(struct radix_tree_root *root, void **results,unsigned long cur_index = first_index;unsigned int ret; - node =rcu_dereference (root->rnode); + node =rcu_dereference_raw (root->rnode);if (!node)return 0 ;
@@ -787,7 +787,7 @@ radix_tree_gang_lookup(struct radix_tree_root *root, void **results, slot = *(((void ***)results)[ret + i]);if (!slot)continue ; - results[ret + nr_found] =rcu_dereference (slot); + results[ret + nr_found] =rcu_dereference_raw (slot); nr_found++; } ret += nr_found;
@@ -826,7 +826,7 @@ radix_tree_gang_lookup_slot(struct radix_tree_root *root, void ***results,unsigned long cur_index = first_index;unsigned int ret; - node =rcu_dereference (root->rnode); + node =rcu_dereference_raw (root->rnode);if (!node)return 0 ;
@@ -915,7 +915,7 @@ __lookup_tag(struct radix_tree_node *slot, void ***results, unsigned long index, } } shift -=RADIX_TREE_MAP_SHIFT ; - slot =rcu_dereference (slot->slots[i]); + slot =rcu_dereference_raw (slot->slots[i]);if (slot ==NULL )break ; }
@@ -951,7 +951,7 @@ radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results,if (!root_tag_get (root, tag))return 0 ; - node =rcu_dereference (root->rnode); + node =rcu_dereference_raw (root->rnode);if (!node)return 0 ;
@@ -980,7 +980,7 @@ radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results, slot = *(((void ***)results)[ret + i]);if (!slot)continue ; - results[ret + nr_found] =rcu_dereference (slot); + results[ret + nr_found] =rcu_dereference_raw (slot); nr_found++; } ret += nr_found;
@@ -1020,7 +1020,7 @@ radix_tree_gang_lookup_tag_slot(struct radix_tree_root *root, void ***results,if (!root_tag_get (root, tag))return 0 ; - node =rcu_dereference (root->rnode); + node =rcu_dereference_raw (root->rnode);if (!node)return 0 ;
Signature · 1 line
1.6.6
PATCH 11/18 idr: apply lockdep-based diagnostics to rcu_dereference() uses
In reply to Paul E. McKenneyBecause idr can be used with any of a number of locks or with any flavor of RCU, just disable the lockdep-based diagnostics. If idr needs diagnostics, the check expression will need to be passed into the relevant idr primitives as an additional argument.
--- lib/idr.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
lib/idr.c +4 -4
@@ -502,7 +502,7 @@ void *idr_find(struct idr *idp, int id)int n;struct idr_layer *p; - p =rcu_dereference (idp->top); + p =rcu_dereference_raw (idp->top);if (!p)return NULL ; n = (p->layer+1 ) *IDR_BITS ;
@@ -517,7 +517,7 @@ void *idr_find(struct idr *idp, int id)while (n >0 && p) { n -=IDR_BITS ;BUG_ON (n != p->layer*IDR_BITS ); - p =rcu_dereference (p->ary[(id >> n) &IDR_MASK ]); + p =rcu_dereference_raw (p->ary[(id >> n) &IDR_MASK ]); }return ((void *)p); }
@@ -550,7 +550,7 @@ int idr_for_each(struct idr *idp,struct idr_layer **paa = &pa[0 ]; n = idp->layers *IDR_BITS ; - p =rcu_dereference (idp->top); + p =rcu_dereference_raw (idp->top); max =1 << n; id =0 ;
@@ -558,7 +558,7 @@ int idr_for_each(struct idr *idp,while (n >0 && p) { n -=IDR_BITS ; *paa++ = p; - p =rcu_dereference (p->ary[(id >> n) &IDR_MASK ]); + p =rcu_dereference_raw (p->ary[(id >> n) &IDR_MASK ]); }if (p) {
Signature · 1 line
1.6.6
PATCH 12/18 security: apply lockdep-based checking to rcu_dereference() uses
In reply to Paul E. McKenneyApply lockdep-ified RCU primitives to key_gc_keyring() and keyring_destroy().
--- security/keys/gc.c | 3 ++- security/keys/keyring.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-)
security/keys/gc.c +2 -1
@@ -77,7 +77,8 @@ static bool key_gc_keyring(struct key *keyring, time_t limit) goto dont_gc;/* scan the keyring looking for dead keys */ - klist =rcu_dereference (keyring->payload.subscriptions); + klist =rcu_dereference_check (keyring->payload.subscriptions, +lockdep_is_held (&key_serial_lock));if (!klist) goto dont_gc;
security/keys/keyring.c +3 -1
@@ -151,7 +151,9 @@ static void keyring_destroy(struct key *keyring)write_unlock (&keyring_name_lock); } - klist =rcu_dereference (keyring->payload.subscriptions); + klist =rcu_dereference_check (keyring->payload.subscriptions, +rcu_read_lock_held () || +atomic_read (&keyring->usage) ==0 );if (klist) {for (loop = klist->nkeys -1 ; loop >=0 ; loop--)key_put (klist->keys[loop]);
Signature · 1 line
1.6.6
PATCH 13/18 rcu: documentation update for CONFIG_PROVE_RCU
In reply to Paul E. McKenneyAdds a lockdep.txt file and updates checklist.txt and whatisRCU.txt to reflect the new lockdep-enabled capabilities of RCU.
--- Documentation/RCU/00-INDEX | 2 + Documentation/RCU/checklist.txt | 34 +++++++++++-------- Documentation/RCU/lockdep.txt | 67 +++++++++++++++++++++++++++++++++++++++ Documentation/RCU/whatisRCU.txt | 13 +++++--- 4 files changed, 97 insertions(+), 19 deletions(-) create mode 100644 Documentation/RCU/lockdep.txt
Documentation/RCU/00-INDEX +2 -0
@@ -6,6 +6,8 @@ checklist.txt - Review Checklist for RCU Patches listRCU.txt - Using RCU to Protect Read-Mostly Linked Lists +lockdep.txt + - RCU and lockdep checking NMI-RCU.txt - Using RCU to Protect Dynamic NMI Handlers rcubarrier.txt
Documentation/RCU/checklist.txt +20 -14
@@ -127,10 +127,14 @@ over a rather long period of time, but improvements are always welcome! perfectly legal (if redundant) for update-side code to use rcu_dereference() and the "_rcu()" list-traversal primitives. This is particularly useful in code that - is common to readers and updaters. However, neither - rcu_dereference() nor the "_rcu()" list-traversal - primitives can substitute for a good concurrency design - coordinating among multiple updaters. + is common to readers and updaters. However, lockdep + will complain if you access rcu_dereference() outside + of an RCU read-side critical section. See lockdep.txt + to learn what to do about this. + + Of course, neither rcu_dereference() nor the "_rcu()" + list-traversal primitives can substitute for a good + concurrency design coordinating among multiple updaters. b. If the list macros are being used, the list_add_tail_rcu() and list_add_rcu() primitives must be used in order
@@ -249,7 +253,9 @@ over a rather long period of time, but improvements are always welcome! must be protected by appropriate update-side locks. RCU read-side critical sections are delimited by rcu_read_lock() and rcu_read_unlock(), or by similar primitives such as - rcu_read_lock_bh() and rcu_read_unlock_bh(). + rcu_read_lock_bh() and rcu_read_unlock_bh(), in which case + the matching rcu_dereference() primitive must be used in order + to keep lockdep happy, in this case, rcu_dereference_bh(). The reason that it is permissible to use RCU list-traversal primitives when the update-side lock is held is that doing so
@@ -302,15 +308,15 @@ over a rather long period of time, but improvements are always welcome! not the case, a self-spawning RCU callback would prevent the victim CPU from ever going offline.) -14. SRCU (srcu_read_lock(), srcu_read_unlock(), synchronize_srcu(), - and synchronize_srcu_expedited()) may only be invoked from - process context. Unlike other forms of RCU, it -is- permissible - to block in an SRCU read-side critical section (demarked by - srcu_read_lock() and srcu_read_unlock()), hence the "SRCU": - "sleepable RCU". Please note that if you don't need to sleep - in read-side critical sections, you should be using RCU rather - than SRCU, because RCU is almost always faster and easier to - use than is SRCU. +14. SRCU (srcu_read_lock(), srcu_read_unlock(), srcu_dereference(), + synchronize_srcu(), and synchronize_srcu_expedited()) may only + be invoked from process context. Unlike other forms of RCU, it + -is- permissible to block in an SRCU read-side critical section + (demarked by srcu_read_lock() and srcu_read_unlock()), hence the + "SRCU": "sleepable RCU". Please note that if you don't need + to sleep in read-side critical sections, you should be using + RCU rather than SRCU, because RCU is almost always faster and + easier to use than is SRCU. Also unlike other forms of RCU, explicit initialization and cleanup is required via init_srcu_struct() and
Documentation/RCU/lockdep.txt new file +67 -0
67 lines not on this page · raw message
Documentation/RCU/whatisRCU.txt +8 -5
@@ -323,15 +323,17 @@ used as follows: Defer Protect a. synchronize_rcu() rcu_read_lock() / rcu_read_unlock() - call_rcu() + call_rcu() rcu_dereference() b. call_rcu_bh() rcu_read_lock_bh() / rcu_read_unlock_bh() + rcu_dereference_bh() c. synchronize_sched() rcu_read_lock_sched() / rcu_read_unlock_sched() preempt_disable() / preempt_enable() local_irq_save() / local_irq_restore() hardirq enter / hardirq exit NMI enter / NMI exit + rcu_dereference_sched() These three mechanisms are used as follows:
@@ -781,9 +783,8 @@ Linux-kernel source code, but it helps to have a full list of the APIs, since there does not appear to be a way to categorize them in docbook. Here is the list, by category. -RCU pointer/list traversal: +RCU list traversal: - rcu_dereference list_for_each_entry_rcu hlist_for_each_entry_rcu hlist_nulls_for_each_entry_rcu
@@ -809,7 +810,7 @@ RCU: Critical sections Grace period Barrier rcu_read_lock synchronize_net rcu_barrier rcu_read_unlock synchronize_rcu - synchronize_rcu_expedited + rcu_dereference synchronize_rcu_expedited call_rcu
@@ -817,7 +818,7 @@ bh: Critical sections Grace period Barrier rcu_read_lock_bh call_rcu_bh rcu_barrier_bh rcu_read_unlock_bh synchronize_rcu_bh - synchronize_rcu_bh_expedited + rcu_dereference_bh synchronize_rcu_bh_expedited sched: Critical sections Grace period Barrier
@@ -826,12 +827,14 @@ sched: Critical sections Grace period Barrier rcu_read_unlock_sched call_rcu_sched [preempt_disable] synchronize_sched_expedited [and friends] + rcu_dereference_sched SRCU: Critical sections Grace period Barrier srcu_read_lock synchronize_srcu N/A srcu_read_unlock synchronize_srcu_expedited + srcu_dereference SRCU: Initialization/cleanup init_srcu_struct
Signature · 1 line
1.6.6
PATCH 14/18 rcu: fix citation of Mathieu's dissertation
In reply to Paul E. McKenney--- Documentation/RCU/RTFP.txt | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
Documentation/RCU/RTFP.txt +4 -1
@@ -864,9 +864,12 @@ Revised: } @phdthesis{MathieuDesnoyersPhD -, title = "Low-impact Operating System Tracing" +, title = "Low-Impact Operating System Tracing" , author = "Mathieu Desnoyers" , school = "Ecole Polytechnique de Montr\'{e}al" , month = "December" , year = 2009 +,note="Available: +\url{http://www.lttng.org/pub/thesis/desnoyers-dissertation-2009-12-v24.pdf} +[Viewed December 9, 2009]" }
Signature · 1 line
1.6.6
PATCH 15/18 rcu: accelerate grace period if last non-dynticked CPU
In reply to Paul E. McKenneyCurrently, rcu_needs_cpu() simply checks whether the current CPU has an outstanding RCU callback, which means that the last CPU to go into dyntick-idle mode might wait a few ticks for the relevant grace periods to complete. However, if all the other CPUs are in dyntick-idle mode, and if this CPU is in a quiescent state (which it is for RCU-bh and RCU-sched any time that we are considering going into dyntick-idle mode), then the grace period is instantly complete.
This patch therefore repeatedly invokes the RCU grace-period machinery in order to force any needed grace periods to complete quickly. It does so a limited number of times in order to prevent starvation by an RCU callback function that might pass itself to call_rcu().
However, if any CPU other than the current one is not in dyntick-idle mode, fall back to simply checking (with fix to bug noted by Lai Jiangshan). Also, take advantage of last grace-period forcing, the opportunity to do so noted by Steve Rostedt. And apply simplified #ifdef condition suggested by Frederic Weisbecker.
--- include/linux/cpumask.h | 14 +++++++++ init/Kconfig | 16 +++++++++++ kernel/rcutree.c | 5 +-- kernel/rcutree_plugin.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 3 deletions(-)
include/linux/cpumask.h +14 -0
@@ -143,6 +143,8 @@ static inline unsigned int cpumask_any_but(const struct cpumask *mask,#define for_each_cpu (cpu, mask) \ for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask) +#define for_each_cpu_not (cpu, mask) \ + for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)#define for_each_cpu_and (cpu, mask, and) \ for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask, (void)and)#else
@@ -203,6 +205,18 @@ int cpumask_any_but(const struct cpumask *mask, unsigned int cpu); (cpu) < nr_cpu_ids;)/** +* for_each_cpu_not - iterate over every cpu in a complemented mask +* @cpu: the (optionally unsigned) integer iterator +* @mask: the cpumask pointer +* +* After the loop, cpu is >= nr_cpu_ids. +*/ +#define for_each_cpu_not (cpu, mask) \ + for ((cpu) = -1; \ + (cpu) = cpumask_next_zero((cpu), (mask)), \ + (cpu) < nr_cpu_ids;) + +/** * for_each_cpu_and - iterate over every cpu in both masks * @cpu: the (optionally unsigned) integer iterator * @mask: the first cpumask pointer
init/Kconfig +16 -0
@@ -396,6 +396,22 @@ config RCU_FANOUT_EXACT Say N if unsure. +config RCU_FAST_NO_HZ + bool "Accelerate last non-dyntick-idle CPU's grace periods" + depends on TREE_RCU && NO_HZ && SMP + default n + help + This option causes RCU to attempt to accelerate grace periods + in order to allow the final CPU to enter dynticks-idle state + more quickly. On the other hand, this option increases the + overhead of the dynticks-idle checking, particularly on systems + with large numbers of CPUs. + + Say Y if energy efficiency is critically important, particularly + if you have relatively few CPUs. + + Say N if you are unsure. + config TREE_RCU_TRACE def_bool RCU_TRACE && ( TREE_RCU || TREE_PREEMPT_RCU ) select DEBUG_FS
kernel/rcutree.c +2 -3
@@ -1550,10 +1550,9 @@ static int rcu_pending(int cpu)/* * Check to see if any future RCU-related work will need to be done * by the current CPU, even if none need be done immediately, returning -* 1 if so. This function is part of the RCU implementation; it is -not- -* an exported member of the RCU API. +* 1 if so. */ -int rcu_needs_cpu (int cpu) +static int rcu_needs_cpu_quick_check (int cpu) {/* RCU callbacks either ready or pending? */ return per_cpu(rcu_sched_data, cpu).nxtlist ||
kernel/rcutree_plugin.h +69 -0
72 lines not on this page · raw message
Signature · 1 line
1.6.6
PATCH 16/18 rcu: use canonical URL for Mathieu's dissertation
In reply to Paul E. McKenneyThe version numbers change too quickly, so use a canonical URL that represents the most recent version.
--- Documentation/RCU/RTFP.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Documentation/RCU/RTFP.txt +1 -1
@@ -870,6 +870,6 @@ Revised: , month = "December" , year = 2009 ,note="Available: -\url{http://www.lttng.org/pub/thesis/desnoyers-dissertation-2009-12-v24.pdf} +\url{http://www.lttng.org/pub/thesis/desnoyers-dissertation-2009-12.pdf} [Viewed December 9, 2009]" }
Signature · 1 line
1.6.6
PATCH 17/18 rcu: stop overflowing signed integers
In reply to Paul E. McKenneyThe C standard does not specify the result of an operation that overflows a signed integer, so such operations need to be avoided. This patch changes the type of several fields from "long" to "unsigned long" and adjusts operations as needed. ULONG_CMP_GE() and ULONG_CMP_LT() macros are introduced to do the modular comparisons that are appropriate given that overflow is an expected event.
--- kernel/rcutree.c | 11 +++++------ kernel/rcutree.h | 33 ++++++++++++++++++--------------- kernel/rcutree_trace.c | 14 +++++++------- 3 files changed, 30 insertions(+), 28 deletions(-)
kernel/rcutree.c +5 -6
@@ -500,7 +500,7 @@ static void print_cpu_stall(struct rcu_state *rsp)trigger_all_cpu_backtrace ();spin_lock_irqsave (&rnp->lock, flags); -if ((long )(jiffies - rsp->jiffies_stall) >=0 ) +if (ULONG_CMP_GE (jiffies, rsp->jiffies_stall)) rsp->jiffies_stall = jiffies +RCU_SECONDS_TILL_STALL_RECHECK ;spin_unlock_irqrestore (&rnp->lock, flags);
@@ -1216,8 +1216,7 @@ static void force_quiescent_state(struct rcu_state *rsp, int relaxed) rsp->n_force_qs_lh++;/* Inexact, can lose counts. Tough! */ return ;/* Someone else is already on the job. */ } -if (relaxed && - (long )(rsp->jiffies_force_qs - jiffies) >=0 ) +if (relaxed &&ULONG_CMP_GE (rsp->jiffies_force_qs, jiffies)) goto unlock_fqs_ret;/* no emergency and done recently. */ rsp->n_force_qs++;spin_lock (&rnp->lock);/* irqs already disabled */
@@ -1295,7 +1294,7 @@ __rcu_process_callbacks(struct rcu_state *rsp, struct rcu_data *rdp)* If an RCU GP has gone long enough, go check for dyntick * idle CPUs and, if needed, send resched IPIs. */ -if ((long )(ACCESS_ONCE (rsp->jiffies_force_qs) - jiffies) <0 ) +if (ULONG_CMP_LT (ACCESS_ONCE (rsp->jiffies_force_qs), jiffies))force_quiescent_state (rsp,1 );/*
@@ -1392,7 +1391,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),force_quiescent_state (rsp,0 ); rdp->n_force_qs_snap = rsp->n_force_qs; rdp->qlen_last_fqs_check = rdp->qlen; - }else if ((long )(ACCESS_ONCE (rsp->jiffies_force_qs) - jiffies) <0 ) + }else if (ULONG_CMP_LT (ACCESS_ONCE (rsp->jiffies_force_qs), jiffies))force_quiescent_state (rsp,1 );local_irq_restore (flags); }
@@ -1525,7 +1524,7 @@ static int __rcu_pending(struct rcu_state *rsp, struct rcu_data *rdp)/* Has an RCU GP gone long enough to send resched IPIs &c? */ if (rcu_gp_in_progress (rsp) && - ((long )(ACCESS_ONCE (rsp->jiffies_force_qs) - jiffies) <0 )) { +ULONG_CMP_LT (ACCESS_ONCE (rsp->jiffies_force_qs), jiffies)) { rdp->n_rp_need_fqs++;return 1 ; }
kernel/rcutree.h +18 -15
@@ -92,10 +92,10 @@ struct rcu_dynticks {struct rcu_node {spinlock_t lock;/* Root rcu_node's lock protects some */ /* rcu_state fields as well as following. */ -long gpnum;/* Current grace period for this node. */ +unsigned long gpnum;/* Current grace period for this node. */ /* This will either be equal to or one */ /* behind the root rcu_node's gpnum. */ -long completed;/* Last grace period completed for this node. */ +unsigned long completed;/* Last GP completed for this node. */ /* This will either be equal to or one */ /* behind the root rcu_node's gpnum. */ unsigned long qsmask;/* CPUs or groups that need to switch in */
@@ -161,11 +161,11 @@ struct rcu_node {/* Per-CPU data for read-copy update. */ struct rcu_data {/* 1) quiescent-state and grace-period handling : */ -long completed;/* Track rsp->completed gp number */ +unsigned long completed;/* Track rsp->completed gp number */ /* in order to detect GP end. */ -long gpnum;/* Highest gp number that this CPU */ +unsigned long gpnum;/* Highest gp number that this CPU */ /* is aware of having started. */ -long passed_quiesc_completed; +unsigned long passed_quiesc_completed;/* Value of completed at time of qs. */ bool passed_quiesc;/* User-mode/idle loop etc. */ bool qs_pending;/* Core waits for quiesc state. */
@@ -221,14 +221,14 @@ struct rcu_data {unsigned long resched_ipi;/* Sent a resched IPI. */ /* 5) __rcu_pending() statistics. */ -long n_rcu_pending;/* rcu_pending() calls since boot. */ -long n_rp_qs_pending; -long n_rp_cb_ready; -long n_rp_cpu_needs_gp; -long n_rp_gp_completed; -long n_rp_gp_started; -long n_rp_need_fqs; -long n_rp_need_nothing; +unsigned long n_rcu_pending;/* rcu_pending() calls since boot. */ +unsigned long n_rp_qs_pending; +unsigned long n_rp_cb_ready; +unsigned long n_rp_cpu_needs_gp; +unsigned long n_rp_gp_completed; +unsigned long n_rp_gp_started; +unsigned long n_rp_need_fqs; +unsigned long n_rp_need_nothing;int cpu; };
@@ -255,6 +255,9 @@ struct rcu_data {#endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */ +#define ULONG_CMP_GE (a, b) (ULONG_MAX / 2 >= (a) - (b)) +#define ULONG_CMP_LT (a, b) (ULONG_MAX / 2 < (a) - (b)) +/* * RCU global state, including node hierarchy. This hierarchy is * represented in "heap" form in a dense array. The root (first level)
@@ -283,8 +286,8 @@ struct rcu_state {/* period because */ /* force_quiescent_state() */ /* was running. */ -long gpnum;/* Current gp number. */ -long completed;/* # of last completed gp. */ +unsigned long gpnum;/* Current gp number. */ +unsigned long completed;/* # of last completed gp. */ /* End of fields guarded by root rcu_node's lock. */
kernel/rcutree_trace.c +7 -7
@@ -50,7 +50,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp) {if (!rdp->beenonline)return ; - seq_printf(m, "%3d%cc=%ld g=%ld pq=%d pqc=%ld qp=%d", + seq_printf(m, "%3d%cc=%lu g=%lu pq=%d pqc=%lu qp=%d", rdp->cpu, cpu_is_offline(rdp->cpu) ? '!' : ' ', rdp->completed, rdp->gpnum,
@@ -105,7 +105,7 @@ static void print_one_rcu_data_csv(struct seq_file *m, struct rcu_data *rdp) {if (!rdp->beenonline)return ; - seq_printf(m, "%d,%s,%ld,%ld,%d,%ld,%d", + seq_printf(m, "%d,%s,%lu,%lu,%d,%lu,%d", rdp->cpu, cpu_is_offline(rdp->cpu) ? "\"N\"" : "\"Y\"", rdp->completed, rdp->gpnum,
@@ -155,13 +155,13 @@ static const struct file_operations rcudata_csv_fops = {static void print_one_rcu_state (struct seq_file *m,struct rcu_state *rsp) { -long gpnum; +unsigned long gpnum;int level =0 ;int phase;struct rcu_node *rnp; gpnum = rsp->gpnum; - seq_printf(m, "c=%ld g=%ld s=%d jfq=%ld j=%x " + seq_printf(m, "c=%lu g=%lu s=%d jfq=%ld j=%x " "nfqs=%lu/nfqsng=%lu(%lu) fqlh=%lu oqlen=%ld\n", rsp->completed, gpnum, rsp->signaled, (long)(rsp->jiffies_force_qs - jiffies),
@@ -215,12 +215,12 @@ static const struct file_operations rcuhier_fops = {static int show_rcugp (struct seq_file *m,void *unused) {#ifdef CONFIG_TREE_PREEMPT_RCU -seq_printf (m,"rcu_preempt: completed=%ld gpnum=%ld\n" , +seq_printf (m,"rcu_preempt: completed=%ld gpnum=%lu\n" , rcu_preempt_state.completed, rcu_preempt_state.gpnum);#endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */ -seq_printf (m,"rcu_sched: completed=%ld gpnum=%ld\n" , +seq_printf (m,"rcu_sched: completed=%ld gpnum=%lu\n" , rcu_sched_state.completed, rcu_sched_state.gpnum); -seq_printf (m,"rcu_bh: completed=%ld gpnum=%ld\n" , +seq_printf (m,"rcu_bh: completed=%ld gpnum=%lu\n" , rcu_bh_state.completed, rcu_bh_state.gpnum);return 0 ; }
Signature · 1 line
1.6.6
Re: [PATCH tip/core/rcu 17/18] rcu: stop overflowing signed integers
Quoted 8 lines · * Paul E. McKenney ([email protected]) wrote:
The C standard does not specify the result of an operation that overflows a signed integer, so such operations need to be avoided. This patch changes the type of several fields from "long" to "unsigned long" and adjusts operations as needed.
ULONG_CMP_GE()andULONG_CMP_LT()macros are introduced to do the modular comparisons that are appropriate given that overflow is an expected event.Signed-off-by Paul E. McKenney <[email protected]>
I had to do something similar for liburcu QSBR to follow the standard.
Quoted 189 lines
--- kernel/rcutree.c | 11 +++++------ kernel/rcutree.h | 33 ++++++++++++++++++--------------- kernel/rcutree_trace.c | 14 +++++++------- 3 files changed, 30 insertions(+), 28 deletions(-)kernel/rcutree.c +5
-6@@ -500,7 +500,7 @@ static void print_cpu_stall(struct rcu_state *rsp)trigger_all_cpu_backtrace ();spin_lock_irqsave (&rnp->lock, flags); -if ((long )(jiffies - rsp->jiffies_stall) >=0 ) +if (ULONG_CMP_GE (jiffies, rsp->jiffies_stall)) rsp->jiffies_stall = jiffies +RCU_SECONDS_TILL_STALL_RECHECK ;spin_unlock_irqrestore (&rnp->lock, flags);@@ -1216,8 +1216,7 @@ static void force_quiescent_state(struct rcu_state *rsp, int relaxed) rsp->n_force_qs_lh++;/* Inexact, can lose counts. Tough! */ return ;/* Someone else is already on the job. */ } -if (relaxed && - (long )(rsp->jiffies_force_qs - jiffies) >=0 ) +if (relaxed &&ULONG_CMP_GE (rsp->jiffies_force_qs, jiffies)) goto unlock_fqs_ret;/* no emergency and done recently. */ rsp->n_force_qs++;spin_lock (&rnp->lock);/* irqs already disabled */ @@ -1295,7 +1294,7 @@ __rcu_process_callbacks(struct rcu_state *rsp, struct rcu_data *rdp)* If an RCU GP has gone long enough, go check for dyntick * idle CPUs and, if needed, send resched IPIs. */ -if ((long )(ACCESS_ONCE (rsp->jiffies_force_qs) - jiffies) <0 ) +if (ULONG_CMP_LT (ACCESS_ONCE (rsp->jiffies_force_qs), jiffies))force_quiescent_state (rsp,1 );/* @@ -1392,7 +1391,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),force_quiescent_state (rsp,0 ); rdp->n_force_qs_snap = rsp->n_force_qs; rdp->qlen_last_fqs_check = rdp->qlen; - }else if ((long )(ACCESS_ONCE (rsp->jiffies_force_qs) - jiffies) <0 ) + }else if (ULONG_CMP_LT (ACCESS_ONCE (rsp->jiffies_force_qs), jiffies))force_quiescent_state (rsp,1 );local_irq_restore (flags); }@@ -1525,7 +1524,7 @@ static int __rcu_pending(struct rcu_state *rsp, struct rcu_data *rdp)/* Has an RCU GP gone long enough to send resched IPIs &c? */ if (rcu_gp_in_progress (rsp) && - ((long )(ACCESS_ONCE (rsp->jiffies_force_qs) - jiffies) <0 )) { +ULONG_CMP_LT (ACCESS_ONCE (rsp->jiffies_force_qs), jiffies)) { rdp->n_rp_need_fqs++;return 1 ; }kernel/rcutree.h +18
-15@@ -92,10 +92,10 @@ struct rcu_dynticks {struct rcu_node {spinlock_t lock;/* Root rcu_node's lock protects some */ /* rcu_state fields as well as following. */ -long gpnum;/* Current grace period for this node. */ +unsigned long gpnum;/* Current grace period for this node. */ /* This will either be equal to or one */ /* behind the root rcu_node's gpnum. */ -long completed;/* Last grace period completed for this node. */ +unsigned long completed;/* Last GP completed for this node. */ /* This will either be equal to or one */ /* behind the root rcu_node's gpnum. */ unsigned long qsmask;/* CPUs or groups that need to switch in */ @@ -161,11 +161,11 @@ struct rcu_node {/* Per-CPU data for read-copy update. */ struct rcu_data {/* 1) quiescent-state and grace-period handling : */ -long completed;/* Track rsp->completed gp number */ +unsigned long completed;/* Track rsp->completed gp number */ /* in order to detect GP end. */ -long gpnum;/* Highest gp number that this CPU */ +unsigned long gpnum;/* Highest gp number that this CPU */ /* is aware of having started. */ -long passed_quiesc_completed; +unsigned long passed_quiesc_completed;/* Value of completed at time of qs. */ bool passed_quiesc;/* User-mode/idle loop etc. */ bool qs_pending;/* Core waits for quiesc state. */ @@ -221,14 +221,14 @@ struct rcu_data {unsigned long resched_ipi;/* Sent a resched IPI. */ /* 5) __rcu_pending() statistics. */ -long n_rcu_pending;/* rcu_pending() calls since boot. */ -long n_rp_qs_pending; -long n_rp_cb_ready; -long n_rp_cpu_needs_gp; -long n_rp_gp_completed; -long n_rp_gp_started; -long n_rp_need_fqs; -long n_rp_need_nothing; +unsigned long n_rcu_pending;/* rcu_pending() calls since boot. */ +unsigned long n_rp_qs_pending; +unsigned long n_rp_cb_ready; +unsigned long n_rp_cpu_needs_gp; +unsigned long n_rp_gp_completed; +unsigned long n_rp_gp_started; +unsigned long n_rp_need_fqs; +unsigned long n_rp_need_nothing;int cpu; };@@ -255,6 +255,9 @@ struct rcu_data {#endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */ +#define ULONG_CMP_GE (a, b) (ULONG_MAX / 2 >= (a) - (b)) +#define ULONG_CMP_LT (a, b) (ULONG_MAX / 2 < (a) - (b)) +/* * RCU global state, including node hierarchy. This hierarchy is * represented in "heap" form in a dense array. The root (first level) @@ -283,8 +286,8 @@ struct rcu_state {/* period because */ /* force_quiescent_state() */ /* was running. */ -long gpnum;/* Current gp number. */ -long completed;/* # of last completed gp. */ +unsigned long gpnum;/* Current gp number. */ +unsigned long completed;/* # of last completed gp. */ /* End of fields guarded by root rcu_node's lock. */ kernel/rcutree_trace.c +7
-7@@ -50,7 +50,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp) {if (!rdp->beenonline)return ; - seq_printf(m, "%3d%cc=%ld g=%ld pq=%d pqc=%ld qp=%d", + seq_printf(m, "%3d%cc=%lu g=%lu pq=%d pqc=%lu qp=%d", rdp->cpu, cpu_is_offline(rdp->cpu) ? '!' : ' ', rdp->completed, rdp->gpnum,@@ -105,7 +105,7 @@ static void print_one_rcu_data_csv(struct seq_file *m, struct rcu_data *rdp) {if (!rdp->beenonline)return ; - seq_printf(m, "%d,%s,%ld,%ld,%d,%ld,%d", + seq_printf(m, "%d,%s,%lu,%lu,%d,%lu,%d", rdp->cpu, cpu_is_offline(rdp->cpu) ? "\"N\"" : "\"Y\"", rdp->completed, rdp->gpnum,@@ -155,13 +155,13 @@ static const struct file_operations rcudata_csv_fops = {static void print_one_rcu_state (struct seq_file *m,struct rcu_state *rsp) { -long gpnum; +unsigned long gpnum;int level =0 ;int phase;struct rcu_node *rnp; gpnum = rsp->gpnum; - seq_printf(m, "c=%ld g=%ld s=%d jfq=%ld j=%x " + seq_printf(m, "c=%lu g=%lu s=%d jfq=%ld j=%x " "nfqs=%lu/nfqsng=%lu(%lu) fqlh=%lu oqlen=%ld\n", rsp->completed, gpnum, rsp->signaled, (long)(rsp->jiffies_force_qs - jiffies),@@ -215,12 +215,12 @@ static const struct file_operations rcuhier_fops = {static int show_rcugp (struct seq_file *m,void *unused) {#ifdef CONFIG_TREE_PREEMPT_RCU -seq_printf (m,"rcu_preempt: completed=%ld gpnum=%ld\n" , +seq_printf (m,"rcu_preempt: completed=%ld gpnum=%lu\n" , rcu_preempt_state.completed, rcu_preempt_state.gpnum);#endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */ -seq_printf (m,"rcu_sched: completed=%ld gpnum=%ld\n" , +seq_printf (m,"rcu_sched: completed=%ld gpnum=%lu\n" , rcu_sched_state.completed, rcu_sched_state.gpnum); -seq_printf (m,"rcu_bh: completed=%ld gpnum=%ld\n" , +seq_printf (m,"rcu_bh: completed=%ld gpnum=%lu\n" , rcu_bh_state.completed, rcu_bh_state.gpnum);return 0 ; }Signature · 1 line
1.6.6
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
PATCH 18/18 The spinlocks in rcutree need to be real spinlocks in preempt-rt. Convert them to raw_spinlocks.
In reply to Paul E. McKenney--- kernel/rcutree.c | 132 +++++++++++++++++++++++----------------------- kernel/rcutree.h | 6 +- kernel/rcutree_plugin.h | 46 ++++++++-------- 3 files changed, 92 insertions(+), 92 deletions(-)
kernel/rcutree.c +66 -66
@@ -66,11 +66,11 @@ static struct lock_class_key rcu_node_class[NUM_RCU_LVLS]; .signaled = RCU_GP_IDLE, \ .gpnum = -300, \ .completed = -300, \ - .onofflock = __SPIN_LOCK_UNLOCKED(&name.onofflock), \ + .onofflock = __RAW_SPIN_LOCK_UNLOCKED(&name.onofflock), \ .orphan_cbs_list = NULL, \ .orphan_cbs_tail = &name.orphan_cbs_list, \ .orphan_qlen = 0, \ - .fqslock = __SPIN_LOCK_UNLOCKED(&name.fqslock), \ + .fqslock = __RAW_SPIN_LOCK_UNLOCKED(&name.fqslock), \ .n_force_qs = 0, \ .n_force_qs_ngp = 0, \ }
@@ -457,10 +457,10 @@ static void print_other_cpu_stall(struct rcu_state *rsp)/* Only let one CPU complain about others per time interval. */ -spin_lock_irqsave (&rnp->lock, flags); +raw_spin_lock_irqsave (&rnp->lock, flags); delta = jiffies - rsp->jiffies_stall;if (delta <RCU_STALL_RAT_DELAY || !rcu_gp_in_progress (rsp)) { -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);return ; } rsp->jiffies_stall = jiffies +RCU_SECONDS_TILL_STALL_RECHECK ;
@@ -470,7 +470,7 @@ static void print_other_cpu_stall(struct rcu_state *rsp)* due to CPU offlining. */ rcu_print_task_stall (rnp); -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);/* OK, time to rat on our buddy... */
@@ -499,11 +499,11 @@ static void print_cpu_stall(struct rcu_state *rsp) smp_processor_id(), jiffies - rsp->gp_start);trigger_all_cpu_backtrace (); -spin_lock_irqsave (&rnp->lock, flags); +raw_spin_lock_irqsave (&rnp->lock, flags);if (ULONG_CMP_GE (jiffies, rsp->jiffies_stall)) rsp->jiffies_stall = jiffies +RCU_SECONDS_TILL_STALL_RECHECK ; -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);set_need_resched ();/* kick ourselves to get things going. */ }
@@ -563,12 +563,12 @@ static void note_new_gpnum(struct rcu_state *rsp, struct rcu_data *rdp)local_irq_save (flags); rnp = rdp->mynode;if (rdp->gpnum ==ACCESS_ONCE (rnp->gpnum) ||/* outside lock. */ - !spin_trylock (&rnp->lock)) {/* irqs already off, retry later. */ + !raw_spin_trylock (&rnp->lock)) {/* irqs already off, so later. */ local_irq_restore (flags);return ; }__note_new_gpnum (rsp, rnp, rdp); -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags); }/*
@@ -627,12 +627,12 @@ rcu_process_gp_end(struct rcu_state *rsp, struct rcu_data *rdp)local_irq_save (flags); rnp = rdp->mynode;if (rdp->completed ==ACCESS_ONCE (rnp->completed) ||/* outside lock. */ - !spin_trylock (&rnp->lock)) {/* irqs already off, retry later. */ + !raw_spin_trylock (&rnp->lock)) {/* irqs already off, so later. */ local_irq_restore (flags);return ; }__rcu_process_gp_end (rsp, rnp, rdp); -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags); }/*
@@ -681,10 +681,10 @@ rcu_start_gp(struct rcu_state *rsp, unsigned long flags)if (cpu_needs_another_gp (rsp, rdp)) rsp->fqs_need_gp =1 ;if (rnp->completed == rsp->completed) { -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);return ; } -spin_unlock (&rnp->lock);/* irqs remain disabled. */ +raw_spin_unlock (&rnp->lock);/* irqs remain disabled. */ /* * Propagate new ->completed value to rcu_node structures
@@ -692,9 +692,9 @@ rcu_start_gp(struct rcu_state *rsp, unsigned long flags)* of the next grace period to process their callbacks. */ rcu_for_each_node_breadth_first (rsp, rnp) { -spin_lock (&rnp->lock);/* irqs already disabled. */ +raw_spin_lock (&rnp->lock);/* irqs already disabled. */ rnp->completed = rsp->completed; -spin_unlock (&rnp->lock);/* irqs remain disabled. */ +raw_spin_unlock (&rnp->lock);/* irqs remain disabled. */ }local_irq_restore (flags);return ;
@@ -715,15 +715,15 @@ rcu_start_gp(struct rcu_state *rsp, unsigned long flags) rnp->completed = rsp->completed; rsp->signaled =RCU_SIGNAL_INIT ;/* force_quiescent_state OK. */ rcu_start_gp_per_cpu (rsp, rnp, rdp); -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);return ; } -spin_unlock (&rnp->lock);/* leave irqs disabled. */ +raw_spin_unlock (&rnp->lock);/* leave irqs disabled. */ /* Exclude any concurrent CPU-hotplug operations. */ -spin_lock (&rsp->onofflock);/* irqs already disabled. */ +raw_spin_lock (&rsp->onofflock);/* irqs already disabled. */ /* * Set the quiescent-state-needed bits in all the rcu_node
@@ -743,21 +743,21 @@ rcu_start_gp(struct rcu_state *rsp, unsigned long flags)* irqs disabled. */ rcu_for_each_node_breadth_first (rsp, rnp) { -spin_lock (&rnp->lock);/* irqs already disabled. */ +raw_spin_lock (&rnp->lock);/* irqs already disabled. */ rcu_preempt_check_blocked_tasks (rnp); rnp->qsmask = rnp->qsmaskinit; rnp->gpnum = rsp->gpnum; rnp->completed = rsp->completed;if (rnp == rdp->mynode)rcu_start_gp_per_cpu (rsp, rnp, rdp); -spin_unlock (&rnp->lock);/* irqs remain disabled. */ +raw_spin_unlock (&rnp->lock);/* irqs remain disabled. */ } rnp =rcu_get_root (rsp); -spin_lock (&rnp->lock);/* irqs already disabled. */ +raw_spin_lock (&rnp->lock);/* irqs already disabled. */ rsp->signaled =RCU_SIGNAL_INIT ;/* force_quiescent_state now OK. */ -spin_unlock (&rnp->lock);/* irqs remain disabled. */ -spin_unlock_irqrestore (&rsp->onofflock, flags); +raw_spin_unlock (&rnp->lock);/* irqs remain disabled. */ +raw_spin_unlock_irqrestore (&rsp->onofflock, flags); }/*
@@ -796,14 +796,14 @@ rcu_report_qs_rnp(unsigned long mask, struct rcu_state *rsp,if (!(rnp->qsmask & mask)) {/* Our bit has already been cleared, so done. */ -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);return ; } rnp->qsmask &= ~mask;if (rnp->qsmask !=0 ||rcu_preempted_readers (rnp)) {/* Other bits still set at this level, so done. */ -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);return ; } mask = rnp->grpmask;
@@ -813,10 +813,10 @@ rcu_report_qs_rnp(unsigned long mask, struct rcu_state *rsp,break ; } -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags); rnp_c = rnp; rnp = rnp->parent; -spin_lock_irqsave (&rnp->lock, flags); +raw_spin_lock_irqsave (&rnp->lock, flags);WARN_ON_ONCE (rnp_c->qsmask); }
@@ -845,7 +845,7 @@ rcu_report_qs_rdp(int cpu, struct rcu_state *rsp, struct rcu_data *rdp, long lasstruct rcu_node *rnp; rnp = rdp->mynode; -spin_lock_irqsave (&rnp->lock, flags); +raw_spin_lock_irqsave (&rnp->lock, flags);if (lastcomp != rnp->completed) {/*
@@ -857,12 +857,12 @@ rcu_report_qs_rdp(int cpu, struct rcu_state *rsp, struct rcu_data *rdp, long las* race occurred. */ rdp->passed_quiesc =0 ;/* try again later! */ -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);return ; } mask = rdp->grpmask;if ((rnp->qsmask & mask) ==0 ) { -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags); }else { rdp->qs_pending =0 ;
@@ -926,7 +926,7 @@ static void rcu_send_cbs_to_orphanage(struct rcu_state *rsp)if (rdp->nxtlist ==NULL )return ;/* irqs disabled, so comparison is stable. */ -spin_lock (&rsp->onofflock);/* irqs already disabled. */ +raw_spin_lock (&rsp->onofflock);/* irqs already disabled. */ *rsp->orphan_cbs_tail = rdp->nxtlist; rsp->orphan_cbs_tail = rdp->nxttail[RCU_NEXT_TAIL ]; rdp->nxtlist =NULL ;
@@ -934,7 +934,7 @@ static void rcu_send_cbs_to_orphanage(struct rcu_state *rsp) rdp->nxttail[i] = &rdp->nxtlist; rsp->orphan_qlen += rdp->qlen; rdp->qlen =0 ; -spin_unlock (&rsp->onofflock);/* irqs remain disabled. */ +raw_spin_unlock (&rsp->onofflock);/* irqs remain disabled. */ }/*
@@ -945,10 +945,10 @@ static void rcu_adopt_orphan_cbs(struct rcu_state *rsp)unsigned long flags;struct rcu_data *rdp; -spin_lock_irqsave (&rsp->onofflock, flags); +raw_spin_lock_irqsave (&rsp->onofflock, flags); rdp = rsp->rda[smp_processor_id ()];if (rsp->orphan_cbs_list ==NULL ) { -spin_unlock_irqrestore (&rsp->onofflock, flags); +raw_spin_unlock_irqrestore (&rsp->onofflock, flags);return ; } *rdp->nxttail[RCU_NEXT_TAIL ] = rsp->orphan_cbs_list;
@@ -957,7 +957,7 @@ static void rcu_adopt_orphan_cbs(struct rcu_state *rsp) rsp->orphan_cbs_list =NULL ; rsp->orphan_cbs_tail = &rsp->orphan_cbs_list; rsp->orphan_qlen =0 ; -spin_unlock_irqrestore (&rsp->onofflock, flags); +raw_spin_unlock_irqrestore (&rsp->onofflock, flags); }/*
@@ -973,23 +973,23 @@ static void __rcu_offline_cpu(int cpu, struct rcu_state *rsp)struct rcu_node *rnp;/* Exclude any attempts to start a new grace period. */ -spin_lock_irqsave (&rsp->onofflock, flags); +raw_spin_lock_irqsave (&rsp->onofflock, flags);/* Remove the outgoing CPU from the masks in the rcu_node hierarchy. */ rnp = rdp->mynode;/* this is the outgoing CPU's rnp. */ mask = rdp->grpmask;/* rnp->grplo is constant. */ do { -spin_lock (&rnp->lock);/* irqs already disabled. */ +raw_spin_lock (&rnp->lock);/* irqs already disabled. */ rnp->qsmaskinit &= ~mask;if (rnp->qsmaskinit !=0 ) {if (rnp != rdp->mynode) -spin_unlock (&rnp->lock);/* irqs remain disabled. */ +raw_spin_unlock (&rnp->lock);/* irqs remain disabled. */ break ; }if (rnp == rdp->mynode) need_report =rcu_preempt_offline_tasks (rsp, rnp, rdp);else -spin_unlock (&rnp->lock);/* irqs remain disabled. */ +raw_spin_unlock (&rnp->lock);/* irqs remain disabled. */ mask = rnp->grpmask; rnp = rnp->parent; }while (rnp !=NULL );
@@ -1000,12 +1000,12 @@ static void __rcu_offline_cpu(int cpu, struct rcu_state *rsp)* because invoking rcu_report_unblock_qs_rnp() with ->onofflock * held leads to deadlock. */ -spin_unlock (&rsp->onofflock);/* irqs remain disabled. */ +raw_spin_unlock (&rsp->onofflock);/* irqs remain disabled. */ rnp = rdp->mynode;if (need_report &RCU_OFL_TASKS_NORM_GP )rcu_report_unblock_qs_rnp (rnp, flags);else -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);if (need_report &RCU_OFL_TASKS_EXP_GP )rcu_report_exp_rnp (rsp, rnp);
@@ -1176,13 +1176,13 @@ static void force_qs_rnp(struct rcu_state *rsp, int (*f)(struct rcu_data *))rcu_for_each_leaf_node (rsp, rnp) { mask =0 ; -spin_lock_irqsave (&rnp->lock, flags); +raw_spin_lock_irqsave (&rnp->lock, flags);if (!rcu_gp_in_progress (rsp)) { -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);return ; }if (rnp->qsmask ==0 ) { -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);continue ; } cpu = rnp->grplo;
@@ -1197,7 +1197,7 @@ static void force_qs_rnp(struct rcu_state *rsp, int (*f)(struct rcu_data *))rcu_report_qs_rnp (mask, rsp, rnp, flags);continue ; } -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags); } }
@@ -1212,18 +1212,18 @@ static void force_quiescent_state(struct rcu_state *rsp, int relaxed)if (!rcu_gp_in_progress (rsp))return ;/* No grace period in progress, nothing to force. */ -if (!spin_trylock_irqsave (&rsp->fqslock, flags)) { +if (!raw_spin_trylock_irqsave (&rsp->fqslock, flags)) { rsp->n_force_qs_lh++;/* Inexact, can lose counts. Tough! */ return ;/* Someone else is already on the job. */ }if (relaxed &&ULONG_CMP_GE (rsp->jiffies_force_qs, jiffies)) goto unlock_fqs_ret;/* no emergency and done recently. */ rsp->n_force_qs++; -spin_lock (&rnp->lock);/* irqs already disabled */ +raw_spin_lock (&rnp->lock);/* irqs already disabled */ rsp->jiffies_force_qs = jiffies +RCU_JIFFIES_TILL_FORCE_QS ;if (!rcu_gp_in_progress (rsp)) { rsp->n_force_qs_ngp++; -spin_unlock (&rnp->lock);/* irqs remain disabled */ +raw_spin_unlock (&rnp->lock);/* irqs remain disabled */ goto unlock_fqs_ret;/* no GP in progress, time updated. */ } rsp->fqs_active =1 ;
@@ -1235,13 +1235,13 @@ static void force_quiescent_state(struct rcu_state *rsp, int relaxed)case RCU_SAVE_DYNTICK : -spin_unlock (&rnp->lock);/* irqs remain disabled */ +raw_spin_unlock (&rnp->lock);/* irqs remain disabled */ if (RCU_SIGNAL_INIT !=RCU_SAVE_DYNTICK )break ;/* So gcc recognizes the dead code. */ /* Record dyntick-idle state. */ force_qs_rnp (rsp, dyntick_save_progress_counter); -spin_lock (&rnp->lock);/* irqs already disabled */ +raw_spin_lock (&rnp->lock);/* irqs already disabled */ if (rcu_gp_in_progress (rsp)) rsp->signaled =RCU_FORCE_QS ;break ;
@@ -1249,24 +1249,24 @@ static void force_quiescent_state(struct rcu_state *rsp, int relaxed)case RCU_FORCE_QS :/* Check dyntick-idle state, send IPI to laggarts. */ -spin_unlock (&rnp->lock);/* irqs remain disabled */ +raw_spin_unlock (&rnp->lock);/* irqs remain disabled */ force_qs_rnp (rsp, rcu_implicit_dynticks_qs);/* Leave state in case more forcing is required. */ -spin_lock (&rnp->lock);/* irqs already disabled */ +raw_spin_lock (&rnp->lock);/* irqs already disabled */ break; } rsp->fqs_active =0 ;if (rsp->fqs_need_gp) { -spin_unlock (&rsp->fqslock);/* irqs remain disabled */ +raw_spin_unlock (&rsp->fqslock);/* irqs remain disabled */ rsp->fqs_need_gp =0 ;rcu_start_gp (rsp, flags);/* releases rnp->lock */ return ; } -spin_unlock (&rnp->lock);/* irqs remain disabled */ +raw_spin_unlock (&rnp->lock);/* irqs remain disabled */ unlock_fqs_ret: -spin_unlock_irqrestore (&rsp->fqslock, flags); +raw_spin_unlock_irqrestore (&rsp->fqslock, flags); }#else /* #ifdef CONFIG_SMP */
@@ -1308,7 +1308,7 @@ __rcu_process_callbacks(struct rcu_state *rsp, struct rcu_data *rdp)/* Does this CPU require a not-yet-started grace period? */ if (cpu_needs_another_gp (rsp, rdp)) { -spin_lock_irqsave (&rcu_get_root (rsp)->lock, flags); +raw_spin_lock_irqsave (&rcu_get_root (rsp)->lock, flags);rcu_start_gp (rsp, flags);/* releases above lock */ }
@@ -1373,7 +1373,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),unsigned long nestflag;struct rcu_node *rnp_root =rcu_get_root (rsp); -spin_lock_irqsave (&rnp_root->lock, nestflag); +raw_spin_lock_irqsave (&rnp_root->lock, nestflag);rcu_start_gp (rsp, nestflag);/* releases rnp_root->lock. */ }
@@ -1662,7 +1662,7 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)struct rcu_node *rnp =rcu_get_root (rsp);/* Set up local state, ensuring consistent view of global state. */ -spin_lock_irqsave (&rnp->lock, flags); +raw_spin_lock_irqsave (&rnp->lock, flags); rdp->grpmask =1UL << (cpu - rdp->mynode->grplo); rdp->nxtlist =NULL ;for (i =0 ; i <RCU_NEXT_SIZE ; i++)
@@ -1672,7 +1672,7 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp) rdp->dynticks = &per_cpu (rcu_dynticks, cpu);#endif /* #ifdef CONFIG_NO_HZ */ rdp->cpu = cpu; -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags); }/*
@@ -1690,7 +1690,7 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptable)struct rcu_node *rnp =rcu_get_root (rsp);/* Set up local state, ensuring consistent view of global state. */ -spin_lock_irqsave (&rnp->lock, flags); +raw_spin_lock_irqsave (&rnp->lock, flags); rdp->passed_quiesc =0 ;/* We could be racing with new GP, */ rdp->qs_pending =1 ;/* so set up to respond to current GP. */ rdp->beenonline =1 ;/* We have now been online. */
@@ -1698,7 +1698,7 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptable) rdp->qlen_last_fqs_check =0 ; rdp->n_force_qs_snap = rsp->n_force_qs; rdp->blimit = blimit; -spin_unlock (&rnp->lock);/* irqs remain disabled. */ +raw_spin_unlock (&rnp->lock);/* irqs remain disabled. */ /* * A new grace period might start here. If so, we won't be part
@@ -1706,14 +1706,14 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptable)*/ /* Exclude any attempts to start a new GP on large systems. */ -spin_lock (&rsp->onofflock);/* irqs already disabled. */ +raw_spin_lock (&rsp->onofflock);/* irqs already disabled. */ /* Add CPU to rcu_node bitmasks. */ rnp = rdp->mynode; mask = rdp->grpmask; do { /* Exclude any attempts to start a new GP on small systems. */ - spin_lock(&rnp->lock); /* irqs already disabled. */ + raw_spin_lock(&rnp->lock); /* irqs already disabled. */ rnp->qsmaskinit |= mask; mask = rnp->grpmask; if (rnp == rdp->mynode) {
@@ -1721,11 +1721,11 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptable) rdp->completed = rnp->completed; rdp->passed_quiesc_completed = rnp->completed -1 ; } -spin_unlock (&rnp->lock);/* irqs already disabled. */ +raw_spin_unlock (&rnp->lock);/* irqs already disabled. */ rnp = rnp->parent; }while (rnp !=NULL && !(rnp->qsmaskinit & mask)); -spin_unlock_irqrestore (&rsp->onofflock, flags); +raw_spin_unlock_irqrestore (&rsp->onofflock, flags); }static void __cpuinit rcu_online_cpu (int cpu)
@@ -1832,7 +1832,7 @@ static void __init rcu_init_one(struct rcu_state *rsp) cpustride *= rsp->levelspread[i]; rnp = rsp->level[i];for (j =0 ; j < rsp->levelcnt[i]; j++, rnp++) { -spin_lock_init (&rnp->lock); +raw_spin_lock_init (&rnp->lock);lockdep_set_class_and_name (&rnp->lock, &rcu_node_class[i], buf[i]); rnp->gpnum =0 ;
kernel/rcutree.h +3 -3
@@ -90,7 +90,7 @@ struct rcu_dynticks {* Definition for node within the RCU grace-period-detection hierarchy. */ struct rcu_node { -spinlock_t lock;/* Root rcu_node's lock protects some */ +raw_spinlock_t lock;/* Root rcu_node's lock protects some */ /* rcu_state fields as well as following. */ unsigned long gpnum;/* Current grace period for this node. */ /* This will either be equal to or one */
@@ -291,7 +291,7 @@ struct rcu_state {/* End of fields guarded by root rcu_node's lock. */ -spinlock_t onofflock;/* exclude on/offline and */ +raw_spinlock_t onofflock;/* exclude on/offline and */ /* starting new GP. Also */ /* protects the following */ /* orphan_cbs fields. */
@@ -301,7 +301,7 @@ struct rcu_state {/* going offline. */ struct rcu_head **orphan_cbs_tail;/* And tail pointer. */ long orphan_qlen;/* Number of orphaned cbs. */ -spinlock_t fqslock;/* Only one task forcing */ +raw_spinlock_t fqslock;/* Only one task forcing */ /* quiescent states. */ unsigned long jiffies_force_qs;/* Time at which to invoke */ /* force_quiescent_state(). */
kernel/rcutree_plugin.h +23 -23
149 lines not on this page · raw message
Signature · 1 line
1.6.6
PATCH 18/18 rcu: Convert to raw_spinlocks
The spinlocks in rcutree need to be real spinlocks in preempt-rt. Convert them to raw_spinlocks.
--- kernel/rcutree.c | 132 +++++++++++++++++++++++----------------------- kernel/rcutree.h | 6 +- kernel/rcutree_plugin.h | 46 ++++++++-------- 3 files changed, 92 insertions(+), 92 deletions(-)
kernel/rcutree.c +66 -66
@@ -66,11 +66,11 @@ static struct lock_class_key rcu_node_class[NUM_RCU_LVLS]; .signaled = RCU_GP_IDLE, \ .gpnum = -300, \ .completed = -300, \ - .onofflock = __SPIN_LOCK_UNLOCKED(&name.onofflock), \ + .onofflock = __RAW_SPIN_LOCK_UNLOCKED(&name.onofflock), \ .orphan_cbs_list = NULL, \ .orphan_cbs_tail = &name.orphan_cbs_list, \ .orphan_qlen = 0, \ - .fqslock = __SPIN_LOCK_UNLOCKED(&name.fqslock), \ + .fqslock = __RAW_SPIN_LOCK_UNLOCKED(&name.fqslock), \ .n_force_qs = 0, \ .n_force_qs_ngp = 0, \ }
@@ -457,10 +457,10 @@ static void print_other_cpu_stall(struct rcu_state *rsp)/* Only let one CPU complain about others per time interval. */ -spin_lock_irqsave (&rnp->lock, flags); +raw_spin_lock_irqsave (&rnp->lock, flags); delta = jiffies - rsp->jiffies_stall;if (delta <RCU_STALL_RAT_DELAY || !rcu_gp_in_progress (rsp)) { -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);return ; } rsp->jiffies_stall = jiffies +RCU_SECONDS_TILL_STALL_RECHECK ;
@@ -470,7 +470,7 @@ static void print_other_cpu_stall(struct rcu_state *rsp)* due to CPU offlining. */ rcu_print_task_stall (rnp); -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);/* OK, time to rat on our buddy... */
@@ -499,11 +499,11 @@ static void print_cpu_stall(struct rcu_state *rsp) smp_processor_id(), jiffies - rsp->gp_start);trigger_all_cpu_backtrace (); -spin_lock_irqsave (&rnp->lock, flags); +raw_spin_lock_irqsave (&rnp->lock, flags);if (ULONG_CMP_GE (jiffies, rsp->jiffies_stall)) rsp->jiffies_stall = jiffies +RCU_SECONDS_TILL_STALL_RECHECK ; -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);set_need_resched ();/* kick ourselves to get things going. */ }
@@ -563,12 +563,12 @@ static void note_new_gpnum(struct rcu_state *rsp, struct rcu_data *rdp)local_irq_save (flags); rnp = rdp->mynode;if (rdp->gpnum ==ACCESS_ONCE (rnp->gpnum) ||/* outside lock. */ - !spin_trylock (&rnp->lock)) {/* irqs already off, retry later. */ + !raw_spin_trylock (&rnp->lock)) {/* irqs already off, so later. */ local_irq_restore (flags);return ; }__note_new_gpnum (rsp, rnp, rdp); -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags); }/*
@@ -627,12 +627,12 @@ rcu_process_gp_end(struct rcu_state *rsp, struct rcu_data *rdp)local_irq_save (flags); rnp = rdp->mynode;if (rdp->completed ==ACCESS_ONCE (rnp->completed) ||/* outside lock. */ - !spin_trylock (&rnp->lock)) {/* irqs already off, retry later. */ + !raw_spin_trylock (&rnp->lock)) {/* irqs already off, so later. */ local_irq_restore (flags);return ; }__rcu_process_gp_end (rsp, rnp, rdp); -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags); }/*
@@ -681,10 +681,10 @@ rcu_start_gp(struct rcu_state *rsp, unsigned long flags)if (cpu_needs_another_gp (rsp, rdp)) rsp->fqs_need_gp =1 ;if (rnp->completed == rsp->completed) { -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);return ; } -spin_unlock (&rnp->lock);/* irqs remain disabled. */ +raw_spin_unlock (&rnp->lock);/* irqs remain disabled. */ /* * Propagate new ->completed value to rcu_node structures
@@ -692,9 +692,9 @@ rcu_start_gp(struct rcu_state *rsp, unsigned long flags)* of the next grace period to process their callbacks. */ rcu_for_each_node_breadth_first (rsp, rnp) { -spin_lock (&rnp->lock);/* irqs already disabled. */ +raw_spin_lock (&rnp->lock);/* irqs already disabled. */ rnp->completed = rsp->completed; -spin_unlock (&rnp->lock);/* irqs remain disabled. */ +raw_spin_unlock (&rnp->lock);/* irqs remain disabled. */ }local_irq_restore (flags);return ;
@@ -715,15 +715,15 @@ rcu_start_gp(struct rcu_state *rsp, unsigned long flags) rnp->completed = rsp->completed; rsp->signaled =RCU_SIGNAL_INIT ;/* force_quiescent_state OK. */ rcu_start_gp_per_cpu (rsp, rnp, rdp); -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);return ; } -spin_unlock (&rnp->lock);/* leave irqs disabled. */ +raw_spin_unlock (&rnp->lock);/* leave irqs disabled. */ /* Exclude any concurrent CPU-hotplug operations. */ -spin_lock (&rsp->onofflock);/* irqs already disabled. */ +raw_spin_lock (&rsp->onofflock);/* irqs already disabled. */ /* * Set the quiescent-state-needed bits in all the rcu_node
@@ -743,21 +743,21 @@ rcu_start_gp(struct rcu_state *rsp, unsigned long flags)* irqs disabled. */ rcu_for_each_node_breadth_first (rsp, rnp) { -spin_lock (&rnp->lock);/* irqs already disabled. */ +raw_spin_lock (&rnp->lock);/* irqs already disabled. */ rcu_preempt_check_blocked_tasks (rnp); rnp->qsmask = rnp->qsmaskinit; rnp->gpnum = rsp->gpnum; rnp->completed = rsp->completed;if (rnp == rdp->mynode)rcu_start_gp_per_cpu (rsp, rnp, rdp); -spin_unlock (&rnp->lock);/* irqs remain disabled. */ +raw_spin_unlock (&rnp->lock);/* irqs remain disabled. */ } rnp =rcu_get_root (rsp); -spin_lock (&rnp->lock);/* irqs already disabled. */ +raw_spin_lock (&rnp->lock);/* irqs already disabled. */ rsp->signaled =RCU_SIGNAL_INIT ;/* force_quiescent_state now OK. */ -spin_unlock (&rnp->lock);/* irqs remain disabled. */ -spin_unlock_irqrestore (&rsp->onofflock, flags); +raw_spin_unlock (&rnp->lock);/* irqs remain disabled. */ +raw_spin_unlock_irqrestore (&rsp->onofflock, flags); }/*
@@ -796,14 +796,14 @@ rcu_report_qs_rnp(unsigned long mask, struct rcu_state *rsp,if (!(rnp->qsmask & mask)) {/* Our bit has already been cleared, so done. */ -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);return ; } rnp->qsmask &= ~mask;if (rnp->qsmask !=0 ||rcu_preempted_readers (rnp)) {/* Other bits still set at this level, so done. */ -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);return ; } mask = rnp->grpmask;
@@ -813,10 +813,10 @@ rcu_report_qs_rnp(unsigned long mask, struct rcu_state *rsp,break ; } -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags); rnp_c = rnp; rnp = rnp->parent; -spin_lock_irqsave (&rnp->lock, flags); +raw_spin_lock_irqsave (&rnp->lock, flags);WARN_ON_ONCE (rnp_c->qsmask); }
@@ -845,7 +845,7 @@ rcu_report_qs_rdp(int cpu, struct rcu_state *rsp, struct rcu_data *rdp, long lasstruct rcu_node *rnp; rnp = rdp->mynode; -spin_lock_irqsave (&rnp->lock, flags); +raw_spin_lock_irqsave (&rnp->lock, flags);if (lastcomp != rnp->completed) {/*
@@ -857,12 +857,12 @@ rcu_report_qs_rdp(int cpu, struct rcu_state *rsp, struct rcu_data *rdp, long las* race occurred. */ rdp->passed_quiesc =0 ;/* try again later! */ -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);return ; } mask = rdp->grpmask;if ((rnp->qsmask & mask) ==0 ) { -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags); }else { rdp->qs_pending =0 ;
@@ -926,7 +926,7 @@ static void rcu_send_cbs_to_orphanage(struct rcu_state *rsp)if (rdp->nxtlist ==NULL )return ;/* irqs disabled, so comparison is stable. */ -spin_lock (&rsp->onofflock);/* irqs already disabled. */ +raw_spin_lock (&rsp->onofflock);/* irqs already disabled. */ *rsp->orphan_cbs_tail = rdp->nxtlist; rsp->orphan_cbs_tail = rdp->nxttail[RCU_NEXT_TAIL ]; rdp->nxtlist =NULL ;
@@ -934,7 +934,7 @@ static void rcu_send_cbs_to_orphanage(struct rcu_state *rsp) rdp->nxttail[i] = &rdp->nxtlist; rsp->orphan_qlen += rdp->qlen; rdp->qlen =0 ; -spin_unlock (&rsp->onofflock);/* irqs remain disabled. */ +raw_spin_unlock (&rsp->onofflock);/* irqs remain disabled. */ }/*
@@ -945,10 +945,10 @@ static void rcu_adopt_orphan_cbs(struct rcu_state *rsp)unsigned long flags;struct rcu_data *rdp; -spin_lock_irqsave (&rsp->onofflock, flags); +raw_spin_lock_irqsave (&rsp->onofflock, flags); rdp = rsp->rda[smp_processor_id ()];if (rsp->orphan_cbs_list ==NULL ) { -spin_unlock_irqrestore (&rsp->onofflock, flags); +raw_spin_unlock_irqrestore (&rsp->onofflock, flags);return ; } *rdp->nxttail[RCU_NEXT_TAIL ] = rsp->orphan_cbs_list;
@@ -957,7 +957,7 @@ static void rcu_adopt_orphan_cbs(struct rcu_state *rsp) rsp->orphan_cbs_list =NULL ; rsp->orphan_cbs_tail = &rsp->orphan_cbs_list; rsp->orphan_qlen =0 ; -spin_unlock_irqrestore (&rsp->onofflock, flags); +raw_spin_unlock_irqrestore (&rsp->onofflock, flags); }/*
@@ -973,23 +973,23 @@ static void __rcu_offline_cpu(int cpu, struct rcu_state *rsp)struct rcu_node *rnp;/* Exclude any attempts to start a new grace period. */ -spin_lock_irqsave (&rsp->onofflock, flags); +raw_spin_lock_irqsave (&rsp->onofflock, flags);/* Remove the outgoing CPU from the masks in the rcu_node hierarchy. */ rnp = rdp->mynode;/* this is the outgoing CPU's rnp. */ mask = rdp->grpmask;/* rnp->grplo is constant. */ do { -spin_lock (&rnp->lock);/* irqs already disabled. */ +raw_spin_lock (&rnp->lock);/* irqs already disabled. */ rnp->qsmaskinit &= ~mask;if (rnp->qsmaskinit !=0 ) {if (rnp != rdp->mynode) -spin_unlock (&rnp->lock);/* irqs remain disabled. */ +raw_spin_unlock (&rnp->lock);/* irqs remain disabled. */ break ; }if (rnp == rdp->mynode) need_report =rcu_preempt_offline_tasks (rsp, rnp, rdp);else -spin_unlock (&rnp->lock);/* irqs remain disabled. */ +raw_spin_unlock (&rnp->lock);/* irqs remain disabled. */ mask = rnp->grpmask; rnp = rnp->parent; }while (rnp !=NULL );
@@ -1000,12 +1000,12 @@ static void __rcu_offline_cpu(int cpu, struct rcu_state *rsp)* because invoking rcu_report_unblock_qs_rnp() with ->onofflock * held leads to deadlock. */ -spin_unlock (&rsp->onofflock);/* irqs remain disabled. */ +raw_spin_unlock (&rsp->onofflock);/* irqs remain disabled. */ rnp = rdp->mynode;if (need_report &RCU_OFL_TASKS_NORM_GP )rcu_report_unblock_qs_rnp (rnp, flags);else -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);if (need_report &RCU_OFL_TASKS_EXP_GP )rcu_report_exp_rnp (rsp, rnp);
@@ -1176,13 +1176,13 @@ static void force_qs_rnp(struct rcu_state *rsp, int (*f)(struct rcu_data *))rcu_for_each_leaf_node (rsp, rnp) { mask =0 ; -spin_lock_irqsave (&rnp->lock, flags); +raw_spin_lock_irqsave (&rnp->lock, flags);if (!rcu_gp_in_progress (rsp)) { -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);return ; }if (rnp->qsmask ==0 ) { -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags);continue ; } cpu = rnp->grplo;
@@ -1197,7 +1197,7 @@ static void force_qs_rnp(struct rcu_state *rsp, int (*f)(struct rcu_data *))rcu_report_qs_rnp (mask, rsp, rnp, flags);continue ; } -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags); } }
@@ -1212,18 +1212,18 @@ static void force_quiescent_state(struct rcu_state *rsp, int relaxed)if (!rcu_gp_in_progress (rsp))return ;/* No grace period in progress, nothing to force. */ -if (!spin_trylock_irqsave (&rsp->fqslock, flags)) { +if (!raw_spin_trylock_irqsave (&rsp->fqslock, flags)) { rsp->n_force_qs_lh++;/* Inexact, can lose counts. Tough! */ return ;/* Someone else is already on the job. */ }if (relaxed &&ULONG_CMP_GE (rsp->jiffies_force_qs, jiffies)) goto unlock_fqs_ret;/* no emergency and done recently. */ rsp->n_force_qs++; -spin_lock (&rnp->lock);/* irqs already disabled */ +raw_spin_lock (&rnp->lock);/* irqs already disabled */ rsp->jiffies_force_qs = jiffies +RCU_JIFFIES_TILL_FORCE_QS ;if (!rcu_gp_in_progress (rsp)) { rsp->n_force_qs_ngp++; -spin_unlock (&rnp->lock);/* irqs remain disabled */ +raw_spin_unlock (&rnp->lock);/* irqs remain disabled */ goto unlock_fqs_ret;/* no GP in progress, time updated. */ } rsp->fqs_active =1 ;
@@ -1235,13 +1235,13 @@ static void force_quiescent_state(struct rcu_state *rsp, int relaxed)case RCU_SAVE_DYNTICK : -spin_unlock (&rnp->lock);/* irqs remain disabled */ +raw_spin_unlock (&rnp->lock);/* irqs remain disabled */ if (RCU_SIGNAL_INIT !=RCU_SAVE_DYNTICK )break ;/* So gcc recognizes the dead code. */ /* Record dyntick-idle state. */ force_qs_rnp (rsp, dyntick_save_progress_counter); -spin_lock (&rnp->lock);/* irqs already disabled */ +raw_spin_lock (&rnp->lock);/* irqs already disabled */ if (rcu_gp_in_progress (rsp)) rsp->signaled =RCU_FORCE_QS ;break ;
@@ -1249,24 +1249,24 @@ static void force_quiescent_state(struct rcu_state *rsp, int relaxed)case RCU_FORCE_QS :/* Check dyntick-idle state, send IPI to laggarts. */ -spin_unlock (&rnp->lock);/* irqs remain disabled */ +raw_spin_unlock (&rnp->lock);/* irqs remain disabled */ force_qs_rnp (rsp, rcu_implicit_dynticks_qs);/* Leave state in case more forcing is required. */ -spin_lock (&rnp->lock);/* irqs already disabled */ +raw_spin_lock (&rnp->lock);/* irqs already disabled */ break; } rsp->fqs_active =0 ;if (rsp->fqs_need_gp) { -spin_unlock (&rsp->fqslock);/* irqs remain disabled */ +raw_spin_unlock (&rsp->fqslock);/* irqs remain disabled */ rsp->fqs_need_gp =0 ;rcu_start_gp (rsp, flags);/* releases rnp->lock */ return ; } -spin_unlock (&rnp->lock);/* irqs remain disabled */ +raw_spin_unlock (&rnp->lock);/* irqs remain disabled */ unlock_fqs_ret: -spin_unlock_irqrestore (&rsp->fqslock, flags); +raw_spin_unlock_irqrestore (&rsp->fqslock, flags); }#else /* #ifdef CONFIG_SMP */
@@ -1308,7 +1308,7 @@ __rcu_process_callbacks(struct rcu_state *rsp, struct rcu_data *rdp)/* Does this CPU require a not-yet-started grace period? */ if (cpu_needs_another_gp (rsp, rdp)) { -spin_lock_irqsave (&rcu_get_root (rsp)->lock, flags); +raw_spin_lock_irqsave (&rcu_get_root (rsp)->lock, flags);rcu_start_gp (rsp, flags);/* releases above lock */ }
@@ -1373,7 +1373,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),unsigned long nestflag;struct rcu_node *rnp_root =rcu_get_root (rsp); -spin_lock_irqsave (&rnp_root->lock, nestflag); +raw_spin_lock_irqsave (&rnp_root->lock, nestflag);rcu_start_gp (rsp, nestflag);/* releases rnp_root->lock. */ }
@@ -1662,7 +1662,7 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)struct rcu_node *rnp =rcu_get_root (rsp);/* Set up local state, ensuring consistent view of global state. */ -spin_lock_irqsave (&rnp->lock, flags); +raw_spin_lock_irqsave (&rnp->lock, flags); rdp->grpmask =1UL << (cpu - rdp->mynode->grplo); rdp->nxtlist =NULL ;for (i =0 ; i <RCU_NEXT_SIZE ; i++)
@@ -1672,7 +1672,7 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp) rdp->dynticks = &per_cpu (rcu_dynticks, cpu);#endif /* #ifdef CONFIG_NO_HZ */ rdp->cpu = cpu; -spin_unlock_irqrestore (&rnp->lock, flags); +raw_spin_unlock_irqrestore (&rnp->lock, flags); }/*
@@ -1690,7 +1690,7 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptable)struct rcu_node *rnp =rcu_get_root (rsp);/* Set up local state, ensuring consistent view of global state. */ -spin_lock_irqsave (&rnp->lock, flags); +raw_spin_lock_irqsave (&rnp->lock, flags); rdp->passed_quiesc =0 ;/* We could be racing with new GP, */ rdp->qs_pending =1 ;/* so set up to respond to current GP. */ rdp->beenonline =1 ;/* We have now been online. */
@@ -1698,7 +1698,7 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptable) rdp->qlen_last_fqs_check =0 ; rdp->n_force_qs_snap = rsp->n_force_qs; rdp->blimit = blimit; -spin_unlock (&rnp->lock);/* irqs remain disabled. */ +raw_spin_unlock (&rnp->lock);/* irqs remain disabled. */ /* * A new grace period might start here. If so, we won't be part
@@ -1706,14 +1706,14 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptable)*/ /* Exclude any attempts to start a new GP on large systems. */ -spin_lock (&rsp->onofflock);/* irqs already disabled. */ +raw_spin_lock (&rsp->onofflock);/* irqs already disabled. */ /* Add CPU to rcu_node bitmasks. */ rnp = rdp->mynode; mask = rdp->grpmask; do { /* Exclude any attempts to start a new GP on small systems. */ - spin_lock(&rnp->lock); /* irqs already disabled. */ + raw_spin_lock(&rnp->lock); /* irqs already disabled. */ rnp->qsmaskinit |= mask; mask = rnp->grpmask; if (rnp == rdp->mynode) {
@@ -1721,11 +1721,11 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptable) rdp->completed = rnp->completed; rdp->passed_quiesc_completed = rnp->completed -1 ; } -spin_unlock (&rnp->lock);/* irqs already disabled. */ +raw_spin_unlock (&rnp->lock);/* irqs already disabled. */ rnp = rnp->parent; }while (rnp !=NULL && !(rnp->qsmaskinit & mask)); -spin_unlock_irqrestore (&rsp->onofflock, flags); +raw_spin_unlock_irqrestore (&rsp->onofflock, flags); }static void __cpuinit rcu_online_cpu (int cpu)
@@ -1832,7 +1832,7 @@ static void __init rcu_init_one(struct rcu_state *rsp) cpustride *= rsp->levelspread[i]; rnp = rsp->level[i];for (j =0 ; j < rsp->levelcnt[i]; j++, rnp++) { -spin_lock_init (&rnp->lock); +raw_spin_lock_init (&rnp->lock);lockdep_set_class_and_name (&rnp->lock, &rcu_node_class[i], buf[i]); rnp->gpnum =0 ;
kernel/rcutree.h +3 -3
@@ -90,7 +90,7 @@ struct rcu_dynticks {* Definition for node within the RCU grace-period-detection hierarchy. */ struct rcu_node { -spinlock_t lock;/* Root rcu_node's lock protects some */ +raw_spinlock_t lock;/* Root rcu_node's lock protects some */ /* rcu_state fields as well as following. */ unsigned long gpnum;/* Current grace period for this node. */ /* This will either be equal to or one */
@@ -291,7 +291,7 @@ struct rcu_state {/* End of fields guarded by root rcu_node's lock. */ -spinlock_t onofflock;/* exclude on/offline and */ +raw_spinlock_t onofflock;/* exclude on/offline and */ /* starting new GP. Also */ /* protects the following */ /* orphan_cbs fields. */
@@ -301,7 +301,7 @@ struct rcu_state {/* going offline. */ struct rcu_head **orphan_cbs_tail;/* And tail pointer. */ long orphan_qlen;/* Number of orphaned cbs. */ -spinlock_t fqslock;/* Only one task forcing */ +raw_spinlock_t fqslock;/* Only one task forcing */ /* quiescent states. */ unsigned long jiffies_force_qs;/* Time at which to invoke */ /* force_quiescent_state(). */
kernel/rcutree_plugin.h +23 -23
149 lines not on this page · raw message
Signature · 1 line
1.6.6