rcu: fix !PREEMPT, __mpol_dup(), and ftrace_perf_buf_prepare() RCU lockdep splats
Subsystems (5)
cover rcu: fix !PREEMPT, __mpol_dup(), and ftrace_perf_buf_prepare() RCU lockdep splats
Hello!
This patch fixes three RCU lockdep issues:
1. Makes rcu_read_lock_sched_held() correctly handle !PREEMPT
kernels.
2. Suppresses __mpol_dup() false positive.
3. Converts a pair of rcu_dereference() calls in
ftrace_perf_buf_prepare() to rcu_dereference_sched().
There are probably more where these came from. ;-)
Thanx, Paul
------------------------------------------------------------------------
include/linux/rcupdate.h | 15 ++++++++++++++- include/trace/ftrace.h | 4 ++-- kernel/trace/trace_event_profile.c | 5 ++--- mm/mempolicy.c | 3 ++- 4 files changed, 20 insertions(+), 7 deletions(-)
PATCH 2/3 rcu: suppress __mpol_dup() false positive from RCU lockdep
Common code is used during task creation and after the task has started running. RCU protection is not needed during task creation because no other CPU has access to the under-construction task. Provide the RCU protection anyway to suppress the false positive, as there does not appear to be a good way for the common code to recognize that the task is only accessible to the CPU creating it.
--- mm/mempolicy.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
mm/mempolicy.c +2 -0
@@ -1730,10 +1730,12 @@ struct mempolicy *__mpol_dup(struct mempolicy *old)if (!new)return ERR_PTR (-ENOMEM ); +rcu_read_lock ();if (current_cpuset_is_being_rebound ()) {nodemask_t mems =cpuset_mems_allowed (current);mpol_rebind_policy (old, &mems); } +rcu_read_unlock (); *new = *old;atomic_set (&new->refcnt,1 );return new;
Signature · 1 line
1.6.6
PATCH 3/3 rcu, ftrace: fix RCU lockdep splat in ftrace_perf_buf_prepare()
In reply to Paul E. McKenneyChange the pair of rcu_dereference() calls in ftrace_perf_buf_prepare() to rcu_dereference_sched().
--- include/trace/ftrace.h | 4 ++-- kernel/trace/trace_event_profile.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
include/trace/ftrace.h +2 -2
@@ -699,9 +699,9 @@ __attribute__((section("_ftrace_events"))) event_##call = { \* __cpu = smp_processor_id(); * * if (in_nmi()) -* trace_buf = rcu_dereference(perf_trace_buf_nmi); +* trace_buf = rcu_dereference_sched(perf_trace_buf_nmi); * else -* trace_buf = rcu_dereference(perf_trace_buf); +* trace_buf = rcu_dereference_sched(perf_trace_buf); * * if (!trace_buf) * goto end;
kernel/trace/trace_event_profile.c +2 -2
@@ -138,9 +138,9 @@ __kprobes void *ftrace_perf_buf_prepare(int size, unsigned short type, cpu =smp_processor_id ();if (in_nmi ()) - trace_buf =rcu_dereference (perf_trace_buf_nmi); + trace_buf =rcu_dereference_sched (perf_trace_buf_nmi);else - trace_buf =rcu_dereference (perf_trace_buf); + trace_buf =rcu_dereference_sched (perf_trace_buf);if (!trace_buf) goto err;
Signature · 1 line
1.6.6
PATCH 1/3 rcu: Make rcu_read_lock_sched_held() handle !PREEMPT
In reply to Paul E. McKenneyThe rcu_read_lock_sched_held() needs to unconditionally return the value "1" in a !PREEMPT kernel, because under !PREEMPT, -all- kernel code is implicitly preempt-disabled. This patch makes this happen.
--- include/linux/rcupdate.h | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
include/linux/rcupdate.h +14 -0
@@ -147,6 +147,7 @@ static inline int rcu_read_lock_bh_held(void)* * Check rcu_scheduler_active to prevent false positives during boot. */ +#ifdef CONFIG_PREEMPT static inline int rcu_read_lock_sched_held (void ) {int lockdep_opinion =0 ;
@@ -157,6 +158,12 @@ static inline int rcu_read_lock_sched_held(void) lockdep_opinion =lock_is_held (&rcu_sched_lock_map); return lockdep_opinion || preempt_count() != 0; } +#else /* #ifdef CONFIG_PREEMPT */ +static inline int rcu_read_lock_sched_held (void ) +{ +return 1 ; +} +#endif /* #else #ifdef CONFIG_PREEMPT */ #else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
@@ -181,10 +188,17 @@ static inline int rcu_read_lock_bh_held(void) return 1; } +#ifdef CONFIG_PREEMPT static inline int rcu_read_lock_sched_held (void ) {return !rcu_scheduler_active ||preempt_count () !=0 ; } +#else /* #ifdef CONFIG_PREEMPT */ +static inline int rcu_read_lock_sched_held (void ) +{ +return 1 ; +} +#endif /* #else #ifdef CONFIG_PREEMPT */ #endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */
Signature · 1 line
1.6.6
Re: [PATCH tip/core/rcu 3/3] rcu, ftrace: fix RCU lockdep splat in ftrace_perf_buf_prepare()
In reply to Paul E. McKenneyQuoted 4 lines · Paul E. McKenney
Change the pair of
rcu_dereference()calls inftrace_perf_buf_prepare()torcu_dereference_sched().Cc Steven Rostedt <[email protected]>
[tip:core/urgent] rcu: Make rcu_read_lock_sched_held() handle !PREEMPT
In reply to Paul E. McKenneyCommit-ID: e6033e3b307fcfae08408e0673266db38392bda4 Gitweb: http://git.kernel.org/tip/e6033e3b307fcfae08408e0673266db38392bda4 Author: Paul E. McKenney <[email protected]> AuthorDate: Wed, 3 Mar 2010 17:50:16 -0800 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 4 Mar 2010 12:07:33 +0100
rcu: Make rcu_read_lock_sched_held() handle !PREEMPT
The rcu_read_lock_sched_held() needs to unconditionally return the value "1" in a !PREEMPT kernel, because under !PREEMPT, -all- kernel code is implicitly preempt-disabled. This patch makes this happen.
LKML-Reference: <[email protected]>
--- include/linux/rcupdate.h | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
include/linux/rcupdate.h +14 -0
@@ -136,6 +136,7 @@ static inline int rcu_read_lock_bh_held(void)* can prove otherwise. Note that disabling of preemption (including * disabling irqs) counts as an RCU-sched read-side critical section. */ +#ifdef CONFIG_PREEMPT static inline int rcu_read_lock_sched_held (void ) {int lockdep_opinion =0 ;
@@ -144,6 +145,12 @@ static inline int rcu_read_lock_sched_held(void) lockdep_opinion =lock_is_held (&rcu_sched_lock_map); return lockdep_opinion || preempt_count() != 0 || !rcu_scheduler_active; } +#else /* #ifdef CONFIG_PREEMPT */ +static inline int rcu_read_lock_sched_held (void ) +{ +return 1 ; +} +#endif /* #else #ifdef CONFIG_PREEMPT */ #else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
@@ -164,10 +171,17 @@ static inline int rcu_read_lock_bh_held(void) return 1; } +#ifdef CONFIG_PREEMPT static inline int rcu_read_lock_sched_held (void ) {return preempt_count () !=0 || !rcu_scheduler_active; } +#else /* #ifdef CONFIG_PREEMPT */ +static inline int rcu_read_lock_sched_held (void ) +{ +return 1 ; +} +#endif /* #else #ifdef CONFIG_PREEMPT */ #endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */
[tip:core/urgent] rcu: Suppress __mpol_dup() false positive from RCU lockdep
In reply to Paul E. McKenneyCommit-ID: 99ee4ca746dda71326db7645463b4075ac1d665c Gitweb: http://git.kernel.org/tip/99ee4ca746dda71326db7645463b4075ac1d665c Author: Paul E. McKenney <[email protected]> AuthorDate: Wed, 3 Mar 2010 17:50:17 -0800 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 4 Mar 2010 12:07:34 +0100
rcu: Suppress __mpol_dup() false positive from RCU lockdep
Common code is used during task creation and after the task has started running. RCU protection is not needed during task creation because no other CPU has access to the under-construction task. Provide the RCU protection anyway to suppress the false positive, as there does not appear to be a good way for the common code to recognize that the task is only accessible to the CPU creating it.
LKML-Reference: <[email protected]>
--- mm/mempolicy.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
mm/mempolicy.c +2 -0
@@ -1730,10 +1730,12 @@ struct mempolicy *__mpol_dup(struct mempolicy *old)if (!new)return ERR_PTR (-ENOMEM ); +rcu_read_lock ();if (current_cpuset_is_being_rebound ()) {nodemask_t mems =cpuset_mems_allowed (current);mpol_rebind_policy (old, &mems); } +rcu_read_unlock (); *new = *old;atomic_set (&new->refcnt,1 );return new;
[tip:core/urgent] rcu, ftrace: Fix RCU lockdep splat in ftrace_perf_buf_prepare()
In reply to Paul E. McKenneyCommit-ID: 8d53dd546f36073e0d29b0cfc24c665db301e3e7 Gitweb: http://git.kernel.org/tip/8d53dd546f36073e0d29b0cfc24c665db301e3e7 Author: Paul E. McKenney <[email protected]> AuthorDate: Wed, 3 Mar 2010 17:50:18 -0800 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 4 Mar 2010 12:07:35 +0100
rcu, ftrace: Fix RCU lockdep splat in ftrace_perf_buf_prepare()
Change the pair of rcu_dereference() calls in ftrace_perf_buf_prepare() to rcu_dereference_sched().
LKML-Reference: <[email protected]>
--- include/trace/ftrace.h | 4 ++-- kernel/trace/trace_event_profile.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
include/trace/ftrace.h +2 -2
@@ -699,9 +699,9 @@ __attribute__((section("_ftrace_events"))) event_##call = { \* __cpu = smp_processor_id(); * * if (in_nmi()) -* trace_buf = rcu_dereference(perf_trace_buf_nmi); +* trace_buf = rcu_dereference_sched(perf_trace_buf_nmi); * else -* trace_buf = rcu_dereference(perf_trace_buf); +* trace_buf = rcu_dereference_sched(perf_trace_buf); * * if (!trace_buf) * goto end;
kernel/trace/trace_event_profile.c +2 -2
@@ -138,9 +138,9 @@ __kprobes void *ftrace_perf_buf_prepare(int size, unsigned short type, cpu =smp_processor_id ();if (in_nmi ()) - trace_buf =rcu_dereference (perf_trace_buf_nmi); + trace_buf =rcu_dereference_sched (perf_trace_buf_nmi);else - trace_buf =rcu_dereference (perf_trace_buf); + trace_buf =rcu_dereference_sched (perf_trace_buf);if (!trace_buf) goto err;