On 2/13/26 1:56 AM, Chen Ridong wrote:

On 2026/2/13 0:46, Waiman Long wrote:
As any change to isolated_cpus is going to be propagated to the
HK_TYPE_DOMAIN housekeeping cpumask, it can be problematic if
housekeeping cpumasks are directly being modified from the CPU hotplug
code path. This is especially the case if we are going to enable dynamic
update to the nohz_full housekeeping cpumask (HK_TYPE_KERNEL_NOISE)
in the near future with the help of CPU hotplug.

Avoid these potential problems by changing the cpuset code to not
updating isolated_cpus when calling from CPU hotplug. A new special
PRS_INVALID_ISOLCPUS is added to indicate the current cpuset is an
invalid partition but its effective_xcpus are still in isolated_cpus.
This special state will be set if an isolated partition becomes invalid
due to the shutdown of the last active CPU in that partition. We also
need to keep the effective_xcpus even if exclusive_cpus isn't set.

When changes are made to "cpuset.cpus", "cpuset.cpus.exclusive" or
"cpuset.cpus.partition" of a PRS_INVALID_ISOLCPUS cpuset, its state
will be reset back to PRS_INVALID_ISOLATED and its effective_xcpus will
be removed from isolated_cpus before proceeding.

As CPU hotplug will no longer update isolated_cpus, some of the test
cases in test_cpuset_prs.h will have to be updated to match the new
expected results. Some new test cases are also added to confirm that
"cpuset.cpus.isolated" and HK_TYPE_DOMAIN housekeeping cpumask will
both be updated.

Signed-off-by: Waiman Long <[email protected]>
---
  kernel/cgroup/cpuset.c                        | 85 ++++++++++++++++---
  .../selftests/cgroup/test_cpuset_prs.sh       | 21 +++--
  2 files changed, 87 insertions(+), 19 deletions(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index c792380f9b60..48b7f275085b 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -159,6 +159,8 @@ static bool force_sd_rebuild;                       /* RWCS 
*/
   *   2 - partition root without load balancing (isolated)
   *  -1 - invalid partition root
   *  -2 - invalid isolated partition root
+ *  -3 - invalid isolated partition root but with effective xcpus still
+ *      in isolated_cpus (set from CPU hotplug side)
   *
   *  There are 2 types of partitions - local or remote. Local partitions are
   *  those whose parents are partition root themselves. Setting of
@@ -187,6 +189,7 @@ static bool force_sd_rebuild;                       /* RWCS 
*/
  #define PRS_ISOLATED          2
  #define PRS_INVALID_ROOT      -1
  #define PRS_INVALID_ISOLATED  -2
+#define PRS_INVALID_ISOLCPUS   -3 /* Effective xcpus still in isolated_cpus */
How about adding a helper?

bool hotplug_invalidate_isolate(struct cpuset *cs)
{
        if (current->flags & PF_KTHREAD) &&
                (cs->partition_root_state == PRS_INVALID_ISOLATED);
}

I decided to revert back to the v4 way of deferring housekeeping_update() call to a workqueue to make it simple, but do it in a simple and straight forward way.

Thanks,
Longman



Reply via email to