Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rcutorture: Allow a negative value for nfakewriters

Currently "nfakewriters" parameter can be set to any value but
there is no possibility to adjust it automatically based on how
many CPUs a system has where a test is run on.

To address this, if the "nfakewriters" is set to negative it will
be adjusted to num_online_cpus() during torture initialization.

Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Link: https://lore.kernel.org/r/20250227131613.52683-1-urezki@gmail.com
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>

authored by

Uladzislau Rezki (Sony) and committed by
Boqun Feng
8d67c155 6ea9a178

+16 -6
+16 -6
kernel/rcu/rcutorture.c
··· 147 147 148 148 static int nrealnocbers; 149 149 static int nrealreaders; 150 + static int nrealfakewriters; 150 151 static struct task_struct *writer_task; 151 152 static struct task_struct **fakewriter_tasks; 152 153 static struct task_struct **reader_tasks; ··· 1729 1728 do { 1730 1729 torture_hrtimeout_jiffies(torture_random(&rand) % 10, &rand); 1731 1730 if (cur_ops->cb_barrier != NULL && 1732 - torture_random(&rand) % (nfakewriters * 8) == 0) { 1731 + torture_random(&rand) % (nrealfakewriters * 8) == 0) { 1733 1732 cur_ops->cb_barrier(); 1734 1733 } else { 1735 1734 switch (synctype[torture_random(&rand) % nsynctypes]) { ··· 2523 2522 "nocbs_nthreads=%d nocbs_toggle=%d " 2524 2523 "test_nmis=%d " 2525 2524 "preempt_duration=%d preempt_interval=%d\n", 2526 - torture_type, tag, nrealreaders, nfakewriters, 2525 + torture_type, tag, nrealreaders, nrealfakewriters, 2527 2526 stat_interval, verbose, test_no_idle_hz, shuffle_interval, 2528 2527 stutter, irqreader, fqs_duration, fqs_holdoff, fqs_stutter, 2529 2528 test_boost, cur_ops->can_boost, ··· 3598 3597 rcu_torture_reader_mbchk = NULL; 3599 3598 3600 3599 if (fakewriter_tasks) { 3601 - for (i = 0; i < nfakewriters; i++) 3600 + for (i = 0; i < nrealfakewriters; i++) 3602 3601 torture_stop_kthread(rcu_torture_fakewriter, 3603 3602 fakewriter_tasks[i]); 3604 3603 kfree(fakewriter_tasks); ··· 3995 3994 3996 3995 rcu_torture_init_srcu_lockdep(); 3997 3996 3997 + if (nfakewriters >= 0) { 3998 + nrealfakewriters = nfakewriters; 3999 + } else { 4000 + nrealfakewriters = num_online_cpus() - 2 - nfakewriters; 4001 + if (nrealfakewriters <= 0) 4002 + nrealfakewriters = 1; 4003 + } 4004 + 3998 4005 if (nreaders >= 0) { 3999 4006 nrealreaders = nreaders; 4000 4007 } else { ··· 4059 4050 writer_task); 4060 4051 if (torture_init_error(firsterr)) 4061 4052 goto unwind; 4062 - if (nfakewriters > 0) { 4063 - fakewriter_tasks = kcalloc(nfakewriters, 4053 + 4054 + if (nrealfakewriters > 0) { 4055 + fakewriter_tasks = kcalloc(nrealfakewriters, 4064 4056 sizeof(fakewriter_tasks[0]), 4065 4057 GFP_KERNEL); 4066 4058 if (fakewriter_tasks == NULL) { ··· 4070 4060 goto unwind; 4071 4061 } 4072 4062 } 4073 - for (i = 0; i < nfakewriters; i++) { 4063 + for (i = 0; i < nrealfakewriters; i++) { 4074 4064 firsterr = torture_create_kthread(rcu_torture_fakewriter, 4075 4065 NULL, fakewriter_tasks[i]); 4076 4066 if (torture_init_error(firsterr))