Candidate patches for the v7.2 merge window
Subsystems (8)
Uladzislau Rezki (Sony)
maintainercover Candidate patches for the v7.2 merge window
Hello!
The git tree with candidate patches for Linux-7.2 can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux.git
(tag: rcu-7.2-v1-20260511)
Please note, there is one patch which should be checked, it is from Zqiang.
Paul E. McKenney (10):
rcutorture: Fully test lazy RCU
torture: Add torture_sched_set_normal() for user-specified nice values
torture: Improve kvm-series.sh header comment
torture: Allow "norm" abbreviation for "normal"
srcu: Don't queue workqueue handlers to never-online CPUs
srcu: Fix kerneldoc header comment typo in srcu_down_read_fast()
checkpatch: Undeprecate rcu_read_lock_trace() and
rcu_read_unlock_trace()
rcu: Simplify rcu_do_batch() by applying clamp()
rcu: Simplify param_set_next_fqs_jiffies() by applying clamp_val()
rcu: Document rcu_access_pointer() feeding into cmpxchg()
Uladzislau Rezki (Sony) (1):
rcu: Latch normal synchronize_rcu() path on flood
Zqiang (1):
rcu-tasks: Fix possible boot-time tests failed for the
call_rcu_tasks()
.../admin-guide/kernel-parameters.txt | 10 ++-- include/linux/rcupdate.h | 12 ++-- include/linux/srcu.h | 2 +- include/linux/torture.h | 1 + kernel/rcu/rcutorture.c | 21 ++++++- kernel/rcu/srcutree.c | 12 ++-- kernel/rcu/tasks.h | 3 +- kernel/rcu/tree.c | 56 ++++++++++++++----- kernel/torture.c | 16 ++++++ scripts/checkpatch.pl | 5 +- .../selftests/rcutorture/bin/kvm-series.sh | 11 ++-- .../selftests/rcutorture/bin/torture.sh | 2 +- 12 files changed, 107 insertions(+), 44 deletions(-)
Signature · 1 line
2.47.3
Uladzislau Rezki (Sony)
maintainerPATCH 1/12 rcutorture: Fully test lazy RCU
From: "Paul E. McKenney" <[email protected]>
Currently, rcutorture bypasses lazy RCU by using call_rcu_hurry(). This works, avoiding the dreaded rtort_pipe_count WARN(), but fails to fully test lazy RCU. The rtort_pipe_count WARN() splats because lazy RCU could delay the start of an RCU grace period for a full stutter period, which defaults to only three seconds.
This commit therefore reverts the call_rcu_hurry() instances back to call_rcu(), but, in kernels built with CONFIG_RCU_LAZY=y, queues a workqueue handler just before the call to stutter_wait() in rcu_torture_writer(). This workqueue handler invokes rcu_barrier(), which motivates any lingering lazy callbacks, thus avoiding the splat.
Questions for review:
1. Should we avoid queueing work for RCU implementations not
supporting lazy callbacks?
2. Should we avoid queueing work in kernels built with
CONFIG_RCU_LAZY=y, but that were not booted with the rcutree.enable_rcu_lazy kernel boot parameter set? (Note that this requires some ugliness to access this parameter, and must also handle Tiny RCU.)
3. Does the rcu_torture_ops structure need a ->call_hurry() field,
and if so, why? If not, why not?
4. Your additional questions here!
--- kernel/rcu/rcutorture.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
kernel/rcu/rcutorture.c +18 -3
@@ -572,7 +572,7 @@ static unsigned long rcu_no_completed(void)static void rcu_torture_deferred_free (struct rcu_torture *p) { -call_rcu_hurry (&p->rtort_rcu, rcu_torture_cb); +call_rcu (&p->rtort_rcu, rcu_torture_cb); }static void rcu_sync_torture_init (void )
@@ -619,7 +619,7 @@ static struct rcu_torture_ops rcu_ops = { .poll_gp_state_exp = poll_state_synchronize_rcu, .cond_sync_exp = cond_synchronize_rcu_expedited, .cond_sync_exp_full = cond_synchronize_rcu_expedited_full, - .call = call_rcu_hurry, + .call = call_rcu, .cb_barrier = rcu_barrier, .fqs = rcu_force_quiescent_state, .gp_kthread_dbg = show_rcu_gp_kthreads,
@@ -1145,7 +1145,7 @@ static void rcu_tasks_torture_deferred_free(struct rcu_torture *p)static void synchronize_rcu_mult_test (void ) { -synchronize_rcu_mult (call_rcu_tasks, call_rcu_hurry); +synchronize_rcu_mult (call_rcu_tasks, call_rcu); }static struct rcu_torture_ops tasks_ops = {
@@ -1631,6 +1631,17 @@ static void do_rtws_sync(struct torture_random_state *trsp, void (*sync)(void))cpus_read_unlock (); } +/* +* Do an rcu_barrier() to motivate lazy callbacks during a stutter +* pause. Without this, we can get false-positives rtort_pipe_count +* splats. +*/ +static void rcu_torture_writer_work (struct work_struct *work) +{ +if (cur_ops->cb_barrier) + cur_ops->cb_barrier (); +} +/* * RCU torture writer kthread. Repeatedly substitutes a new structure * for that pointed to by rcu_torture_current, freeing the old structure
@@ -1651,6 +1662,7 @@ rcu_torture_writer(void *arg)int i;int idx;unsigned long j; +struct work_struct lazy_work;int oldnice =task_nice (current);struct rcu_gp_oldstate *rgo =NULL ;int rgo_size =0 ;
@@ -1667,6 +1679,7 @@ rcu_torture_writer(void *arg) stallsdone += (stall_cpu_holdoff + stall_gp_kthread + stall_cpu +60 ) *HZ * (stall_cpu_repeat +1 );VERBOSE_TOROUT_STRING ("rcu_torture_writer task started" ); +INIT_WORK_ONSTACK (&lazy_work, rcu_torture_writer_work);if (!can_expedite) pr_alert("%s" TORTURE_FLAG " GP expediting controlled from boot/sysfs for %s.\n",
@@ -1895,6 +1908,8 @@ rcu_torture_writer(void *arg) !rcu_gp_is_normal (); } rcu_torture_writer_state =RTWS_STUTTER ; +if (IS_ENABLED (CONFIG_RCU_LAZY )) +queue_work (system_percpu_wq, &lazy_work); stutter_waited =stutter_wait ("rcu_torture_writer" ); if (stutter_waited && !atomic_read(&rcu_fwd_cb_nodelay) &&
Signature · 1 line
2.47.3
Re: [PATCH -next v1 01/12] rcutorture: Fully test lazy RCU
Quoted 15 lines
From: "Paul E. McKenney" <[email protected]>
Currently, rcutorture bypasses lazy RCU by using
call_rcu_hurry(). This works, avoiding the dreadedrtort_pipe_countWARN(), but fails to fully test lazy RCU. Thertort_pipe_countWARN()splats because lazy RCU could delay the start of an RCU grace period for a full stutter period, which defaults to only three seconds.This commit therefore reverts the
call_rcu_hurry()instances back tocall_rcu(), but, in kernels built withCONFIG_RCU_LAZY=y, queues a workqueue handler just before the call tostutter_wait()inrcu_torture_writer(). This workqueue handler invokesrcu_barrier(), which motivates any lingering lazy callbacks, thus avoiding the splat.
Quoted 4 lines
Questions for review:
1. Should we avoid queueing work for RCU implementations not
supporting lazy callbacks?
Hello, Paul
maybe we can do this:
rcu_ops = {
...
.support_lazy = IS_ENABLED(CONFIG_RCU_LAZY),
};
and
if (cur_ops->support_lazy )
queue_work(..., &lazy_work);
Quoted 85 lines
2. Should we avoid queueing work in kernels built with
CONFIG_RCU_LAZY=y, but that were not booted with the rcutree.enable_rcu_lazy kernel boot parameter set? (Note that this requires some ugliness to access this parameter, and must also handle Tiny RCU.)3. Does the
rcu_torture_opsstructure need a ->call_hurry() field,
and if so, why? If not, why not?4. Your additional questions here!
Reported-by Saravana Kannan <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Signed-off-by Uladzislau Rezki (Sony) <[email protected]>--- kernel/rcu/rcutorture.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)kernel/rcu/rcutorture.c +16
-3@@ -572,7 +572,7 @@ static unsigned long rcu_no_completed(void)static void rcu_torture_deferred_free (struct rcu_torture *p) { -call_rcu_hurry (&p->rtort_rcu, rcu_torture_cb); +call_rcu (&p->rtort_rcu, rcu_torture_cb); }static void rcu_sync_torture_init (void )@@ -619,7 +619,7 @@ static struct rcu_torture_ops rcu_ops = { .poll_gp_state_exp = poll_state_synchronize_rcu, .cond_sync_exp = cond_synchronize_rcu_expedited, .cond_sync_exp_full = cond_synchronize_rcu_expedited_full, - .call = call_rcu_hurry, + .call = call_rcu, .cb_barrier = rcu_barrier, .fqs = rcu_force_quiescent_state, .gp_kthread_dbg = show_rcu_gp_kthreads,@@ -1145,7 +1145,7 @@ static void rcu_tasks_torture_deferred_free(struct rcu_torture *p)static void synchronize_rcu_mult_test (void ) { -synchronize_rcu_mult (call_rcu_tasks, call_rcu_hurry); +synchronize_rcu_mult (call_rcu_tasks, call_rcu); }static struct rcu_torture_ops tasks_ops = {@@ -1631,6 +1631,17 @@ static void do_rtws_sync(struct torture_random_state *trsp, void (*sync)(void))cpus_read_unlock (); } +/* +* Do an rcu_barrier() to motivate lazy callbacks during a stutter +* pause. Without this, we can get false-positives rtort_pipe_count +* splats. +*/ +static void rcu_torture_writer_work (struct work_struct *work) +{ +if (cur_ops->cb_barrier) + cur_ops->cb_barrier (); +} +/* * RCU torture writer kthread. Repeatedly substitutes a new structure * for that pointed to by rcu_torture_current, freeing the old structure @@ -1651,6 +1662,7 @@ rcu_torture_writer(void *arg)int i;int idx;unsigned long j; +struct work_struct lazy_work;int oldnice =task_nice (current);struct rcu_gp_oldstate *rgo =NULL ;int rgo_size =0 ;@@ -1667,6 +1679,7 @@ rcu_torture_writer(void *arg) stallsdone += (stall_cpu_holdoff + stall_gp_kthread + stall_cpu +60 ) *HZ * (stall_cpu_repeat +1 );VERBOSE_TOROUT_STRING ("rcu_torture_writer task started" ); +INIT_WORK_ONSTACK (&lazy_work, rcu_torture_writer_work);if (!can_expedite) pr_alert("%s" TORTURE_FLAG " GP expediting controlled from boot/sysfs for %s.\n",
kernel/rcu/rcutorture.c rcu_torture_writer(void *arg) · line 1912
Quoted 5 lines
kernel/rcu/rcutorture.c +2
-0@@ -1895,6 +1908,8 @@ rcu_torture_writer(void *arg) !rcu_gp_is_normal (); } rcu_torture_writer_state =RTWS_STUTTER ; +if (IS_ENABLED (CONFIG_RCU_LAZY )) +queue_work (system_percpu_wq, &lazy_work);
When the task ends, the lazy_work should be cancel and destroy:
kernel/rcu/rcutorture.c +0 -0
@@ -1682,7 +1682,6 @@ rcu_torture_writer(void *arg)
stallsdone += (stall_cpu_holdoff + stall_gp_kthread + stall_cpu + 60) * HZ * (stall_cpu_repeat + 1); VERBOSE_TOROUT_STRING("rcu_torture_writer task started");
- INIT_WORK_ONSTACK(&lazy_work, rcu_torture_writer_work);
if (!can_expedite)
pr_alert("%s" TORTURE_FLAG
" GP expediting controlled from boot/sysfs for %s.\n",
@@ -1719,6 +1718,8 @@ rcu_torture_writer(void *arg) pr_alert("%s" TORTURE_FLAG " Waited %lu jiffies for boot to complete.\n", torture_type, jiffies - j);
+ INIT_WORK_ONSTACK(&lazy_work, rcu_torture_writer_work); +
do {rcu_torture_writer_state = RTWS_FIXED_DELAY; torture_hrtimeout_us(500, 1000, &rand);
@@ -1943,6 +1944,9 @@ rcu_torture_writer(void *arg) pr_alert("%s" TORTURE_FLAG
" Dynamic grace-period expediting was disabled.\n", torture_type);
+ if (IS_ENABLED(CONFIG_RCU_LAZY))
+ cancel_work_sync(&lazy_work);
+ destroy_work_on_stack(&lazy_work);
kfree(ulo);
kfree(rgo);rcu_torture_writer_state = RTWS_STOPPING;
Thanks
Zqiang
Quoted 7 lines
kernel/rcu/rcutorture.c +0
-1stutter_waited =stutter_wait ("rcu_torture_writer" ); if (stutter_waited && !atomic_read(&rcu_fwd_cb_nodelay) && --2.47.3
Uladzislau Rezki
maintainerRe: [PATCH -next v1 01/12] rcutorture: Fully test lazy RCU
Quoted 151 lines · Z qiang
Quoted 15 lines
From: "Paul E. McKenney" <[email protected]>
Currently, rcutorture bypasses lazy RCU by using
call_rcu_hurry(). This works, avoiding the dreadedrtort_pipe_countWARN(), but fails to fully test lazy RCU. Thertort_pipe_countWARN()splats because lazy RCU could delay the start of an RCU grace period for a full stutter period, which defaults to only three seconds.This commit therefore reverts the
call_rcu_hurry()instances back tocall_rcu(), but, in kernels built withCONFIG_RCU_LAZY=y, queues a workqueue handler just before the call tostutter_wait()inrcu_torture_writer(). This workqueue handler invokesrcu_barrier(), which motivates any lingering lazy callbacks, thus avoiding the splat.Quoted 4 lines
Questions for review:
1. Should we avoid queueing work for RCU implementations not
supporting lazy callbacks?Hello, Paul
maybe we can do this:
rcu_ops= {
...
.support_lazy =IS_ENABLED(CONFIG_RCU_LAZY),
};and
if (
cur_ops->support_lazy)queue_work(..., &lazy_work);Quoted 85 lines
2. Should we avoid queueing work in kernels built with
CONFIG_RCU_LAZY=y, but that were not booted with the rcutree.enable_rcu_lazy kernel boot parameter set? (Note that this requires some ugliness to access this parameter, and must also handle Tiny RCU.)3. Does the
rcu_torture_opsstructure need a ->call_hurry() field,
and if so, why? If not, why not?4. Your additional questions here!
Reported-by Saravana Kannan <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Signed-off-by Uladzislau Rezki (Sony) <[email protected]>--- kernel/rcu/rcutorture.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)kernel/rcu/rcutorture.c +16
-3@@ -572,7 +572,7 @@ static unsigned long rcu_no_completed(void)static void rcu_torture_deferred_free (struct rcu_torture *p) { -call_rcu_hurry (&p->rtort_rcu, rcu_torture_cb); +call_rcu (&p->rtort_rcu, rcu_torture_cb); }static void rcu_sync_torture_init (void )@@ -619,7 +619,7 @@ static struct rcu_torture_ops rcu_ops = { .poll_gp_state_exp = poll_state_synchronize_rcu, .cond_sync_exp = cond_synchronize_rcu_expedited, .cond_sync_exp_full = cond_synchronize_rcu_expedited_full, - .call = call_rcu_hurry, + .call = call_rcu, .cb_barrier = rcu_barrier, .fqs = rcu_force_quiescent_state, .gp_kthread_dbg = show_rcu_gp_kthreads,@@ -1145,7 +1145,7 @@ static void rcu_tasks_torture_deferred_free(struct rcu_torture *p)static void synchronize_rcu_mult_test (void ) { -synchronize_rcu_mult (call_rcu_tasks, call_rcu_hurry); +synchronize_rcu_mult (call_rcu_tasks, call_rcu); }static struct rcu_torture_ops tasks_ops = {@@ -1631,6 +1631,17 @@ static void do_rtws_sync(struct torture_random_state *trsp, void (*sync)(void))cpus_read_unlock (); } +/* +* Do an rcu_barrier() to motivate lazy callbacks during a stutter +* pause. Without this, we can get false-positives rtort_pipe_count +* splats. +*/ +static void rcu_torture_writer_work (struct work_struct *work) +{ +if (cur_ops->cb_barrier) + cur_ops->cb_barrier (); +} +/* * RCU torture writer kthread. Repeatedly substitutes a new structure * for that pointed to by rcu_torture_current, freeing the old structure @@ -1651,6 +1662,7 @@ rcu_torture_writer(void *arg)int i;int idx;unsigned long j; +struct work_struct lazy_work;int oldnice =task_nice (current);struct rcu_gp_oldstate *rgo =NULL ;int rgo_size =0 ;@@ -1667,6 +1679,7 @@ rcu_torture_writer(void *arg) stallsdone += (stall_cpu_holdoff + stall_gp_kthread + stall_cpu +60 ) *HZ * (stall_cpu_repeat +1 );VERBOSE_TOROUT_STRING ("rcu_torture_writer task started" ); +INIT_WORK_ONSTACK (&lazy_work, rcu_torture_writer_work);if (!can_expedite) pr_alert("%s" TORTURE_FLAG " GP expediting controlled from boot/sysfs for %s.\n",kernel/rcu/rcutorture.c rcu_torture_writer(void *arg) · line 1912
Quoted 5 lines
kernel/rcu/rcutorture.c +2
-0@@ -1895,6 +1908,8 @@ rcu_torture_writer(void *arg) !rcu_gp_is_normal (); } rcu_torture_writer_state =RTWS_STUTTER ; +if (IS_ENABLED (CONFIG_RCU_LAZY )) +queue_work (system_percpu_wq, &lazy_work);When the task ends, the
lazy_workshould be cancel and destroy:kernel/rcu/rcutorture.c +0
-0@@ -1682,7 +1682,6 @@ rcu_torture_writer(void *arg)stallsdone += (
stall_cpu_holdoff+stall_gp_kthread+stall_cpu+ 60) * HZ * (stall_cpu_repeat+ 1);VERBOSE_TOROUT_STRING("rcu_torture_writer task started");
-INIT_WORK_ONSTACK(&lazy_work, rcu_torture_writer_work);
if (!can_expedite)
pr_alert("%s"TORTURE_FLAG
" GP expediting controlled from boot/sysfs for %s.\n",kernel/rcu/rcutorture.c +2
-0@@ -1719,6 +1718,8 @@ rcu_torture_writer(void *arg)pr_alert ("%s" TORTURE_FLAG " Waited %lu jiffies for boot to complete.\n" , torture_type, jiffies - j); +INIT_WORK_ONSTACK (&lazy_work, rcu_torture_writer_work); + do { rcu_torture_writer_state = RTWS_FIXED_DELAY; torture_hrtimeout_us(500, 1000, &rand);@@ -1943,6 +1944,9 @@ rcu_torture_writer(void *arg)pr_alert("%s"
TORTURE_FLAG
Quoted 9 lines
" Dynamic grace-period expediting was disabled.\n",
torture_type);
+ if (IS_ENABLED(CONFIG_RCU_LAZY))
+cancel_work_sync(&lazy_work);
+destroy_work_on_stack(&lazy_work); kfree(ulo);
kfree(rgo);rcu_torture_writer_state=RTWS_STOPPING;
I agree, we seem miss destroying the work via destroy_work_on_stack() and "sync" the lazy_work work via cancel_work_sync().
Paul, any thoughts?
--
Uladzislau Rezki
Paul E. McKenney
maintainerRe: [PATCH -next v1 01/12] rcutorture: Fully test lazy RCU
Quoted 164 lines · Uladzislau Rezki
Quoted 151 lines · Z qiang
Quoted 15 lines
From: "Paul E. McKenney" <[email protected]>
Currently, rcutorture bypasses lazy RCU by using
call_rcu_hurry(). This works, avoiding the dreadedrtort_pipe_countWARN(), but fails to fully test lazy RCU. Thertort_pipe_countWARN()splats because lazy RCU could delay the start of an RCU grace period for a full stutter period, which defaults to only three seconds.This commit therefore reverts the
call_rcu_hurry()instances back tocall_rcu(), but, in kernels built withCONFIG_RCU_LAZY=y, queues a workqueue handler just before the call tostutter_wait()inrcu_torture_writer(). This workqueue handler invokesrcu_barrier(), which motivates any lingering lazy callbacks, thus avoiding the splat.Quoted 4 lines
Questions for review:
1. Should we avoid queueing work for RCU implementations not
supporting lazy callbacks?Hello, Paul
maybe we can do this:
rcu_ops= {
...
.support_lazy =IS_ENABLED(CONFIG_RCU_LAZY),
};and
if (
cur_ops->support_lazy)queue_work(..., &lazy_work);Quoted 85 lines
2. Should we avoid queueing work in kernels built with
CONFIG_RCU_LAZY=y, but that were not booted with the rcutree.enable_rcu_lazy kernel boot parameter set? (Note that this requires some ugliness to access this parameter, and must also handle Tiny RCU.)3. Does the
rcu_torture_opsstructure need a ->call_hurry() field,
and if so, why? If not, why not?4. Your additional questions here!
Reported-by Saravana Kannan <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Signed-off-by Uladzislau Rezki (Sony) <[email protected]>--- kernel/rcu/rcutorture.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)kernel/rcu/rcutorture.c +16
-3@@ -572,7 +572,7 @@ static unsigned long rcu_no_completed(void)static void rcu_torture_deferred_free (struct rcu_torture *p) { -call_rcu_hurry (&p->rtort_rcu, rcu_torture_cb); +call_rcu (&p->rtort_rcu, rcu_torture_cb); }static void rcu_sync_torture_init (void )@@ -619,7 +619,7 @@ static struct rcu_torture_ops rcu_ops = { .poll_gp_state_exp = poll_state_synchronize_rcu, .cond_sync_exp = cond_synchronize_rcu_expedited, .cond_sync_exp_full = cond_synchronize_rcu_expedited_full, - .call = call_rcu_hurry, + .call = call_rcu, .cb_barrier = rcu_barrier, .fqs = rcu_force_quiescent_state, .gp_kthread_dbg = show_rcu_gp_kthreads,@@ -1145,7 +1145,7 @@ static void rcu_tasks_torture_deferred_free(struct rcu_torture *p)static void synchronize_rcu_mult_test (void ) { -synchronize_rcu_mult (call_rcu_tasks, call_rcu_hurry); +synchronize_rcu_mult (call_rcu_tasks, call_rcu); }static struct rcu_torture_ops tasks_ops = {@@ -1631,6 +1631,17 @@ static void do_rtws_sync(struct torture_random_state *trsp, void (*sync)(void))cpus_read_unlock (); } +/* +* Do an rcu_barrier() to motivate lazy callbacks during a stutter +* pause. Without this, we can get false-positives rtort_pipe_count +* splats. +*/ +static void rcu_torture_writer_work (struct work_struct *work) +{ +if (cur_ops->cb_barrier) + cur_ops->cb_barrier (); +} +/* * RCU torture writer kthread. Repeatedly substitutes a new structure * for that pointed to by rcu_torture_current, freeing the old structure @@ -1651,6 +1662,7 @@ rcu_torture_writer(void *arg)int i;int idx;unsigned long j; +struct work_struct lazy_work;int oldnice =task_nice (current);struct rcu_gp_oldstate *rgo =NULL ;int rgo_size =0 ;@@ -1667,6 +1679,7 @@ rcu_torture_writer(void *arg) stallsdone += (stall_cpu_holdoff + stall_gp_kthread + stall_cpu +60 ) *HZ * (stall_cpu_repeat +1 );VERBOSE_TOROUT_STRING ("rcu_torture_writer task started" ); +INIT_WORK_ONSTACK (&lazy_work, rcu_torture_writer_work);if (!can_expedite) pr_alert("%s" TORTURE_FLAG " GP expediting controlled from boot/sysfs for %s.\n",kernel/rcu/rcutorture.c rcu_torture_writer(void *arg) · line 1912
Quoted 5 lines
kernel/rcu/rcutorture.c +2
-0@@ -1895,6 +1908,8 @@ rcu_torture_writer(void *arg) !rcu_gp_is_normal (); } rcu_torture_writer_state =RTWS_STUTTER ; +if (IS_ENABLED (CONFIG_RCU_LAZY )) +queue_work (system_percpu_wq, &lazy_work);When the task ends, the
lazy_workshould be cancel and destroy:kernel/rcu/rcutorture.c +0
-0@@ -1682,7 +1682,6 @@ rcu_torture_writer(void *arg)stallsdone += (
stall_cpu_holdoff+stall_gp_kthread+stall_cpu+ 60) * HZ * (stall_cpu_repeat+ 1);VERBOSE_TOROUT_STRING("rcu_torture_writer task started");
-INIT_WORK_ONSTACK(&lazy_work, rcu_torture_writer_work);
if (!can_expedite)
pr_alert("%s"TORTURE_FLAG
" GP expediting controlled from boot/sysfs for %s.\n",kernel/rcu/rcutorture.c +2
-0@@ -1719,6 +1718,8 @@ rcu_torture_writer(void *arg)pr_alert ("%s" TORTURE_FLAG " Waited %lu jiffies for boot to complete.\n" , torture_type, jiffies - j); +INIT_WORK_ONSTACK (&lazy_work, rcu_torture_writer_work); + do { rcu_torture_writer_state = RTWS_FIXED_DELAY; torture_hrtimeout_us(500, 1000, &rand);@@ -1943,6 +1944,9 @@ rcu_torture_writer(void *arg)pr_alert("%s"
TORTURE_FLAGQuoted 9 lines
" Dynamic grace-period expediting was disabled.\n",
torture_type);
+ if (IS_ENABLED(CONFIG_RCU_LAZY))
+cancel_work_sync(&lazy_work);
+destroy_work_on_stack(&lazy_work); kfree(ulo);
kfree(rgo);rcu_torture_writer_state=RTWS_STOPPING;I agree, we seem miss destroying the work via
destroy_work_on_stack()and "sync" thelazy_workwork viacancel_work_sync().
Quoted 1 line
Paul, any thoughts?
Good eyes!!! I will take a closer look tomorrow.
In the meantime, one question... Do we want to test for your new ->support_lazy instead of IS_ENABLED(CONFIG_RCU_LAZY) for that cancel_work_sync() and destroy_work_on_stack()? If we really need IS_ENABLED(CONFIG_RCU_LAZY), could you please suggest a comment giving the reasoning?
Thanx, Paul
Uladzislau Rezki
maintainerRe: [PATCH -next v1 01/12] rcutorture: Fully test lazy RCU
Quoted 167 lines · Paul E. McKenney
Quoted 164 lines · Uladzislau Rezki
Quoted 151 lines · Z qiang
Quoted 15 lines
From: "Paul E. McKenney" <[email protected]>
Currently, rcutorture bypasses lazy RCU by using
call_rcu_hurry(). This works, avoiding the dreadedrtort_pipe_countWARN(), but fails to fully test lazy RCU. Thertort_pipe_countWARN()splats because lazy RCU could delay the start of an RCU grace period for a full stutter period, which defaults to only three seconds.This commit therefore reverts the
call_rcu_hurry()instances back tocall_rcu(), but, in kernels built withCONFIG_RCU_LAZY=y, queues a workqueue handler just before the call tostutter_wait()inrcu_torture_writer(). This workqueue handler invokesrcu_barrier(), which motivates any lingering lazy callbacks, thus avoiding the splat.Quoted 4 lines
Questions for review:
1. Should we avoid queueing work for RCU implementations not
supporting lazy callbacks?Hello, Paul
maybe we can do this:
rcu_ops= {
...
.support_lazy =IS_ENABLED(CONFIG_RCU_LAZY),
};and
if (
cur_ops->support_lazy)queue_work(..., &lazy_work);Quoted 85 lines
2. Should we avoid queueing work in kernels built with
CONFIG_RCU_LAZY=y, but that were not booted with the rcutree.enable_rcu_lazy kernel boot parameter set? (Note that this requires some ugliness to access this parameter, and must also handle Tiny RCU.)3. Does the
rcu_torture_opsstructure need a ->call_hurry() field,
and if so, why? If not, why not?4. Your additional questions here!
Reported-by Saravana Kannan <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Signed-off-by Uladzislau Rezki (Sony) <[email protected]>--- kernel/rcu/rcutorture.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)kernel/rcu/rcutorture.c +16
-3@@ -572,7 +572,7 @@ static unsigned long rcu_no_completed(void)static void rcu_torture_deferred_free (struct rcu_torture *p) { -call_rcu_hurry (&p->rtort_rcu, rcu_torture_cb); +call_rcu (&p->rtort_rcu, rcu_torture_cb); }static void rcu_sync_torture_init (void )@@ -619,7 +619,7 @@ static struct rcu_torture_ops rcu_ops = { .poll_gp_state_exp = poll_state_synchronize_rcu, .cond_sync_exp = cond_synchronize_rcu_expedited, .cond_sync_exp_full = cond_synchronize_rcu_expedited_full, - .call = call_rcu_hurry, + .call = call_rcu, .cb_barrier = rcu_barrier, .fqs = rcu_force_quiescent_state, .gp_kthread_dbg = show_rcu_gp_kthreads,@@ -1145,7 +1145,7 @@ static void rcu_tasks_torture_deferred_free(struct rcu_torture *p)static void synchronize_rcu_mult_test (void ) { -synchronize_rcu_mult (call_rcu_tasks, call_rcu_hurry); +synchronize_rcu_mult (call_rcu_tasks, call_rcu); }static struct rcu_torture_ops tasks_ops = {@@ -1631,6 +1631,17 @@ static void do_rtws_sync(struct torture_random_state *trsp, void (*sync)(void))cpus_read_unlock (); } +/* +* Do an rcu_barrier() to motivate lazy callbacks during a stutter +* pause. Without this, we can get false-positives rtort_pipe_count +* splats. +*/ +static void rcu_torture_writer_work (struct work_struct *work) +{ +if (cur_ops->cb_barrier) + cur_ops->cb_barrier (); +} +/* * RCU torture writer kthread. Repeatedly substitutes a new structure * for that pointed to by rcu_torture_current, freeing the old structure @@ -1651,6 +1662,7 @@ rcu_torture_writer(void *arg)int i;int idx;unsigned long j; +struct work_struct lazy_work;int oldnice =task_nice (current);struct rcu_gp_oldstate *rgo =NULL ;int rgo_size =0 ;@@ -1667,6 +1679,7 @@ rcu_torture_writer(void *arg) stallsdone += (stall_cpu_holdoff + stall_gp_kthread + stall_cpu +60 ) *HZ * (stall_cpu_repeat +1 );VERBOSE_TOROUT_STRING ("rcu_torture_writer task started" ); +INIT_WORK_ONSTACK (&lazy_work, rcu_torture_writer_work);if (!can_expedite) pr_alert("%s" TORTURE_FLAG " GP expediting controlled from boot/sysfs for %s.\n",kernel/rcu/rcutorture.c rcu_torture_writer(void *arg) · line 1912
Quoted 5 lines
kernel/rcu/rcutorture.c +2
-0@@ -1895,6 +1908,8 @@ rcu_torture_writer(void *arg) !rcu_gp_is_normal (); } rcu_torture_writer_state =RTWS_STUTTER ; +if (IS_ENABLED (CONFIG_RCU_LAZY )) +queue_work (system_percpu_wq, &lazy_work);When the task ends, the
lazy_workshould be cancel and destroy:kernel/rcu/rcutorture.c +0
-0@@ -1682,7 +1682,6 @@ rcu_torture_writer(void *arg)stallsdone += (
stall_cpu_holdoff+stall_gp_kthread+stall_cpu+ 60) * HZ * (stall_cpu_repeat+ 1);VERBOSE_TOROUT_STRING("rcu_torture_writer task started");
-INIT_WORK_ONSTACK(&lazy_work, rcu_torture_writer_work);
if (!can_expedite)
pr_alert("%s"TORTURE_FLAG
" GP expediting controlled from boot/sysfs for %s.\n",kernel/rcu/rcutorture.c +2
-0@@ -1719,6 +1718,8 @@ rcu_torture_writer(void *arg)pr_alert ("%s" TORTURE_FLAG " Waited %lu jiffies for boot to complete.\n" , torture_type, jiffies - j); +INIT_WORK_ONSTACK (&lazy_work, rcu_torture_writer_work); + do { rcu_torture_writer_state = RTWS_FIXED_DELAY; torture_hrtimeout_us(500, 1000, &rand);@@ -1943,6 +1944,9 @@ rcu_torture_writer(void *arg)pr_alert("%s"
TORTURE_FLAGQuoted 9 lines
" Dynamic grace-period expediting was disabled.\n",
torture_type);
+ if (IS_ENABLED(CONFIG_RCU_LAZY))
+cancel_work_sync(&lazy_work);
+destroy_work_on_stack(&lazy_work); kfree(ulo);
kfree(rgo);rcu_torture_writer_state=RTWS_STOPPING;I agree, we seem miss destroying the work via
destroy_work_on_stack()and "sync" thelazy_workwork viacancel_work_sync().Quoted 1 line
Paul, any thoughts?
Quoted 8 lines
Good eyes!!! I will take a closer look tomorrow.
In the meantime, one question... Do we want to test for your new ->support_lazy instead of
IS_ENABLED(CONFIG_RCU_LAZY)for thatcancel_work_sync()anddestroy_work_on_stack()? If we really needIS_ENABLED(CONFIG_RCU_LAZY), could you please suggest a comment giving the reasoning?
To me IS_ENABLED(CONFIG_RCU_LAZY) is enough :) I am not sure we really need ->support_lazy flag.
--
Uladzislau Rezki
Paul E. McKenney
maintainerRe: [PATCH -next v1 01/12] rcutorture: Fully test lazy RCU
Quoted 170 lines · Uladzislau Rezki
Quoted 169 lines · Paul E. McKenney
Quoted 164 lines · Uladzislau Rezki
Quoted 151 lines · Z qiang
Quoted 15 lines
From: "Paul E. McKenney" <[email protected]>
Currently, rcutorture bypasses lazy RCU by using
call_rcu_hurry(). This works, avoiding the dreadedrtort_pipe_countWARN(), but fails to fully test lazy RCU. Thertort_pipe_countWARN()splats because lazy RCU could delay the start of an RCU grace period for a full stutter period, which defaults to only three seconds.This commit therefore reverts the
call_rcu_hurry()instances back tocall_rcu(), but, in kernels built withCONFIG_RCU_LAZY=y, queues a workqueue handler just before the call tostutter_wait()inrcu_torture_writer(). This workqueue handler invokesrcu_barrier(), which motivates any lingering lazy callbacks, thus avoiding the splat.Quoted 4 lines
Questions for review:
1. Should we avoid queueing work for RCU implementations not
supporting lazy callbacks?Hello, Paul
maybe we can do this:
rcu_ops= {
...
.support_lazy =IS_ENABLED(CONFIG_RCU_LAZY),
};and
if (
cur_ops->support_lazy)queue_work(..., &lazy_work);Quoted 85 lines
2. Should we avoid queueing work in kernels built with
CONFIG_RCU_LAZY=y, but that were not booted with the rcutree.enable_rcu_lazy kernel boot parameter set? (Note that this requires some ugliness to access this parameter, and must also handle Tiny RCU.)3. Does the
rcu_torture_opsstructure need a ->call_hurry() field,
and if so, why? If not, why not?4. Your additional questions here!
Reported-by Saravana Kannan <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Signed-off-by Uladzislau Rezki (Sony) <[email protected]>--- kernel/rcu/rcutorture.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)kernel/rcu/rcutorture.c +16
-3@@ -572,7 +572,7 @@ static unsigned long rcu_no_completed(void)static void rcu_torture_deferred_free (struct rcu_torture *p) { -call_rcu_hurry (&p->rtort_rcu, rcu_torture_cb); +call_rcu (&p->rtort_rcu, rcu_torture_cb); }static void rcu_sync_torture_init (void )@@ -619,7 +619,7 @@ static struct rcu_torture_ops rcu_ops = { .poll_gp_state_exp = poll_state_synchronize_rcu, .cond_sync_exp = cond_synchronize_rcu_expedited, .cond_sync_exp_full = cond_synchronize_rcu_expedited_full, - .call = call_rcu_hurry, + .call = call_rcu, .cb_barrier = rcu_barrier, .fqs = rcu_force_quiescent_state, .gp_kthread_dbg = show_rcu_gp_kthreads,@@ -1145,7 +1145,7 @@ static void rcu_tasks_torture_deferred_free(struct rcu_torture *p)static void synchronize_rcu_mult_test (void ) { -synchronize_rcu_mult (call_rcu_tasks, call_rcu_hurry); +synchronize_rcu_mult (call_rcu_tasks, call_rcu); }static struct rcu_torture_ops tasks_ops = {@@ -1631,6 +1631,17 @@ static void do_rtws_sync(struct torture_random_state *trsp, void (*sync)(void))cpus_read_unlock (); } +/* +* Do an rcu_barrier() to motivate lazy callbacks during a stutter +* pause. Without this, we can get false-positives rtort_pipe_count +* splats. +*/ +static void rcu_torture_writer_work (struct work_struct *work) +{ +if (cur_ops->cb_barrier) + cur_ops->cb_barrier (); +} +/* * RCU torture writer kthread. Repeatedly substitutes a new structure * for that pointed to by rcu_torture_current, freeing the old structure @@ -1651,6 +1662,7 @@ rcu_torture_writer(void *arg)int i;int idx;unsigned long j; +struct work_struct lazy_work;int oldnice =task_nice (current);struct rcu_gp_oldstate *rgo =NULL ;int rgo_size =0 ;@@ -1667,6 +1679,7 @@ rcu_torture_writer(void *arg) stallsdone += (stall_cpu_holdoff + stall_gp_kthread + stall_cpu +60 ) *HZ * (stall_cpu_repeat +1 );VERBOSE_TOROUT_STRING ("rcu_torture_writer task started" ); +INIT_WORK_ONSTACK (&lazy_work, rcu_torture_writer_work);if (!can_expedite) pr_alert("%s" TORTURE_FLAG " GP expediting controlled from boot/sysfs for %s.\n",kernel/rcu/rcutorture.c rcu_torture_writer(void *arg) · line 1912
Quoted 5 lines
kernel/rcu/rcutorture.c +2
-0@@ -1895,6 +1908,8 @@ rcu_torture_writer(void *arg) !rcu_gp_is_normal (); } rcu_torture_writer_state =RTWS_STUTTER ; +if (IS_ENABLED (CONFIG_RCU_LAZY )) +queue_work (system_percpu_wq, &lazy_work);When the task ends, the
lazy_workshould be cancel and destroy:kernel/rcu/rcutorture.c +0
-0@@ -1682,7 +1682,6 @@ rcu_torture_writer(void *arg)stallsdone += (
stall_cpu_holdoff+stall_gp_kthread+stall_cpu+ 60) * HZ * (stall_cpu_repeat+ 1);VERBOSE_TOROUT_STRING("rcu_torture_writer task started");
-INIT_WORK_ONSTACK(&lazy_work, rcu_torture_writer_work);
if (!can_expedite)
pr_alert("%s"TORTURE_FLAG
" GP expediting controlled from boot/sysfs for %s.\n",kernel/rcu/rcutorture.c +2
-0@@ -1719,6 +1718,8 @@ rcu_torture_writer(void *arg)pr_alert ("%s" TORTURE_FLAG " Waited %lu jiffies for boot to complete.\n" , torture_type, jiffies - j); +INIT_WORK_ONSTACK (&lazy_work, rcu_torture_writer_work); + do { rcu_torture_writer_state = RTWS_FIXED_DELAY; torture_hrtimeout_us(500, 1000, &rand);@@ -1943,6 +1944,9 @@ rcu_torture_writer(void *arg)pr_alert("%s"
TORTURE_FLAGQuoted 9 lines
" Dynamic grace-period expediting was disabled.\n",
torture_type);
+ if (IS_ENABLED(CONFIG_RCU_LAZY))
+cancel_work_sync(&lazy_work);
+destroy_work_on_stack(&lazy_work); kfree(ulo);
kfree(rgo);rcu_torture_writer_state=RTWS_STOPPING;I agree, we seem miss destroying the work via
destroy_work_on_stack()and "sync" thelazy_workwork viacancel_work_sync().Quoted 1 line
Paul, any thoughts?
Good eyes!!! I will take a closer look tomorrow.
Quoted 8 lines
Quoted 6 lines
In the meantime, one question... Do we want to test for your new ->support_lazy instead of
IS_ENABLED(CONFIG_RCU_LAZY)for thatcancel_work_sync()anddestroy_work_on_stack()? If we really needIS_ENABLED(CONFIG_RCU_LAZY), could you please suggest a comment giving the reasoning?To me
IS_ENABLED(CONFIG_RCU_LAZY)is enough :) I am not sure we really need ->support_lazy flag.
Good point, given that the queue_work() is also guarded by that same IS_ENABLED(CONFIG_RCU_LAZY).
How does the patch below, based on the patch I sent initially, look?
I can fold it in and resend, or you can do so, your choice.
Thanx, Paul
------------------------------------------------------------------------
commit 68284a54b40f4fb1a6595fb9263aae47a56f20bb
Author: Paul E. McKenney <[email protected]> Date: Mon May 18 17:36:10 2026 -0700
squash! rcutorture: Fully test lazy RCU
[ paulmck: Apply Z qiang feedback. ]
kernel/rcu/rcutorture.c +6 -1
@@ -1682,7 +1682,6 @@ rcu_torture_writer(void *arg) stallsdone += (stall_cpu_holdoff + stall_gp_kthread + stall_cpu +60 ) *HZ * (stall_cpu_repeat +1 );VERBOSE_TOROUT_STRING ("rcu_torture_writer task started" ); -INIT_WORK_ONSTACK (&lazy_work, rcu_torture_writer_work);if (!can_expedite) pr_alert("%s" TORTURE_FLAG " GP expediting controlled from boot/sysfs for %s.\n",
@@ -1719,6 +1718,8 @@ rcu_torture_writer(void *arg)pr_alert ("%s" TORTURE_FLAG " Waited %lu jiffies for boot to complete.\n" , torture_type, jiffies - j); +if (IS_ENABLED (CONFIG_RCU_LAZY )) +INIT_WORK_ONSTACK (&lazy_work, rcu_torture_writer_work); do { rcu_torture_writer_state = RTWS_FIXED_DELAY; torture_hrtimeout_us(500, 1000, &rand);
@@ -1943,6 +1944,10 @@ rcu_torture_writer(void *arg)pr_alert ("%s" TORTURE_FLAG " Dynamic grace-period expediting was disabled.\n" , torture_type); +if (IS_ENABLED (CONFIG_RCU_LAZY )) { +cancel_work_sync (&lazy_work); +destroy_work_on_stack (&lazy_work); + }kfree (ulo);kfree (rgo); rcu_torture_writer_state =RTWS_STOPPING ;
Uladzislau Rezki
maintainerRe: [PATCH -next v1 01/12] rcutorture: Fully test lazy RCU
Quoted 224 lines · Paul E. McKenney
Quoted 170 lines · Uladzislau Rezki
Quoted 169 lines · Paul E. McKenney
Quoted 164 lines · Uladzislau Rezki
Quoted 151 lines · Z qiang
Quoted 15 lines
From: "Paul E. McKenney" <[email protected]>
Currently, rcutorture bypasses lazy RCU by using
call_rcu_hurry(). This works, avoiding the dreadedrtort_pipe_countWARN(), but fails to fully test lazy RCU. Thertort_pipe_countWARN()splats because lazy RCU could delay the start of an RCU grace period for a full stutter period, which defaults to only three seconds.This commit therefore reverts the
call_rcu_hurry()instances back tocall_rcu(), but, in kernels built withCONFIG_RCU_LAZY=y, queues a workqueue handler just before the call tostutter_wait()inrcu_torture_writer(). This workqueue handler invokesrcu_barrier(), which motivates any lingering lazy callbacks, thus avoiding the splat.Quoted 4 lines
Questions for review:
1. Should we avoid queueing work for RCU implementations not
supporting lazy callbacks?Hello, Paul
maybe we can do this:
rcu_ops= {
...
.support_lazy =IS_ENABLED(CONFIG_RCU_LAZY),
};and
if (
cur_ops->support_lazy)queue_work(..., &lazy_work);Quoted 85 lines
2. Should we avoid queueing work in kernels built with
CONFIG_RCU_LAZY=y, but that were not booted with the rcutree.enable_rcu_lazy kernel boot parameter set? (Note that this requires some ugliness to access this parameter, and must also handle Tiny RCU.)3. Does the
rcu_torture_opsstructure need a ->call_hurry() field,
and if so, why? If not, why not?4. Your additional questions here!
Reported-by Saravana Kannan <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Signed-off-by Uladzislau Rezki (Sony) <[email protected]>--- kernel/rcu/rcutorture.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)kernel/rcu/rcutorture.c +16
-3@@ -572,7 +572,7 @@ static unsigned long rcu_no_completed(void)static void rcu_torture_deferred_free (struct rcu_torture *p) { -call_rcu_hurry (&p->rtort_rcu, rcu_torture_cb); +call_rcu (&p->rtort_rcu, rcu_torture_cb); }static void rcu_sync_torture_init (void )@@ -619,7 +619,7 @@ static struct rcu_torture_ops rcu_ops = { .poll_gp_state_exp = poll_state_synchronize_rcu, .cond_sync_exp = cond_synchronize_rcu_expedited, .cond_sync_exp_full = cond_synchronize_rcu_expedited_full, - .call = call_rcu_hurry, + .call = call_rcu, .cb_barrier = rcu_barrier, .fqs = rcu_force_quiescent_state, .gp_kthread_dbg = show_rcu_gp_kthreads,@@ -1145,7 +1145,7 @@ static void rcu_tasks_torture_deferred_free(struct rcu_torture *p)static void synchronize_rcu_mult_test (void ) { -synchronize_rcu_mult (call_rcu_tasks, call_rcu_hurry); +synchronize_rcu_mult (call_rcu_tasks, call_rcu); }static struct rcu_torture_ops tasks_ops = {@@ -1631,6 +1631,17 @@ static void do_rtws_sync(struct torture_random_state *trsp, void (*sync)(void))cpus_read_unlock (); } +/* +* Do an rcu_barrier() to motivate lazy callbacks during a stutter +* pause. Without this, we can get false-positives rtort_pipe_count +* splats. +*/ +static void rcu_torture_writer_work (struct work_struct *work) +{ +if (cur_ops->cb_barrier) + cur_ops->cb_barrier (); +} +/* * RCU torture writer kthread. Repeatedly substitutes a new structure * for that pointed to by rcu_torture_current, freeing the old structure @@ -1651,6 +1662,7 @@ rcu_torture_writer(void *arg)int i;int idx;unsigned long j; +struct work_struct lazy_work;int oldnice =task_nice (current);struct rcu_gp_oldstate *rgo =NULL ;int rgo_size =0 ;@@ -1667,6 +1679,7 @@ rcu_torture_writer(void *arg) stallsdone += (stall_cpu_holdoff + stall_gp_kthread + stall_cpu +60 ) *HZ * (stall_cpu_repeat +1 );VERBOSE_TOROUT_STRING ("rcu_torture_writer task started" ); +INIT_WORK_ONSTACK (&lazy_work, rcu_torture_writer_work);if (!can_expedite) pr_alert("%s" TORTURE_FLAG " GP expediting controlled from boot/sysfs for %s.\n",kernel/rcu/rcutorture.c rcu_torture_writer(void *arg) · line 1912
Quoted 5 lines
kernel/rcu/rcutorture.c +2
-0@@ -1895,6 +1908,8 @@ rcu_torture_writer(void *arg) !rcu_gp_is_normal (); } rcu_torture_writer_state =RTWS_STUTTER ; +if (IS_ENABLED (CONFIG_RCU_LAZY )) +queue_work (system_percpu_wq, &lazy_work);When the task ends, the
lazy_workshould be cancel and destroy:kernel/rcu/rcutorture.c +0
-0@@ -1682,7 +1682,6 @@ rcu_torture_writer(void *arg)stallsdone += (
stall_cpu_holdoff+stall_gp_kthread+stall_cpu+ 60) * HZ * (stall_cpu_repeat+ 1);VERBOSE_TOROUT_STRING("rcu_torture_writer task started");
-INIT_WORK_ONSTACK(&lazy_work, rcu_torture_writer_work);
if (!can_expedite)
pr_alert("%s"TORTURE_FLAG
" GP expediting controlled from boot/sysfs for %s.\n",kernel/rcu/rcutorture.c +2
-0@@ -1719,6 +1718,8 @@ rcu_torture_writer(void *arg)pr_alert ("%s" TORTURE_FLAG " Waited %lu jiffies for boot to complete.\n" , torture_type, jiffies - j); +INIT_WORK_ONSTACK (&lazy_work, rcu_torture_writer_work); + do { rcu_torture_writer_state = RTWS_FIXED_DELAY; torture_hrtimeout_us(500, 1000, &rand);@@ -1943,6 +1944,9 @@ rcu_torture_writer(void *arg)pr_alert("%s"
TORTURE_FLAGQuoted 9 lines
" Dynamic grace-period expediting was disabled.\n",
torture_type);
+ if (IS_ENABLED(CONFIG_RCU_LAZY))
+cancel_work_sync(&lazy_work);
+destroy_work_on_stack(&lazy_work); kfree(ulo);
kfree(rgo);rcu_torture_writer_state=RTWS_STOPPING;I agree, we seem miss destroying the work via
destroy_work_on_stack()and "sync" thelazy_workwork viacancel_work_sync().Quoted 1 line
Paul, any thoughts?
Good eyes!!! I will take a closer look tomorrow.
Quoted 8 lines
Quoted 6 lines
In the meantime, one question... Do we want to test for your new ->support_lazy instead of
IS_ENABLED(CONFIG_RCU_LAZY)for thatcancel_work_sync()anddestroy_work_on_stack()? If we really needIS_ENABLED(CONFIG_RCU_LAZY), could you please suggest a comment giving the reasoning?To me
IS_ENABLED(CONFIG_RCU_LAZY)is enough :) I am not sure we really need ->support_lazy flag.Good point, given that the
queue_work()is also guarded by that sameIS_ENABLED(CONFIG_RCU_LAZY).How does the patch below, based on the patch I sent initially, look?
I can fold it in and resend, or you can do so, your choice.
Thanx, Paul
------------------------------------------------------------------------
commit
68284a54b40f4fb1a6595fb9263aae47a56f20bbAuthor: Paul E. McKenney <[email protected]> Date: Mon May 18 17:36:10 2026 -0700squash! rcutorture: Fully test lazy RCU
[ paulmck: Apply Z qiang feedback. ]
Signed-off-by Paul E. McKenney <[email protected]>kernel/rcu/rcutorture.c +2
-1@@ -1682,7 +1682,6 @@ rcu_torture_writer(void *arg) stallsdone += (stall_cpu_holdoff + stall_gp_kthread + stall_cpu +60 ) *HZ * (stall_cpu_repeat +1 );VERBOSE_TOROUT_STRING ("rcu_torture_writer task started" ); -INIT_WORK_ONSTACK (&lazy_work, rcu_torture_writer_work);if (!can_expedite) pr_alert("%s" TORTURE_FLAG " GP expediting controlled from boot/sysfs for %s.\n",@@ -1719,6 +1718,8 @@ rcu_torture_writer(void *arg)pr_alert ("%s" TORTURE_FLAG " Waited %lu jiffies for boot to complete.\n" , torture_type, jiffies - j); +if (IS_ENABLED (CONFIG_RCU_LAZY )) +INIT_WORK_ONSTACK (&lazy_work, rcu_torture_writer_work); do { rcu_torture_writer_state = RTWS_FIXED_DELAY; torture_hrtimeout_us(500, 1000, &rand);
kernel/rcu/rcutorture.c rcu_torture_writer(void *arg) · line 1953
Quoted 10 lines
kernel/rcu/rcutorture.c +4
-0@@ -1943,6 +1944,10 @@ rcu_torture_writer(void *arg)pr_alert ("%s" TORTURE_FLAG " Dynamic grace-period expediting was disabled.\n" , torture_type); +if (IS_ENABLED (CONFIG_RCU_LAZY )) { +cancel_work_sync (&lazy_work); +destroy_work_on_stack (&lazy_work); + }kfree (ulo);kfree (rgo); rcu_torture_writer_state =RTWS_STOPPING ;
I will fold it on my own, Paul!
--
Uladzislau Rezki
Uladzislau Rezki (Sony)
maintainerPATCH 2/12 torture: Add torture_sched_set_normal() for user-specified nice values
In reply to Uladzislau Rezki (Sony)From: "Paul E. McKenney" <[email protected]>
This new torture_sched_set_normal() function clamps the nice value at the MIN_NICE..MAX_NICE limits, splatting it these limits are exceeded. It then invokes sched_set_normal() to set the new value. This prevents more difficult-to-debug failures within the scheduler.
--- include/linux/torture.h | 1 + kernel/torture.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+)
include/linux/torture.h +1 -0
@@ -129,6 +129,7 @@ void _torture_stop_kthread(char *m, struct task_struct **tp);#else #define torture_preempt_schedule () do { } while (0)#endif +void torture_sched_set_normal (struct task_struct *t,int nice);#if IS_ENABLED (CONFIG_RCU_TORTURE_TEST ) ||IS_MODULE (CONFIG_RCU_TORTURE_TEST ) ||IS_ENABLED (CONFIG_LOCK_TORTURE_TEST ) ||IS_MODULE (CONFIG_LOCK_TORTURE_TEST )long torture_sched_setaffinity (pid_t pid,const struct cpumask *in_mask,bool dowarn);
kernel/torture.c +16 -0
@@ -972,3 +972,19 @@ void _torture_stop_kthread(char *m, struct task_struct **tp) *tp =NULL ; }EXPORT_SYMBOL_GPL (_torture_stop_kthread); + +/* +* Set the specified task's niceness value, saturating at limits. +* Saturating noisily, but saturating. +*/ +void torture_sched_set_normal (struct task_struct *t,int nice) +{ +int realnice = nice; + +if (WARN_ON_ONCE (realnice >MAX_NICE )) + realnice =MAX_NICE ; +if (WARN_ON_ONCE (realnice <MIN_NICE )) + realnice =MIN_NICE ; +sched_set_normal (t, realnice); +} +EXPORT_SYMBOL_GPL (torture_sched_set_normal);
Signature · 1 line
2.47.3
Uladzislau Rezki (Sony)
maintainerPATCH 3/12 torture: Improve kvm-series.sh header comment
In reply to Uladzislau Rezki (Sony)From: "Paul E. McKenney" <[email protected]>
The constraints on the arguments to kvm-series.sh are easy to forget, so this commit adds examples in the header comment.
--- tools/testing/selftests/rcutorture/bin/kvm-series.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-series.sh +6 -5
@@ -1,12 +1,13 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0+ # -# Usage: kvm-series.sh config-list commit-id-list [ kvm.sh parameters ] +# Usage: kvm-series.sh config-list commit-id-range [ kvm.sh parameters ] # -# Tests the specified list of unadorned configs ("TREE01 SRCU-P" but not -# "CFLIST" or "3*TRACE01") and an indication of a set of commits to test, -# then runs each commit through the specified list of commits using kvm.sh. -# The runs are grouped into a -series/config/commit directory tree. +# Tests the specified list of unadorned configs ("TREE01 SRCU-P" but +# not "CFLIST" or "3*TRACE01") and an indication of a range of commits +# ("v7.0-rc1..rcu/dev", but not "cd0ce7bab0408 ff74db28df623 17c52d7b31a1f") +# to test, then runs each commit through the specified list of commits using +# kvm.sh. The runs are grouped into a -series/config/commit directory tree. # Each run defaults to a duration of one minute. # # Run in top-level Linux source directory. Please note that this is in
Signature · 1 line
2.47.3
Uladzislau Rezki (Sony)
maintainerPATCH 4/12 torture: Allow "norm" abbreviation for "normal"
In reply to Uladzislau Rezki (Sony)From: "Paul E. McKenney" <[email protected]>
This adds "--do-norm", --do-no-norm", and "--no-norm" synonyms for the "--do-normal" group of torture.sh command-line arguments.
--- tools/testing/selftests/rcutorture/bin/torture.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/torture.sh +1 -1
@@ -184,7 +184,7 @@ do do_clocksourcewd=no do_srcu_lockdep=no ;; - --do-normal|--do-no-normal|--no-normal) + --do-normal|--do-norm|--do-no-normal|--do-no-norm|--no-normal|--no-norm) do_normal=`doyesno "$1" --do-normal` explicit_normal=yes ;;
Signature · 1 line
2.47.3
Uladzislau Rezki (Sony)
maintainerPATCH 5/12 srcu: Don't queue workqueue handlers to never-online CPUs
In reply to Uladzislau Rezki (Sony)From: "Paul E. McKenney" <[email protected]>
While an srcu_struct structure is in the midst of switching from CPU-0 to all-CPUs state, it can attempt to invoke callbacks for CPUs that have never been online. Worse yet, it can attempt in invoke callbacks for CPUs that never will be online, even including imaginary CPUs not in cpu_possible_mask. This can cause hangs on s390, which is not set up to deal with workqueue handlers being scheduled on such CPUs. This commit therefore causes Tree SRCU to refrain from queueing workqueue handlers on CPUs that have not yet (and might never) come online.
Because callbacks are not invoked on CPUs that have not been online, it is an error to invoke call_srcu(), synchronize_srcu(), or synchronize_srcu_expedited() on a CPU that is not yet fully online. However, it turns out to be less code to redirect the callbacks from too-early invocations of call_srcu() than to warn about such invocations. This commit therefore also redirects callbacks queued on not-yet-fully-online CPUs to the boot CPU.
--- kernel/rcu/srcutree.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
kernel/rcu/srcutree.c +6 -6
@@ -897,11 +897,9 @@ static void srcu_schedule_cbs_snp(struct srcu_struct *ssp, struct srcu_node *snp {int cpu; -for (cpu = snp->grplo; cpu <= snp->grphi; cpu++) { -if (!(mask & (1UL << (cpu - snp->grplo)))) -continue ; -srcu_schedule_cbs_sdp (per_cpu_ptr (ssp->sda, cpu), delay); - } +for (cpu = snp->grplo; cpu <= snp->grphi; cpu++) +if ((mask & (1UL << (cpu - snp->grplo))) &&rcu_cpu_beenfullyonline (cpu)) +srcu_schedule_cbs_sdp (per_cpu_ptr (ssp->sda, cpu), delay); }/*
@@ -1322,7 +1320,9 @@ static unsigned long srcu_gp_start_if_needed(struct srcu_struct *ssp,*/ idx =__srcu_read_lock_nmisafe (ssp); ss_state =smp_load_acquire (&ssp->srcu_sup->srcu_size_state); -if (ss_state <SRCU_SIZE_WAIT_CALL ) +// If !rcu_cpu_beenfullyonline(), interrupts are still disabled, +// so no migration is possible in either direction from this CPU. +if (ss_state <SRCU_SIZE_WAIT_CALL || !rcu_cpu_beenfullyonline (raw_smp_processor_id ())) sdp =per_cpu_ptr (ssp->sda,get_boot_cpu_id ());else sdp =raw_cpu_ptr (ssp->sda);
Signature · 1 line
2.47.3
Re: [PATCH -next v1 05/12] srcu: Don't queue workqueue handlers to never-online CPUs
Quoted 7 lines · Uladzislau Rezki (Sony)
From: "Paul E. McKenney" <[email protected]>
While an
srcu_structstructure is in the midst of switching from CPU-0 to all-CPUs state, it can attempt to invoke callbacks for CPUs that have never been online. Worse yet, it can attempt in invoke callbacks for CPUs that never will be online, even including imaginary CPUs not incpu_possible_mask. This can cause hangs on s390,
Uladzislau, Paul, according to the fixes tag below this change fixes a change that went into 7.0-rc6 -- and apparently causes a "hang" on some architectures. So shouldn't this be heading to mainline instead of -next? Ideally with a stable tag to ensure backporting to 7.0.y, but that is a separate decision?
I had an eye on this issue after noticing Samir's report:
https://lore.kernel.org/lkml/[email protected]/
And the jury is still out, but Jiri is dealing with some issues that might or might not be related to the problem this fixes, too:
https://lore.kernel.org/all/[email protected]/
Ciao, Thorsten
Quoted 55 lines
which is not set up to
deal with workqueue handlers being scheduled on such CPUs. This commit therefore causes Tree SRCU to refrain from queueing workqueue handlers on CPUs that have not yet (and might never) come online.Because callbacks are not invoked on CPUs that have not been online, it is an error to invoke
call_srcu(),synchronize_srcu(), orsynchronize_srcu_expedited()on a CPU that is not yet fully online. However, it turns out to be less code to redirect the callbacks from too-early invocations ofcall_srcu()than to warn about such invocations. This commit therefore also redirects callbacks queued on not-yet-fully-online CPUs to the boot CPU.Reported-by Vasily Gorbik <[email protected]>Fixes 61bbcfb50514 ("srcu: Push srcu_node allocation to GP when non-preemptible")Signed-off-by Paul E. McKenney <[email protected]>Tested-by Vasily Gorbik <[email protected]>Tested-by Samir <[email protected]>Reviewed-by Shrikanth Hegde <[email protected]>Cc Tejun Heo <[email protected]>Signed-off-by Uladzislau Rezki (Sony) <[email protected]>--- kernel/rcu/srcutree.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)kernel/rcu/srcutree.c +6
-6@@ -897,11 +897,9 @@ static void srcu_schedule_cbs_snp(struct srcu_struct *ssp, struct srcu_node *snp {int cpu; -for (cpu = snp->grplo; cpu <= snp->grphi; cpu++) { -if (!(mask & (1UL << (cpu - snp->grplo)))) -continue ; -srcu_schedule_cbs_sdp (per_cpu_ptr (ssp->sda, cpu), delay); - } +for (cpu = snp->grplo; cpu <= snp->grphi; cpu++) +if ((mask & (1UL << (cpu - snp->grplo))) &&rcu_cpu_beenfullyonline (cpu)) +srcu_schedule_cbs_sdp (per_cpu_ptr (ssp->sda, cpu), delay); }/* @@ -1322,7 +1320,9 @@ static unsigned long srcu_gp_start_if_needed(struct srcu_struct *ssp,*/ idx =__srcu_read_lock_nmisafe (ssp); ss_state =smp_load_acquire (&ssp->srcu_sup->srcu_size_state); -if (ss_state <SRCU_SIZE_WAIT_CALL ) +// If !rcu_cpu_beenfullyonline(), interrupts are still disabled, +// so no migration is possible in either direction from this CPU. +if (ss_state <SRCU_SIZE_WAIT_CALL || !rcu_cpu_beenfullyonline (raw_smp_processor_id ())) sdp =per_cpu_ptr (ssp->sda,get_boot_cpu_id ());else sdp =raw_cpu_ptr (ssp->sda);
Uladzislau Rezki
maintainerRe: [PATCH -next v1 05/12] srcu: Don't queue workqueue handlers to never-online CPUs
Quoted 9 lines · Thorsten Leemhuis
Quoted 7 lines · Uladzislau Rezki (Sony)
From: "Paul E. McKenney" <[email protected]>
While an
srcu_structstructure is in the midst of switching from CPU-0 to all-CPUs state, it can attempt to invoke callbacks for CPUs that have never been online. Worse yet, it can attempt in invoke callbacks for CPUs that never will be online, even including imaginary CPUs not incpu_possible_mask. This can cause hangs on s390,
Quoted 6 lines
Uladzislau, Paul, according to the fixes tag below this change fixes a change that went into 7.0-rc6 -- and apparently causes a "hang" on some architectures. So shouldn't this be heading to mainline instead of -next? Ideally with a stable tag to ensure backporting to 7.0.y, but that is a separate decision?
I assume it will be picked to stable since there is a "Fixes:" tag. From the other hand i can explicitly update commit message with Cc: [email protected]
Paul, any thoughts?
--
Uladzislau Rezki
Paul E. McKenney
maintainerRe: [PATCH -next v1 05/12] srcu: Don't queue workqueue handlers to never-online CPUs
Quoted 16 lines · Uladzislau Rezki
Quoted 9 lines · Thorsten Leemhuis
Quoted 7 lines · Uladzislau Rezki (Sony)
From: "Paul E. McKenney" <[email protected]>
While an
srcu_structstructure is in the midst of switching from CPU-0 to all-CPUs state, it can attempt to invoke callbacks for CPUs that have never been online. Worse yet, it can attempt in invoke callbacks for CPUs that never will be online, even including imaginary CPUs not incpu_possible_mask. This can cause hangs on s390,Quoted 6 lines
Uladzislau, Paul, according to the fixes tag below this change fixes a change that went into 7.0-rc6 -- and apparently causes a "hang" on some architectures. So shouldn't this be heading to mainline instead of -next? Ideally with a stable tag to ensure backporting to 7.0.y, but that is a separate decision?
Quoted 4 lines
I assume it will be picked to stable since there is a "Fixes:" tag. From the other hand i can explicitly update commit message with Cc: [email protected]
Paul, any thoughts?
The "Fixes" tag should cover it. But maybe Thorsten knows something that I do not?
Thanx, Paul
Re: [PATCH -next v1 05/12] srcu: Don't queue workqueue handlers to never-online CPUs
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · Uladzislau Rezki
Quoted 9 lines · Thorsten Leemhuis
Quoted 7 lines · Uladzislau Rezki (Sony)
From: "Paul E. McKenney" <[email protected]>
While an
srcu_structstructure is in the midst of switching from CPU-0 to all-CPUs state, it can attempt to invoke callbacks for CPUs that have never been online. Worse yet, it can attempt in invoke callbacks for CPUs that never will be online, even including imaginary CPUs not incpu_possible_mask. This can cause hangs on s390,
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Uladzislau, Paul, according to the fixes tag below this change fixes a change that went into 7.0-rc6 -- and apparently causes a "hang" on some architectures. So shouldn't this be heading to mainline instead of -next? Ideally with a stable tag to ensure backporting to 7.0.y, but that is a separate decision?
I assume it will be picked to stable
Thx for the reply. This answered the second aspect I raised. What about the first: shouldn't this be heading to mainline this cycle, ideally quite soon? Or is this the plan and I misinterpreted the "-next" in the subject?
Sadly Jiri (now CCed) afaics didn't yet report if this fix helped to fix the issues they were seeing, but it sounded a lot like it was likely:
https://lore.kernel.org/all/[email protected]/
Quoted 6 lines
Quoted 4 lines
since there is a "Fixes:" tag. From
the other hand i can explicitly update commit message with Cc: [email protected]Paul, any thoughts?
The "Fixes" tag should cover it.
Often it does, yes, but it might be silently dropped for one reason or another. So in the end only a stable tag will guarantee backporting attempt by the stable team.
Site note: I recently also tried to persuade Greg to also take those with a stable tag first in case there is a huge backlog.
Ciao, Thorsten
Boqun Feng
maintainerRe: [PATCH -next v1 05/12] srcu: Don't queue workqueue handlers to never-online CPUs
Quoted 12 lines · Thorsten Leemhuis
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · Uladzislau Rezki
Quoted 9 lines · Thorsten Leemhuis
Quoted 7 lines · Uladzislau Rezki (Sony)
From: "Paul E. McKenney" <[email protected]>
While an
srcu_structstructure is in the midst of switching from CPU-0 to all-CPUs state, it can attempt to invoke callbacks for CPUs that have never been online. Worse yet, it can attempt in invoke callbacks for CPUs that never will be online, even including imaginary CPUs not incpu_possible_mask. This can cause hangs on s390,
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Uladzislau, Paul, according to the fixes tag below this change fixes a change that went into 7.0-rc6 -- and apparently causes a "hang" on some architectures. So shouldn't this be heading to mainline instead of -next? Ideally with a stable tag to ensure backporting to 7.0.y, but that is a separate decision?
FWIW, I'm happy to create an urgent PR to Linus with this fix. Since it fixes a commit in the previous urgent fix PR from me. Ulad, let me know if you want me to do it.
Regards,
Boqun
Quoted 26 lines
Quoted 1 line
Quoted 1 line
I assume it will be picked to stable
Thx for the reply. This answered the second aspect I raised. What about the first: shouldn't this be heading to mainline this cycle, ideally quite soon? Or is this the plan and I misinterpreted the "-next" in the subject?
Sadly Jiri (now CCed) afaics didn't yet report if this fix helped to fix the issues they were seeing, but it sounded a lot like it was likely:
https://lore.kernel.org/all/[email protected]/Quoted 6 lines
Quoted 4 lines
since there is a "Fixes:" tag. From
the other hand i can explicitly update commit message with Cc: [email protected]Paul, any thoughts?
The "Fixes" tag should cover it.
Often it does, yes, but it might be silently dropped for one reason or another. So in the end only a stable tag will guarantee backporting attempt by the stable team.
Site note: I recently also tried to persuade Greg to also take those with a stable tag first in case there is a huge backlog.
Ciao, Thorsten
Uladzislau Rezki
maintainerRe: [PATCH -next v1 05/12] srcu: Don't queue workqueue handlers to never-online CPUs
Quoted 20 lines · Boqun Feng
Quoted 12 lines · Thorsten Leemhuis
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · Uladzislau Rezki
Quoted 9 lines · Thorsten Leemhuis
Quoted 7 lines · Uladzislau Rezki (Sony)
From: "Paul E. McKenney" <[email protected]>
While an
srcu_structstructure is in the midst of switching from CPU-0 to all-CPUs state, it can attempt to invoke callbacks for CPUs that have never been online. Worse yet, it can attempt in invoke callbacks for CPUs that never will be online, even including imaginary CPUs not incpu_possible_mask. This can cause hangs on s390,Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Uladzislau, Paul, according to the fixes tag below this change fixes a change that went into 7.0-rc6 -- and apparently causes a "hang" on some architectures. So shouldn't this be heading to mainline instead of -next? Ideally with a stable tag to ensure backporting to 7.0.y, but that is a separate decision?
Quoted 4 lines
FWIW, I'm happy to create an urgent PR to Linus with this fix. Since it fixes a commit in the previous urgent fix PR from me. Ulad, let me know if you want me to do it.
I do not mind :) So i can drop this patch!
--
Uladzislau Rezki
Boqun Feng
maintainerRe: [PATCH -next v1 05/12] srcu: Don't queue workqueue handlers to never-online CPUs
Quoted 21 lines · Uladzislau Rezki
Quoted 20 lines · Boqun Feng
Quoted 18 lines · Thorsten Leemhuis
Quoted 17 lines · Paul E. McKenney
Quoted 16 lines · Uladzislau Rezki
Quoted 15 lines · Thorsten Leemhuis
Quoted 7 lines · Uladzislau Rezki (Sony)
From: "Paul E. McKenney" <[email protected]>
While an
srcu_structstructure is in the midst of switching from CPU-0 to all-CPUs state, it can attempt to invoke callbacks for CPUs that have never been online. Worse yet, it can attempt in invoke callbacks for CPUs that never will be online, even including imaginary CPUs not incpu_possible_mask. This can cause hangs on s390,Uladzislau, Paul, according to the fixes tag below this change fixes a change that went into 7.0-rc6 -- and apparently causes a "hang" on some architectures. So shouldn't this be heading to mainline instead of -next? Ideally with a stable tag to ensure backporting to 7.0.y, but that is a separate decision?
Quoted 6 lines
Quoted 4 lines
FWIW, I'm happy to create an urgent PR to Linus with this fix. Since it fixes a commit in the previous urgent fix PR from me. Ulad, let me know if you want me to do it.
I do not mind :) So i can drop this patch!
Alright, I created the fix branch at:
https://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux.git/log/?h=fixes.v7.1
And I'm going to throw some tests on it. Will send the pull request tomorrow.
Regards,
Boqun
Quoted 2 lines
--
Uladzislau Rezki
Uladzislau Rezki
maintainerRe: [PATCH -next v1 05/12] srcu: Don't queue workqueue handlers to never-online CPUs
Quoted 29 lines · Boqun Feng
Quoted 21 lines · Uladzislau Rezki
Quoted 20 lines · Boqun Feng
Quoted 18 lines · Thorsten Leemhuis
Quoted 17 lines · Paul E. McKenney
Quoted 16 lines · Uladzislau Rezki
Quoted 15 lines · Thorsten Leemhuis
Quoted 7 lines · Uladzislau Rezki (Sony)
From: "Paul E. McKenney" <[email protected]>
While an
srcu_structstructure is in the midst of switching from CPU-0 to all-CPUs state, it can attempt to invoke callbacks for CPUs that have never been online. Worse yet, it can attempt in invoke callbacks for CPUs that never will be online, even including imaginary CPUs not incpu_possible_mask. This can cause hangs on s390,Uladzislau, Paul, according to the fixes tag below this change fixes a change that went into 7.0-rc6 -- and apparently causes a "hang" on some architectures. So shouldn't this be heading to mainline instead of -next? Ideally with a stable tag to ensure backporting to 7.0.y, but that is a separate decision?
Quoted 6 lines
Quoted 4 lines
FWIW, I'm happy to create an urgent PR to Linus with this fix. Since it fixes a commit in the previous urgent fix PR from me. Ulad, let me know if you want me to do it.
I do not mind :) So i can drop this patch!
Quoted 7 lines
Alright, I created the fix branch at:
https://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux.git/log/?h=fixes.v7.1And I'm going to throw some tests on it. Will send the pull request tomorrow.
Cool, then i drop this patch!
--
Uladzislau Rezki
Re: [PATCH -next v1 05/12] srcu: Don't queue workqueue handlers to never-online CPUs
In reply to Boqun FengQuoted 10 lines · Boqun Feng
Quoted 10 lines
Quoted 1 line
Quoted 1 line
I assume it will be picked to stable
Thx for the reply. This answered the second aspect I raised. What about the first: shouldn't this be heading to mainline this cycle, ideally quite soon? Or is this the plan and I misinterpreted the "-next" in the subject?
Sadly Jiri (now CCed) afaics didn't yet report if this fix helped to fix the issues they were seeing, but it sounded a lot like it was likely:
https://lore.kernel.org/all/[email protected]/
Yes, it did!
You could have checked the linked bug, BTW:
https://bugzilla.suse.com/show_bug.cgi?id=1263947#c19
Quoted 1 line
works nicely without complaining about non-existant CPUs
and:
Quoted 1 line
seems stopped messages about workqueue lockup and not exist CPUs at kernel 7.0.7-1-default now
But:
Quoted 1 line
FYI the power8 machine hangs using 7.0.7-2.gf1d450c-default, to be investigated.
That's likely not related.
thanks,
Signature · 2 lines
js suse labs
Uladzislau Rezki (Sony)
maintainerPATCH 6/12 srcu: Fix kerneldoc header comment typo in srcu_down_read_fast()
In reply to Uladzislau Rezki (Sony)From: "Paul E. McKenney" <[email protected]>
s/srcu_read_lock_safe()/srcu_read_lock_fast_updown(), there being no such thing as srcu_read_lock_safe().
--- include/linux/srcu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/srcu.h +1 -1
@@ -397,7 +397,7 @@ static inline struct srcu_ctr __percpu *srcu_read_lock_fast_notrace(struct srcu_* * The same srcu_struct may be used concurrently by srcu_down_read_fast() * and srcu_read_lock_fast(). However, the same definition/initialization -* requirements called out for srcu_read_lock_safe() apply. +* requirements called out for srcu_read_lock_fast_updown() apply. */ static inline struct srcu_ctr __percpu *srcu_down_read_fast (struct srcu_struct *ssp)__acquires_shared (ssp) {
Signature · 1 line
2.47.3
Uladzislau Rezki (Sony)
maintainerPATCH 7/12 checkpatch: Undeprecate rcu_read_lock_trace() and rcu_read_unlock_trace()
In reply to Uladzislau Rezki (Sony)From: "Paul E. McKenney" <[email protected]>
It turns out that there are BPF use cases that rely on nesting RCU Tasks Trace readers. These use cases are well-served by the old rcu_read_lock_trace() and rcu_read_unlock_trace() functions that maintain a nesting counter in the task_struct structure. But these use cases incur a performance penalty when using the shiny new rcu_read_lock_tasks_trace() and rcu_read_unlock_tasks_trace() functions, which nest in the same way that SRCU does.
This means that rcu_read_lock_trace() and rcu_read_unlock_trace() will be with us for some time. Therefore, remove the checkpatch.pl deprecation.
Also, the rcu_read_lock_tasks_trace() and rcu_read_unlock_tasks_trace() functions are intended for use only by BPF. Therefore, add them to the list of functions that checkpatch complains about outside of BPF (and of course, RCU).
--- scripts/checkpatch.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +3 -2
@@ -865,8 +865,6 @@ our %deprecated_apis = ( "DEFINE_IDR" => "DEFINE_XARRAY", "idr_init" => "xa_init", "idr_init_base" => "xa_init_flags", - "rcu_read_lock_trace" => "rcu_read_lock_tasks_trace", - "rcu_read_unlock_trace" => "rcu_read_unlock_tasks_trace", ); #Create a search pattern for all these strings to speed up a loop below
@@ -7596,12 +7594,15 @@ sub process { # Complain about RCU Tasks Trace used outside of BPF (and of course, RCU). our $rcu_trace_funcs = qr{(?x: + rcu_read_lock_tasks_trace | rcu_read_lock_trace | rcu_read_lock_trace_held | rcu_read_unlock_trace | + rcu_read_unlock_tasks_trace | call_rcu_tasks_trace | synchronize_rcu_tasks_trace | rcu_barrier_tasks_trace | + rcu_tasks_trace_expedite_current | rcu_request_urgent_qs_task )}; our $rcu_trace_paths = qr{(?x:
Signature · 1 line
2.47.3
Uladzislau Rezki (Sony)
maintainerPATCH 8/12 rcu: Simplify rcu_do_batch() by applying clamp()
In reply to Uladzislau Rezki (Sony)From: "Paul E. McKenney" <[email protected]>
This commit replaces a nested ?: sequence with clamp(). This does not reduce the number of lines of code, but it does simplify the line that it modifies.
--- kernel/rcu/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree.c +1 -1
@@ -2584,7 +2584,7 @@ static void rcu_do_batch(struct rcu_data *rdp)const long npj =NSEC_PER_SEC /HZ ;long rrn =READ_ONCE (rcu_resched_ns); - rrn = rrn <NSEC_PER_MSEC ?NSEC_PER_MSEC : rrn >NSEC_PER_SEC ?NSEC_PER_SEC : rrn; + rrn =clamp (rrn,NSEC_PER_MSEC ,NSEC_PER_SEC ); tlimit =local_clock () + rrn; jlimit = jiffies + (rrn + npj +1 ) / npj; jlimit_check = true;
Signature · 1 line
2.47.3
Uladzislau Rezki (Sony)
maintainerPATCH 9/12 rcu: Simplify param_set_next_fqs_jiffies() by applying clamp_val()
In reply to Uladzislau Rezki (Sony)From: "Paul E. McKenney" <[email protected]>
This commit replaces a nested ?: sequence with clamp_val(). This does not reduce the number of lines of code, but it does simplify the line that it modifies.
--- kernel/rcu/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree.c +1 -1
@@ -492,7 +492,7 @@ static int param_set_next_fqs_jiffies(const char *val, const struct kernel_paramint ret =kstrtoul (val,0 , &j);if (!ret) { -WRITE_ONCE (*(ulong *)kp->arg, (j >HZ ) ?HZ : (j ?:1 )); +WRITE_ONCE (*(ulong *)kp->arg,clamp_val (j,1 ,HZ ));adjust_jiffies_till_sched_qs (); }return ret;
Signature · 1 line
2.47.3
Uladzislau Rezki (Sony)
maintainerPATCH 10/12 rcu: Document rcu_access_pointer() feeding into cmpxchg()
In reply to Uladzislau Rezki (Sony)From: "Paul E. McKenney" <[email protected]>
This commit documents the rcu_access_pointer() use case for fetching the old value of an RCU-protected pointer within a lockless updater for use by an atomic cmpxchg() operation.
--- include/linux/rcupdate.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
include/linux/rcupdate.h +7 -5
@@ -592,11 +592,13 @@ context_unsafe( \* lockdep checks for being in an RCU read-side critical section. This is * useful when the value of this pointer is accessed, but the pointer is * not dereferenced, for example, when testing an RCU-protected pointer -* against NULL. Although rcu_access_pointer() may also be used in cases -* where update-side locks prevent the value of the pointer from changing, -* you should instead use rcu_dereference_protected() for this use case. -* Within an RCU read-side critical section, there is little reason to -* use rcu_access_pointer(). +* against NULL. Within an RCU read-side critical section, there is little +* reason to use rcu_access_pointer(). Although rcu_access_pointer() may +* also be used in cases where update-side locks prevent the value of the +* pointer from changing, you should instead use rcu_dereference_protected() +* for this use case. It is also permissible to use rcu_access_pointer() +* within lockless updaters to obtain the old value for an atomic operation, +* for example, for cmpxchg(). * * It is usually best to test the rcu_access_pointer() return value * directly in order to avoid accidental dereferences being introduced
Signature · 1 line
2.47.3
Uladzislau Rezki (Sony)
maintainerPATCH 11/12 rcu: Latch normal synchronize_rcu() path on flood
In reply to Uladzislau Rezki (Sony)Currently, rcu_normal_wake_from_gp is only enabled by default on small systems(<= 16 CPUs) or when a user explicitly set it enabled.
Introduce an adaptive latching mechanism:
* Track the number of in-flight synchronize_rcu() requests using a new rcu_sr_normal_count counter;
* If the count reaches/exceeds RCU_SR_NORMAL_LATCH_THR(64), it sets the rcu_sr_normal_latched, reverting new requests onto the scaled wait_rcu_gp() path;
* The latch is cleared only when the pending requests are fully drained(nr == 0);
* Enables rcu_normal_wake_from_gp by default for all systems, relying on this dynamic throttling instead of static CPU limits.
Testing(synthetic flood workload):
* Kernel version: 6.19.0-rc6
* Number of CPUs: 1536
* 60K concurrent synchronize_rcu() calls
Perf(cycles, system-wide):
total cycles: 932020263832 rcu_sr_normal_add_req(): 2650282811 cycles(~0.28%)
Perf report excerpt:
0.01% 0.01% sync_test/... [k] rcu_sr_normal_add_req
Measured overhead of rcu_sr_normal_add_req() remained ~0.28% of total CPU cycles in this synthetic stress test.
--- .../admin-guide/kernel-parameters.txt | 10 ++-- kernel/rcu/tree.c | 52 ++++++++++++++----- 2 files changed, 44 insertions(+), 18 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +5 -5
@@ -5862,13 +5862,13 @@ Kernel parameters use a call_rcu[_hurry]() path. Please note, this is for a normal grace period. - How to enable it: + How to disable it: - echo 1 > /sys/module/rcutree/parameters/rcu_normal_wake_from_gp - or pass a boot parameter "rcutree.rcu_normal_wake_from_gp=1" + echo 0 > /sys/module/rcutree/parameters/rcu_normal_wake_from_gp + or pass a boot parameter "rcutree.rcu_normal_wake_from_gp=0" - Default is 1 if num_possible_cpus() <= 16 and it is not explicitly - disabled by the boot parameter passing 0. + Default is 1 if it is not explicitly disabled by the boot parameter + passing 0. rcuscale.gp_async= [KNL] Measure performance of asynchronous
kernel/rcu/tree.c +39 -13
104 lines not on this page · raw message
Signature · 1 line
2.47.3
Uladzislau Rezki (Sony)
maintainerPATCH 12/12 rcu-tasks: Fix possible boot-time tests failed for the call_rcu_tasks()
In reply to Uladzislau Rezki (Sony)From: Zqiang <[email protected]>
The following scenarios will cause the call_rcu_tasks() boot-time tests failed:
CPU0 CPU1
rcu_init_tasks_generic() ->rcu_tasks_initiate_self_tests()
->call_rcu_tasks_trace(&tests[1].rh, test_rcu_tasks_callback)
->call_rcu_tasks_generic()
->havekthread = smp_load_acquire(&rtp->kthread_ptr)
"The havekthread is false"
....
rcu_tasks_kthread()
->smp_store_release(&rtp->kthread_ptr, current)
->rcu_tasks_one_gp()
->rcuwait_wait_event()
->rcu_tasks_need_gpcb()
->for (cpu = 0; cpu < dequeue_limit; cpu++)
->rcu_segcblist_n_cbs(&rtpcp->cblist) == 0
->schedule()
->raw_spin_trylock_rcu_node()
->needwake = (func == wakeme_after_rcu) ||
(rcu_segcblist_n_cbs(&rtpcp->cblist) == rcu_task_lazy_lim)
"the rcu_task_lazy_lim default value is 32, and the
func pointer is test_rcu_tasks_callback, lead to needwake
is false."
->if (havekthread && !needwake && !timer_pending(&rtpcp->lazy_timer))
"the havekthread is false, will not enter here."
....
"the needwake is false lead to rtp_irq_work can not queue,
even if the rtp->kthread_ptr already exists at this point."
->if (needwake && READ_ONCE(rtp->kthread_ptr))
->irq_work_queue(&rtpcp->rtp_irq_work)For the above scenarios, if the call_rcu_tasks() is not called again afterward, the rcu_tasks_kthread will not have a chance to be wakeup, the test_rcu_tasks_callback() will never be called, the boot-time tests failed can happen, this commit therefore check havekthread variable, if it's false and the rtpcp->cblist is empty, set needwake variable is true, if the rtp->kthread_ptr exist, the rtpcp->rtp_irq_work can be queued to wakeup rcu_tasks_kthread.
--- kernel/rcu/tasks.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcu/tasks.h +2 -1
@@ -373,7 +373,8 @@ static void call_rcu_tasks_generic(struct rcu_head *rhp, rcu_callback_t func,// Queuing callbacks before initialization not yet supported. if (WARN_ON_ONCE (!rcu_segcblist_is_enabled (&rtpcp->cblist)))rcu_segcblist_init (&rtpcp->cblist); - needwake = (func == wakeme_after_rcu) || + needwake = (!havekthread &&rcu_segcblist_empty (&rtpcp->cblist)) || + (func == wakeme_after_rcu) || (rcu_segcblist_n_cbs (&rtpcp->cblist) == rcu_task_lazy_lim);if (havekthread && !needwake && !timer_pending (&rtpcp->lazy_timer)) {if (rtp->lazy_jiffies)
Signature · 1 line
2.47.3