2021-11-15 05:15:59

by Zqiang

[permalink] [raw]
Subject: [PATCH] rcu: Avoid boost task running on isolated cpus

If the nohz_full is enabled, when the boost task be created,
the cpus_allowed_ptr be set housekeeping_cpumask(HK_FLAG_KTHREAD),
however when the rcu_boost_kthread_setaffinity() be called, the
original affinity will be changed, the isolated cpus should be
considered again.

Signed-off-by: Zqiang <[email protected]>
---
kernel/rcu/tree_plugin.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 5199559fbbf0..87e7ebbdb12e 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -1204,8 +1204,9 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
if ((mask & leaf_node_cpu_bit(rnp, cpu)) &&
cpu != outgoingcpu)
cpumask_set_cpu(cpu, cm);
+ cpumask_and(cm, cm, housekeeping_cpumask(HK_FLAG_RCU));
if (cpumask_weight(cm) == 0)
- cpumask_setall(cm);
+ cpumask_copy(cm, housekeeping_cpumask(HK_FLAG_RCU));
set_cpus_allowed_ptr(t, cm);
free_cpumask_var(cm);
}
--
2.17.1



2021-11-15 13:13:43

by Paul E. McKenney

[permalink] [raw]
Subject: Re: [PATCH] rcu: Avoid boost task running on isolated cpus

On Mon, Nov 15, 2021 at 01:15:46PM +0800, Zqiang wrote:
> If the nohz_full is enabled, when the boost task be created,
> the cpus_allowed_ptr be set housekeeping_cpumask(HK_FLAG_KTHREAD),
> however when the rcu_boost_kthread_setaffinity() be called, the
> original affinity will be changed, the isolated cpus should be
> considered again.
>
> Signed-off-by: Zqiang <[email protected]>

I have queued this for testing and further review, thank you!

I am particularly interested in Frederic's thoughts on how this might
interact with any future ability to change the set of nohz_full CPUs
at runtime.

Thanx, Paul

> ---
> kernel/rcu/tree_plugin.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
> index 5199559fbbf0..87e7ebbdb12e 100644
> --- a/kernel/rcu/tree_plugin.h
> +++ b/kernel/rcu/tree_plugin.h
> @@ -1204,8 +1204,9 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
> if ((mask & leaf_node_cpu_bit(rnp, cpu)) &&
> cpu != outgoingcpu)
> cpumask_set_cpu(cpu, cm);
> + cpumask_and(cm, cm, housekeeping_cpumask(HK_FLAG_RCU));
> if (cpumask_weight(cm) == 0)
> - cpumask_setall(cm);
> + cpumask_copy(cm, housekeeping_cpumask(HK_FLAG_RCU));
> set_cpus_allowed_ptr(t, cm);
> free_cpumask_var(cm);
> }
> --
> 2.17.1
>