diff mbox series

[v3] rcutorture: Create nocb tasks only for CONFIG_RCU_NOCB_CPU=y kernels

Message ID 20230203014021.3408798-1-qiang1.zhang@intel.com (mailing list archive)
State Accepted
Commit 38c1e8adc5c51fdd2acb9c4362765e78fed2979b
Headers show
Series [v3] rcutorture: Create nocb tasks only for CONFIG_RCU_NOCB_CPU=y kernels | expand

Commit Message

Zqiang Feb. 3, 2023, 1:40 a.m. UTC
When setting nocbs_nthreads to start rcutorture test with a non-zero value,
the nocb tasks will be created and invoke rcu_nocb_cpu_offload/deoffload()
to toggle CPU's callback-offload state, but for CONFIG_RCU_NOCB_CPU=n
kernel, the rcu_nocb_cpu_offload/deoffload() is a no-op and this is also
meaningless for torture_type is non-rcu.

This commit therefore add member can_nocbs_toggle to rcu_torture_ops
structure to avoid unnecessary nocb tasks creation.

Signed-off-by: Zqiang <qiang1.zhang@intel.com>
---
 kernel/rcu/rcutorture.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Zqiang Feb. 3, 2023, 6:38 a.m. UTC | #1
>When setting nocbs_nthreads to start rcutorture test with a non-zero value,
>the nocb tasks will be created and invoke rcu_nocb_cpu_offload/deoffload()
>to toggle CPU's callback-offload state, but for CONFIG_RCU_NOCB_CPU=n
>kernel, the rcu_nocb_cpu_offload/deoffload() is a no-op and this is also
>meaningless for torture_type is non-rcu.
>
>This commit therefore add member can_nocbs_toggle to rcu_torture_ops
>structure to avoid unnecessary nocb tasks creation.

Will change commit log next version.

Thanks
Zqiang

>
>Signed-off-by: Zqiang <qiang1.zhang@intel.com>
>---
> kernel/rcu/rcutorture.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
>diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
>index 297da28ce92d..d01127e0e8cd 100644
>--- a/kernel/rcu/rcutorture.c
>+++ b/kernel/rcu/rcutorture.c
>@@ -3708,6 +3708,12 @@ rcu_torture_init(void)
> 		pr_alert("rcu-torture: ->fqs NULL and non-zero fqs_duration, fqs disabled.\n");
> 		fqs_duration = 0;
> 	}
>+	if (nocbs_nthreads != 0 && (cur_ops != &rcu_ops ||
>+					!IS_ENABLED(CONFIG_RCU_NOCB_CPU))) {
>+		pr_alert("rcu-torture types: %s and CONFIG_RCU_NOCB_CPU=%d, nocb toggle disabled.\n",
>+				cur_ops->name, IS_ENABLED(CONFIG_RCU_NOCB_CPU));
>+		nocbs_nthreads = 0;
>+	}
> 	if (cur_ops->init)
> 		cur_ops->init();
> 
>-- 
>2.25.1
Joel Fernandes Feb. 3, 2023, 5:28 p.m. UTC | #2
On Thu, Feb 2, 2023 at 8:35 PM Zqiang <qiang1.zhang@intel.com> wrote:
>
> When setting nocbs_nthreads to start rcutorture test with a non-zero value,
> the nocb tasks will be created and invoke rcu_nocb_cpu_offload/deoffload()
> to toggle CPU's callback-offload state, but for CONFIG_RCU_NOCB_CPU=n
> kernel, the rcu_nocb_cpu_offload/deoffload() is a no-op and this is also
> meaningless for torture_type is non-rcu.
>
> This commit therefore add member can_nocbs_toggle to rcu_torture_ops
> structure to avoid unnecessary nocb tasks creation.
>
> Signed-off-by: Zqiang <qiang1.zhang@intel.com>

Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>

thanks,

 - Joel


> ---
>  kernel/rcu/rcutorture.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
> index 297da28ce92d..d01127e0e8cd 100644
> --- a/kernel/rcu/rcutorture.c
> +++ b/kernel/rcu/rcutorture.c
> @@ -3708,6 +3708,12 @@ rcu_torture_init(void)
>                 pr_alert("rcu-torture: ->fqs NULL and non-zero fqs_duration, fqs disabled.\n");
>                 fqs_duration = 0;
>         }
> +       if (nocbs_nthreads != 0 && (cur_ops != &rcu_ops ||
> +                                       !IS_ENABLED(CONFIG_RCU_NOCB_CPU))) {
> +               pr_alert("rcu-torture types: %s and CONFIG_RCU_NOCB_CPU=%d, nocb toggle disabled.\n",
> +                               cur_ops->name, IS_ENABLED(CONFIG_RCU_NOCB_CPU));
> +               nocbs_nthreads = 0;
> +       }
>         if (cur_ops->init)
>                 cur_ops->init();
>
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 297da28ce92d..d01127e0e8cd 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -3708,6 +3708,12 @@  rcu_torture_init(void)
 		pr_alert("rcu-torture: ->fqs NULL and non-zero fqs_duration, fqs disabled.\n");
 		fqs_duration = 0;
 	}
+	if (nocbs_nthreads != 0 && (cur_ops != &rcu_ops ||
+					!IS_ENABLED(CONFIG_RCU_NOCB_CPU))) {
+		pr_alert("rcu-torture types: %s and CONFIG_RCU_NOCB_CPU=%d, nocb toggle disabled.\n",
+				cur_ops->name, IS_ENABLED(CONFIG_RCU_NOCB_CPU));
+		nocbs_nthreads = 0;
+	}
 	if (cur_ops->init)
 		cur_ops->init();