lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 15 Sep 2023 17:45:04 +0200
From:   Pierre Gondois <pierre.gondois@....com>
To:     linux-kernel@...r.kernel.org
Cc:     rui.zhang@...el.com, aaron.lu@...el.com,
        Pierre Gondois <pierre.gondois@....com>,
        Waiman Long <longman@...hat.com>,
        Zefan Li <lizefan.x@...edance.com>, Tejun Heo <tj@...nel.org>,
        Johannes Weiner <hannes@...xchg.org>, cgroups@...r.kernel.org
Subject: [PATCH 1/1] cgroup/cpuset: Rebuild sched domains if isolated partition changed

When an isolated parition is created, the sched domains (sds) are
rebuilt and the sds of the isolated CPUs are detached. This only
happens at the creation of the isolated parition. Updating
the cpuset of the partition doesn't rebuild the sds:

To reproduce:
  # ls /sys/kernel/debug/sched/domains/cpu0/
  domain0
  # ls /sys/kernel/debug/sched/domains/cpu1/
  domain0
  #
  # mkdir cgroup
  # mount -t cgroup2 none cgroup/
  # mkdir cgroup/A1/
  # echo "+cpuset" > cgroup/cgroup.subtree_control
  # echo 0-3 > cgroup/A1/cpuset.cpus
  # echo isolated > cgroup/A1/cpuset.cpus.partition
  #
  # ls /sys/kernel/debug/sched/domains/cpu0/
  # ls /sys/kernel/debug/sched/domains/cpu1/
  #
  # echo 0 > cgroup/A1/cpuset.cpus
  # ls /sys/kernel/debug/sched/domains/cpu0/
  # ls /sys/kernel/debug/sched/domains/cpu1/
  #

Here CPU1 should have a sched domain re-attached.

Signed-off-by: Pierre Gondois <pierre.gondois@....com>
---
 kernel/cgroup/cpuset.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 58e6f18f01c1..e3eb27ff9b68 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -1680,11 +1680,15 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
 		 * empty cpuset is changed, we need to rebuild sched domains.
 		 * On default hierarchy, the cpuset needs to be a partition
 		 * root as well.
+		 * Also rebuild sched domains if the cpuset of an isolated
+		 * partition changed.
 		 */
-		if (!cpumask_empty(cp->cpus_allowed) &&
-		    is_sched_load_balance(cp) &&
-		   (!cgroup_subsys_on_dfl(cpuset_cgrp_subsys) ||
-		    is_partition_valid(cp)))
+		if ((!cpumask_empty(cp->cpus_allowed) &&
+		     is_sched_load_balance(cp) &&
+		     (!cgroup_subsys_on_dfl(cpuset_cgrp_subsys) ||
+		      is_partition_valid(cp))) ||
+		    (cp->partition_root_state == PRS_ISOLATED ||
+		     cp->partition_root_state == PRS_INVALID_ISOLATED))
 			need_rebuild_sched_domains = true;
 
 		rcu_read_lock();
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ