When a cpuset isolated partition is created or destroyed, also drive
kernel-noise housekeeping types (HK_TYPE_KERNEL_NOISE and
HK_TYPE_MANAGED_IRQ) through housekeeping_update_types().  The sched
domain mask (HK_TYPE_DOMAIN) is updated first via the existing
housekeeping_update() call, then the explicit callback chain in
housekeeping_update_types() invokes subsystem apply() handlers to
toggle nohz_full, managed IRQ migration, and RCU NOCB offloading.

The update runs outside cpuset_mutex and cpus_read_lock, protected
only by cpuset_top_mutex.

Signed-off-by: Jing Wu <[email protected]>
Signed-off-by: Qiliang Yuan <[email protected]>
---
 kernel/cgroup/cpuset.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 5c33ab20cc208..67b93bd4d58f2 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -1347,17 +1347,30 @@ 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);
 
-               /*
-                * 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));
+
+               /*
+                * Drive kernel-noise types through the new explicit
+                * callback chain.  Tik/rcu/genirq subtypes react
+                * through their registered housekeeping_cbs apply()
+                * handlers.
+                */
+               WARN_ON_ONCE(housekeeping_update_types(noise_types,
+                                                      isolated_hk_cpus));
                mutex_unlock(&cpuset_top_mutex);
        } else {
                cpuset_full_unlock();

-- 
2.43.0


Reply via email to