rcuscale: add kfree_rcu() single-argument scale test
Subsystems (2)
Uladzislau Rezki (Sony)
maintainerPATCH v3 1/1 rcuscale: add kfree_rcu() single-argument scale test
To stress and test a single argument of kfree_rcu() call, we should to have a special coverage for it. We used to have it in the test-suite related to vmalloc stressing. The reason is the rcuscale is a correct place for RCU related things.
Therefore introduce two torture_param() variables, one is for single-argument scale test and another one for double-argument scale test.
By default kfree_rcu_test_single and kfree_rcu_test_double are initialized to false. If both have the same value (false or true) both are randomly tested, otherwise only the one with value true is tested. The value of this is that it allows testing of both options with one test.
--- kernel/rcu/rcuscale.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
kernel/rcu/rcuscale.c +14 -1
@@ -625,6 +625,8 @@ rcu_scale_shutdown(void *arg)torture_param (int, kfree_nthreads,-1 ,"Number of threads running loops of kfree_rcu()." );torture_param (int, kfree_alloc_num,8000 ,"Number of allocations and frees done in an iteration." );torture_param (int, kfree_loops,10 ,"Number of loops doing kfree_alloc_num allocations and frees." ); +torture_param (bool, kfree_rcu_test_single, false,"Do we run a kfree_rcu() single-argument scale test?" ); +torture_param (bool, kfree_rcu_test_double, false,"Do we run a kfree_rcu() double-argument scale test?" );static struct task_struct **kfree_reader_tasks;static int kfree_nrealthreads;
@@ -644,10 +646,13 @@ kfree_scale_thread(void *arg)struct kfree_obj *alloc_ptr;u64 start_time, end_time;long long mem_begin, mem_during =0 ; +bool kfree_rcu_test_both; +DEFINE_TORTURE_RANDOM (tr);VERBOSE_SCALEOUT_STRING ("kfree_scale_thread task started" );set_cpus_allowed_ptr (current,cpumask_of (me % nr_cpu_ids));set_user_nice (current,MAX_NICE ); + kfree_rcu_test_both = (kfree_rcu_test_single == kfree_rcu_test_double); start_time =ktime_get_mono_fast_ns ();
@@ -670,7 +675,15 @@ kfree_scale_thread(void *arg)if (!alloc_ptr)return -ENOMEM ; -kfree_rcu (alloc_ptr, rh); +// By default kfree_rcu_test_single and kfree_rcu_test_double are +// initialized to false. If both have the same value (false or true) +// both are randomly tested, otherwise only the one with value true +// is tested. +if ((kfree_rcu_test_single && !kfree_rcu_test_double) || + (kfree_rcu_test_both &&torture_random (&tr) &0x800 )) +kfree_rcu (alloc_ptr); +else +kfree_rcu (alloc_ptr, rh); }cond_resched ();
Signature · 1 line
2.20.1
Quoted 9 lines · Uladzislau Rezki (Sony)
To stress and test a single argument of
kfree_rcu()call, we should to have a special coverage for it. We used to have it in the test-suite related to vmalloc stressing. The reason is the rcuscale is a correct place for RCU related things.Therefore introduce two
torture_param()variables, one is for single-argument scale test and another one for double-argument scale test.
Quoted 8 lines
By default
kfree_rcu_test_singleandkfree_rcu_test_doubleare initialized to false. If both have the same value (false or true) both are randomly tested, otherwise only the one with value true is tested. The value of this is that it allows testing of both options with one test.Suggested-by Paul E. McKenney <[email protected]>Signed-off-by Uladzislau Rezki (Sony) <[email protected]>
Queued with the usual wordsmithing, thank you!
Thanx, Paul
Quoted 51 lines
--- kernel/rcu/rcuscale.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)kernel/rcu/rcuscale.c +14
-1@@ -625,6 +625,8 @@ rcu_scale_shutdown(void *arg)torture_param (int, kfree_nthreads,-1 ,"Number of threads running loops of kfree_rcu()." );torture_param (int, kfree_alloc_num,8000 ,"Number of allocations and frees done in an iteration." );torture_param (int, kfree_loops,10 ,"Number of loops doing kfree_alloc_num allocations and frees." ); +torture_param (bool, kfree_rcu_test_single, false,"Do we run a kfree_rcu() single-argument scale test?" ); +torture_param (bool, kfree_rcu_test_double, false,"Do we run a kfree_rcu() double-argument scale test?" );static struct task_struct **kfree_reader_tasks;static int kfree_nrealthreads;@@ -644,10 +646,13 @@ kfree_scale_thread(void *arg)struct kfree_obj *alloc_ptr;u64 start_time, end_time;long long mem_begin, mem_during =0 ; +bool kfree_rcu_test_both; +DEFINE_TORTURE_RANDOM (tr);VERBOSE_SCALEOUT_STRING ("kfree_scale_thread task started" );set_cpus_allowed_ptr (current,cpumask_of (me % nr_cpu_ids));set_user_nice (current,MAX_NICE ); + kfree_rcu_test_both = (kfree_rcu_test_single == kfree_rcu_test_double); start_time =ktime_get_mono_fast_ns ();@@ -670,7 +675,15 @@ kfree_scale_thread(void *arg)if (!alloc_ptr)return -ENOMEM ; -kfree_rcu (alloc_ptr, rh); +// By default kfree_rcu_test_single and kfree_rcu_test_double are +// initialized to false. If both have the same value (false or true) +// both are randomly tested, otherwise only the one with value true +// is tested. +if ((kfree_rcu_test_single && !kfree_rcu_test_double) || + (kfree_rcu_test_both &&torture_random (&tr) &0x800 )) +kfree_rcu (alloc_ptr); +else +kfree_rcu (alloc_ptr, rh); }cond_resched ();Signature · 1 line
2.20.1