Re: [PATCH 1/2] rcuscale: add kfree_rcu() single-argument scale test
From: Paul E. McKenney
Date: Thu Feb 04 2021 - 16:49:21 EST
On Fri, Jan 29, 2021 at 09:05:04PM +0100, Uladzislau Rezki (Sony) wrote:
> 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.
>
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@xxxxxxxxx>
This is a great addition, but it would be even better if there was
a way to say "test both in one run". One way to do this is to have
torture_param() variables for both kfree_rcu_test_single and (say)
kfree_rcu_test_double, both bool and both initialized to false. If both
have the same value (false or true) both are 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.
See the gp_cond, gp_exp, gp_normal, gp_poll, and gp_sync torture_param()
variables in kernel/rcu/rcutorture.c and how they are handled in
rcu_torture_write_types() for one way to do this.
If you wanted to vary the intensity of the testing (but I don't see why
this would be useful), the various weight_* torture_param() variables
are dealt with by kernel/scftorture.c in scf_torture_init().
Thoughts?
Thanx, Paul
> ---
> kernel/rcu/rcuscale.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/rcu/rcuscale.c b/kernel/rcu/rcuscale.c
> index 06491d5530db..e17745a155f9 100644
> --- a/kernel/rcu/rcuscale.c
> +++ b/kernel/rcu/rcuscale.c
> @@ -94,6 +94,7 @@ torture_param(bool, shutdown, RCUSCALE_SHUTDOWN,
> torture_param(int, verbose, 1, "Enable verbose debugging printk()s");
> torture_param(int, writer_holdoff, 0, "Holdoff (us) between GPs, zero to disable");
> torture_param(int, kfree_rcu_test, 0, "Do we run a kfree_rcu() scale test?");
> +torture_param(int, kfree_rcu_test_single, 0, "Do we run a kfree_rcu() single-argument scale test?");
> torture_param(int, kfree_mult, 1, "Multiple of kfree_obj size to allocate.");
>
> static char *scale_type = "rcu";
> @@ -667,10 +668,14 @@ kfree_scale_thread(void *arg)
>
> for (i = 0; i < kfree_alloc_num; i++) {
> alloc_ptr = kmalloc(kfree_mult * sizeof(struct kfree_obj), GFP_KERNEL);
> +
> if (!alloc_ptr)
> return -ENOMEM;
>
> - kfree_rcu(alloc_ptr, rh);
> + if (kfree_rcu_test_single)
> + kfree_rcu(alloc_ptr);
> + else
> + kfree_rcu(alloc_ptr, rh);
> }
>
> cond_resched();
> --
> 2.20.1
>