Le Fri, Jul 10, 2026 at 11:28:14AM +0800, Jing Wu a écrit :
> An isolated cpuset partition already updates the HK_TYPE_DOMAIN
> housekeeping mask. Extend it to also update the kernel-noise masks
> (HK_TYPE_KERNEL_NOISE and HK_TYPE_MANAGED_IRQ) so that creating or
> destroying an isolated partition reconfigures the full set of
> housekeeping cpumasks.
>
> The sched domain mask is updated first because the workqueue flush and
> timer migration paths depend on it; the kernel-noise masks are updated
> afterwards via housekeeping_update_types().
>
> housekeeping_update() and housekeeping_update_types() are called after
> dropping cpus_read_lock and cpuset_mutex, with only cpuset_top_mutex held
> for mutual exclusion.
>
> Co-developed-by: Qiliang Yuan <[email protected]>
> Signed-off-by: Qiliang Yuan <[email protected]>
> Signed-off-by: Jing Wu <[email protected]>
> ---
> kernel/cgroup/cpuset.c | 23 +++++++++++++++++++++--
> 1 file changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 5c33ab20cc208..80f43a24d3c8a 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -1347,17 +1347,36 @@ static void cpuset_update_sd_hk_unlock(void)
> rebuild_sched_domains_locked();
>
> if (update_housekeeping) {
> + static const unsigned long noise_types =
> + BIT(HK_TYPE_KERNEL_NOISE) | BIT(HK_TYPE_MANAGED_IRQ);
> +
> update_housekeeping = false;
> cpumask_copy(isolated_hk_cpus, isolated_cpus);
>
> + mutex_unlock(&cpuset_mutex);
> + cpus_read_unlock();
> +
> /*
> * housekeeping_update() is now called without holding
> * cpus_read_lock and cpuset_mutex. Only cpuset_top_mutex
> * is still being held for mutual exclusion.
> */
> - mutex_unlock(&cpuset_mutex);
> - cpus_read_unlock();
> +
> + /*
> + * Update the sched domain mask first; it must succeed
> + * before the kernel-noise types because workqueue flush
> + * and timer migration depend on the sched domain mask.
> + */
> WARN_ON_ONCE(housekeeping_update(isolated_hk_cpus));
> +
> + /*
> + * Update the kernel-noise housekeeping masks
> + * (HK_TYPE_KERNEL_NOISE and HK_TYPE_MANAGED_IRQ). The tick,
> + * RCU and managed-interrupt state is reconfigured as the
> + * affected CPUs are cycled through the CPU hotplug machinery.
> + */
> + WARN_ON_ONCE(housekeeping_update_types(noise_types,
> + isolated_hk_cpus));
We rely on the fact that target CPUs are offline in order to set them
as HK_TYPE_KERNEL_NOISE, right? So, should we keep cpus_read_lock held
to prevent from concurrent hotplug events?
Thanks.
> mutex_unlock(&cpuset_top_mutex);
> } else {
> cpuset_full_unlock();
>
> --
> 2.43.0
>
--
Frederic Weisbecker
SUSE Labs