[PATCH 12/33] sched/isolation: Convert housekeeping cpumasks to rcu pointers
Waiman Long
llong at redhat.com
Mon Oct 20 20:49:53 PDT 2025
On 10/13/25 4:31 PM, Frederic Weisbecker wrote:
> HK_TYPE_DOMAIN's cpumask will soon be made modifyable by cpuset.
> A synchronization mechanism is then needed to synchronize the updates
> with the housekeeping cpumask readers.
>
> Turn the housekeeping cpumasks into RCU pointers. Once a housekeeping
> cpumask will be modified, the update side will wait for an RCU grace
> period and propagate the change to interested subsystem when deemed
> necessary.
>
> Signed-off-by: Frederic Weisbecker <frederic at kernel.org>
> ---
> kernel/sched/isolation.c | 58 +++++++++++++++++++++++++---------------
> kernel/sched/sched.h | 1 +
> 2 files changed, 37 insertions(+), 22 deletions(-)
>
> diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
> index 8690fb705089..b46c20b5437f 100644
> --- a/kernel/sched/isolation.c
> +++ b/kernel/sched/isolation.c
> @@ -21,7 +21,7 @@ DEFINE_STATIC_KEY_FALSE(housekeeping_overridden);
> EXPORT_SYMBOL_GPL(housekeeping_overridden);
>
> struct housekeeping {
> - cpumask_var_t cpumasks[HK_TYPE_MAX];
> + struct cpumask __rcu *cpumasks[HK_TYPE_MAX];
> unsigned long flags;
> };
>
> @@ -33,17 +33,28 @@ bool housekeeping_enabled(enum hk_type type)
> }
> EXPORT_SYMBOL_GPL(housekeeping_enabled);
>
> +const struct cpumask *housekeeping_cpumask(enum hk_type type)
> +{
> + if (static_branch_unlikely(&housekeeping_overridden)) {
> + if (housekeeping.flags & BIT(type)) {
> + return rcu_dereference_check(housekeeping.cpumasks[type], 1);
> + }
> + }
> + return cpu_possible_mask;
> +}
> +EXPORT_SYMBOL_GPL(housekeeping_cpumask);
> +
> int housekeeping_any_cpu(enum hk_type type)
> {
> int cpu;
>
> if (static_branch_unlikely(&housekeeping_overridden)) {
> if (housekeeping.flags & BIT(type)) {
> - cpu = sched_numa_find_closest(housekeeping.cpumasks[type], smp_processor_id());
> + cpu = sched_numa_find_closest(housekeeping_cpumask(type), smp_processor_id());
> if (cpu < nr_cpu_ids)
> return cpu;
>
> - cpu = cpumask_any_and_distribute(housekeeping.cpumasks[type], cpu_online_mask);
> + cpu = cpumask_any_and_distribute(housekeeping_cpumask(type), cpu_online_mask);
> if (likely(cpu < nr_cpu_ids))
> return cpu;
> /*
> @@ -59,28 +70,18 @@ int housekeeping_any_cpu(enum hk_type type)
> }
> EXPORT_SYMBOL_GPL(housekeeping_any_cpu);
>
> -const struct cpumask *housekeeping_cpumask(enum hk_type type)
> -{
> - if (static_branch_unlikely(&housekeeping_overridden))
> - if (housekeeping.flags & BIT(type))
> - return housekeeping.cpumasks[type];
> - return cpu_possible_mask;
> -}
> -EXPORT_SYMBOL_GPL(housekeeping_cpumask);
> -
> void housekeeping_affine(struct task_struct *t, enum hk_type type)
> {
> if (static_branch_unlikely(&housekeeping_overridden))
> if (housekeeping.flags & BIT(type))
> - set_cpus_allowed_ptr(t, housekeeping.cpumasks[type]);
> + set_cpus_allowed_ptr(t, housekeeping_cpumask(type));
> }
> EXPORT_SYMBOL_GPL(housekeeping_affine);
>
> bool housekeeping_test_cpu(int cpu, enum hk_type type)
> {
> - if (static_branch_unlikely(&housekeeping_overridden))
> - if (housekeeping.flags & BIT(type))
> - return cpumask_test_cpu(cpu, housekeeping.cpumasks[type]);
> + if (housekeeping.flags & BIT(type))
> + return cpumask_test_cpu(cpu, housekeeping_cpumask(type));
> return true;
> }
The housekeeping_overridden static key check is kept in other places
except this one. Should we keep it for consistency?
Cheers,
Longman
More information about the linux-arm-kernel
mailing list