Miscellaneous fixes for v5.12
Subsystems (3)
Paul E. McKenney
maintainercover Miscellaneous fixes for v5.12
Hello!
This series contains miscellaneous fixes.
1. Allow try_invoke_on_locked_down_task() with irqs disabled,
courtesy of Peter Zijlstra.
2. Remove duplicate include of percpu-rwsem.h, courtesy of Wang Qing.
3. Add lockdep_assert_irqs_disabled() to rcu_sched_clock_irq()
and callees.
4. Add lockdep_assert_irqs_disabled() to raw_spin_unlock_rcu_node()
macros.
5. rcu-tasks: Add RCU-tasks self tests, courtesy of Uladzislau Rezki.
6. Make TASKS_TRACE_RCU select IRQ_WORK.
Thanx, Paul
------------------------------------------------------------------------
locking/locktorture.c | 1 rcu/Kconfig | 1 rcu/rcu.h | 16 ++++++++-- rcu/tasks.h | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ rcu/tree.c | 4 ++ rcu/tree_plugin.h | 1 rcu/tree_stall.h | 8 +++++ sched/core.c | 9 ++--- 8 files changed, 110 insertions(+), 9 deletions(-)
[email protected]
maintainerPATCH 1/6 sched/core: Allow try_invoke_on_locked_down_task() with irqs disabled
From: Peter Zijlstra <[email protected]>
The try_invoke_on_locked_down_task() function currently requires that interrupts be enabled, but it is called with interrupts disabled from rcu_print_task_stall(), resulting in an "IRQs not enabled as expected" diagnostic. This commit therefore updates try_invoke_on_locked_down_task() to use raw_spin_lock_irqsave() instead of raw_spin_lock_irq(), thus allowing use from either context.
--- kernel/sched/core.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
kernel/sched/core.c +4 -5
@@ -2989,7 +2989,7 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)/** * try_invoke_on_locked_down_task - Invoke a function on task in fixed state -* @p: Process for which the function is to be invoked. +* @p: Process for which the function is to be invoked, can be @current. * @func: Function to invoke. * @arg: Argument to function. *
@@ -3007,12 +3007,11 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)*/ bool try_invoke_on_locked_down_task (struct task_struct *p,bool (*func)(struct task_struct *t,void *arg),void *arg) { -bool ret = false;struct rq_flags rf; +bool ret = false;struct rq *rq; -lockdep_assert_irqs_enabled (); -raw_spin_lock_irq (&p->pi_lock); +raw_spin_lock_irqsave (&p->pi_lock, rf.flags);if (p->on_rq) { rq =__task_rq_lock (p, &rf);if (task_rq (p) == rq)
@@ -3029,7 +3028,7 @@ bool try_invoke_on_locked_down_task(struct task_struct *p, bool (*func)(struct t ret =func (p, arg); } } -raw_spin_unlock_irq (&p->pi_lock); +raw_spin_unlock_irqrestore (&p->pi_lock, rf.flags);return ret; }
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 2/6 locking: Remove duplicate include of percpu-rwsem.h
In reply to Paul E. McKenneyFrom: Wang Qing <[email protected]>
This commit removes an unnecessary #include.
--- kernel/locking/locktorture.c | 1 - 1 file changed, 1 deletion(-)
kernel/locking/locktorture.c +0 -1
@@ -27,7 +27,6 @@#include <linux/moduleparam.h> #include <linux/delay.h> #include <linux/slab.h> -#include <linux/percpu-rwsem.h> #include <linux/torture.h> MODULE_LICENSE ("GPL" );
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 3/6 rcu: Add lockdep_assert_irqs_disabled() to rcu_sched_clock_irq() and callees
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit adds a number of lockdep_assert_irqs_disabled() calls to rcu_sched_clock_irq() and a number of the functions that it calls. The point of this is to help track down a situation where lockdep appears to be insisting that interrupts are enabled within these functions, which should only ever be invoked from the scheduling-clock interrupt handler.
--- kernel/rcu/tree.c | 4 ++++ kernel/rcu/tree_plugin.h | 1 + kernel/rcu/tree_stall.h | 8 ++++++++ 3 files changed, 13 insertions(+)
kernel/rcu/tree.c +4 -0
@@ -2553,6 +2553,7 @@ static void rcu_do_batch(struct rcu_data *rdp)void rcu_sched_clock_irq (int user) {trace_rcu_utilization (TPS ("Start scheduler-tick" )); +lockdep_assert_irqs_disabled ();raw_cpu_inc (rcu_data.ticks_this_gp);/* The load-acquire pairs with the store-release setting to true. */ if (smp_load_acquire (this_cpu_ptr (&rcu_data.rcu_urgent_qs))) {
@@ -2566,6 +2567,7 @@ void rcu_sched_clock_irq(int user)rcu_flavor_sched_clock_irq (user);if (rcu_pending (user))invoke_rcu_core (); +lockdep_assert_irqs_disabled ();trace_rcu_utilization (TPS ("End scheduler-tick" )); }
@@ -3690,6 +3692,8 @@ static int rcu_pending(int user)struct rcu_data *rdp =this_cpu_ptr (&rcu_data);struct rcu_node *rnp = rdp->mynode; +lockdep_assert_irqs_disabled (); +/* Check for CPU stalls, if enabled. */ check_cpu_stall (rdp);
kernel/rcu/tree_plugin.h +1 -0
@@ -682,6 +682,7 @@ static void rcu_flavor_sched_clock_irq(int user) {struct task_struct *t = current; +lockdep_assert_irqs_disabled ();if (user ||rcu_is_cpu_rrupt_from_idle ()) {rcu_note_voluntary_context_switch (current); }
kernel/rcu/tree_stall.h +8 -0
@@ -260,6 +260,7 @@ static int rcu_print_task_stall(struct rcu_node *rnp, unsigned long flags)struct task_struct *t;struct task_struct *ts[8 ]; +lockdep_assert_irqs_disabled ();if (!rcu_preempt_blocked_readers_cgp (rnp))return 0 ; pr_err("\tTasks blocked on level-%d rcu_node (CPUs %d-%d):",
@@ -284,6 +285,7 @@ static int rcu_print_task_stall(struct rcu_node *rnp, unsigned long flags)".q" [rscr.rs.b.need_qs],".e" [rscr.rs.b.exp_hint], ".l"[rscr.on_blkd_list]); +lockdep_assert_irqs_disabled ();put_task_struct (t); ndetected++; }
@@ -472,6 +474,8 @@ static void print_other_cpu_stall(unsigned long gp_seq, unsigned long gps)struct rcu_node *rnp;long totqlen =0 ; +lockdep_assert_irqs_disabled (); +/* Kick and suppress, if so configured. */ rcu_stall_kick_kthreads ();if (rcu_stall_is_suppressed ())
@@ -493,6 +497,7 @@ static void print_other_cpu_stall(unsigned long gp_seq, unsigned long gps) } } ndetected +=rcu_print_task_stall (rnp, flags);// Releases rnp->lock. +lockdep_assert_irqs_disabled (); }for_each_possible_cpu (cpu)
@@ -538,6 +543,8 @@ static void print_cpu_stall(unsigned long gps)struct rcu_node *rnp =rcu_get_root ();long totqlen =0 ; +lockdep_assert_irqs_disabled (); +/* Kick and suppress, if so configured. */ rcu_stall_kick_kthreads ();if (rcu_stall_is_suppressed ())
@@ -592,6 +599,7 @@ static void check_cpu_stall(struct rcu_data *rdp)unsigned long js;struct rcu_node *rnp; +lockdep_assert_irqs_disabled ();if ((rcu_stall_is_suppressed () && !READ_ONCE (rcu_kick_kthreads)) || !rcu_gp_in_progress ())return ;
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 4/6 rcu: Add lockdep_assert_irqs_disabled() to raw_spin_unlock_rcu_node() macros
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit adds a lockdep_assert_irqs_disabled() call to the helper macros that release the rcu_node structure's ->lock, namely to raw_spin_unlock_rcu_node(), raw_spin_unlock_irq_rcu_node() and raw_spin_unlock_irqrestore_rcu_node(). The point of this is to help track down a situation where lockdep appears to be insisting that interrupts are enabled while holding an rcu_node structure's ->lock.
--- kernel/rcu/rcu.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
kernel/rcu/rcu.h +13 -3
@@ -378,7 +378,11 @@ do { \smp_mb__after_unlock_lock (); \ } while (0) -#define raw_spin_unlock_rcu_node (p) raw_spin_unlock(&ACCESS_PRIVATE(p, lock)) +#define raw_spin_unlock_rcu_node (p) \ +do { \ + lockdep_assert_irqs_disabled(); \ + raw_spin_unlock(&ACCESS_PRIVATE(p, lock)); \ +} while (0)#define raw_spin_lock_irq_rcu_node (p) \ do { \
@@ -387,7 +391,10 @@ do { \ } while (0)#define raw_spin_unlock_irq_rcu_node (p) \ - raw_spin_unlock_irq(&ACCESS_PRIVATE(p, lock)) +do { \ + lockdep_assert_irqs_disabled(); \ + raw_spin_unlock_irq(&ACCESS_PRIVATE(p, lock)); \ +} while (0)#define raw_spin_lock_irqsave_rcu_node (p, flags) \ do { \
@@ -396,7 +403,10 @@ do { \ } while (0)#define raw_spin_unlock_irqrestore_rcu_node (p, flags) \ - raw_spin_unlock_irqrestore(&ACCESS_PRIVATE(p, lock), flags) +do { \ + lockdep_assert_irqs_disabled(); \ + raw_spin_unlock_irqrestore(&ACCESS_PRIVATE(p, lock), flags); \ +} while (0)#define raw_spin_trylock_rcu_node (p) \ ({ \
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 5/6 rcu-tasks: Add RCU-tasks self tests
In reply to Paul E. McKenneyFrom: "Uladzislau Rezki (Sony)" <[email protected]>
This commit adds self tests for early-boot use of RCU-tasks grace periods. It tests all three variants (Rude, Tasks, and Tasks Trace) and covers both synchronous (e.g., synchronize_rcu_tasks()) and asynchronous (e.g., call_rcu_tasks()) grace-period APIs.
Self-tests are run only in kernels built with CONFIG_PROVE_RCU=y.
--- kernel/rcu/tasks.h | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+)
kernel/rcu/tasks.h +79 -0
@@ -1231,6 +1231,82 @@ void show_rcu_tasks_gp_kthreads(void) }#endif /* #ifndef CONFIG_TINY_RCU */ +#ifdef CONFIG_PROVE_RCU +struct rcu_tasks_test_desc { +struct rcu_head rh; +const char *name; +bool notrun; +}; + +static struct rcu_tasks_test_desc tests[] = { + { + .name ="call_rcu_tasks()" , +/* If not defined, the test is skipped. */ + .notrun = !IS_ENABLED (CONFIG_TASKS_RCU ), + }, + { + .name ="call_rcu_tasks_rude()" , +/* If not defined, the test is skipped. */ + .notrun = !IS_ENABLED (CONFIG_TASKS_RUDE_RCU ), + }, + { + .name ="call_rcu_tasks_trace()" , +/* If not defined, the test is skipped. */ + .notrun = !IS_ENABLED (CONFIG_TASKS_TRACE_RCU ) + } +}; + +static void test_rcu_tasks_callback (struct rcu_head *rhp) +{ +struct rcu_tasks_test_desc *rttd = + container_of(rhp, struct rcu_tasks_test_desc, rh); + +pr_info ("Callback from %s invoked.\n" , rttd->name); + + rttd->notrun = true; +} + +static void rcu_tasks_initiate_self_tests (void ) +{ +pr_info ("Running RCU-tasks wait API self tests\n" ); +#ifdef CONFIG_TASKS_RCU +synchronize_rcu_tasks (); +call_rcu_tasks (&tests[0 ].rh, test_rcu_tasks_callback); +#endif + +#ifdef CONFIG_TASKS_RUDE_RCU +synchronize_rcu_tasks_rude (); +call_rcu_tasks_rude (&tests[1 ].rh, test_rcu_tasks_callback); +#endif + +#ifdef CONFIG_TASKS_TRACE_RCU +synchronize_rcu_tasks_trace (); +call_rcu_tasks_trace (&tests[2 ].rh, test_rcu_tasks_callback); +#endif +} + +static int rcu_tasks_verify_self_tests (void ) +{ +int ret =0 ; +int i; + +for (i =0 ; i <ARRAY_SIZE (tests); i++) { +if (!tests[i].notrun) {// still hanging. +pr_err ("%s has been failed.\n" , tests[i].name); + ret =-1 ; + } + } + +if (ret) +WARN_ON (1 ); + +return ret; +} +late_initcall (rcu_tasks_verify_self_tests); +#else /* #ifdef CONFIG_PROVE_RCU */ +static void rcu_tasks_initiate_self_tests (void ) { } +#endif /* #else #ifdef CONFIG_PROVE_RCU */ +void __init rcu_init_tasks_generic (void ) {#ifdef CONFIG_TASKS_RCU
@@ -1244,6 +1320,9 @@ void __init rcu_init_tasks_generic(void)#ifdef CONFIG_TASKS_TRACE_RCU rcu_spawn_tasks_trace_kthread ();#endif + +// Run the self-tests. + rcu_tasks_initiate_self_tests(); }#else /* #ifdef CONFIG_TASKS_RCU_GENERIC */
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 6/6 rcu: Make TASKS_TRACE_RCU select IRQ_WORK
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
Tasks Trace RCU uses irq_work_queue() to safely awaken its grace-period kthread, so this commit therefore causes the TASKS_TRACE_RCU Kconfig option select the IRQ_WORK Kconfig option.
--- kernel/rcu/Kconfig | 1 + 1 file changed, 1 insertion(+)
kernel/rcu/Kconfig +1 -0
@@ -95,6 +95,7 @@ config TASKS_RUDE_RCU config TASKS_TRACE_RCU def_bool 0 + select IRQ_WORK help This option enables a task-based RCU implementation that uses explicit rcu_read_lock_trace() read-side markers, and allows
Signature · 1 line
2.9.5