[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251113033322.431859-1-sunshaojie@kylinos.cn>
Date: Thu, 13 Nov 2025 11:33:22 +0800
From: Sun Shaojie <sunshaojie@...inos.cn>
To: chenridong@...weicloud.com,
longman@...hat.com
Cc: tj@...nel.org,
hannes@...xchg.org,
mkoutny@...e.com,
shuah@...nel.org,
cgroups@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-kselftest@...r.kernel.org
Subject: Re: [PATCH v1] cpuset: Avoid unnecessary partition invalidation
On 2025/11/13 09:21, Chen Ridong wrote:
>
>Hi, Longman.
>
>It did not fail to set cupset.cpus, but invalidated the sibling cpuset partition.
>
>If we relax this rule, we should consider:
>
> What I want to note is this: what if we run echo root > /sys/fs/cgroup/B1/cpuset.cpus.partition
>after step #5? There’s no conflict check when enabling the partition.
>
>--
>Best regards,
>Ridong
Hi, Ridong.
I understand your concern, and there is a conflict check when enabling
partitions. Below, I will use two tables to show the partition states of A1
and B1 before applying this patch and after applying it.(All the steps in
the table are by default under the path /sys/fs/cgroup)
Table 1: Before applying the patch
| A1's prstate | B1's prstate |
#1> mkdir -p A1 | member | |
#2> echo "0-1" > A1/cpuset.cpus | member | |
#3> echo "root" > A1/cpuset.cpus.partition | root | |
#4> mkdir -p B1 | root | member |
#5> echo "0-3" > B1/cpuset.cpus | root invalid | member |
#6> echo "root" > B1/cpuset.cpus.partition | root invalid | root invalid |
Table 2: After applying the patch
| A1's prstate | B1's prstate |
#1> mkdir -p A1 | member | |
#2> echo "0-1" > A1/cpuset.cpus | member | |
#3> echo "root" > A1/cpuset.cpus.partition | root | |
#4> mkdir -p B1 | root | member |
#5> echo "0-3" > B1/cpuset.cpus | root | member |
#6> echo "root" > B1/cpuset.cpus.partition | root | root invalid |
As shown in Table 2, after step #6, B1's partition state becomes "root
invalid". This confirms that conflict checks are performed when enabling
partitions, and clearly, the check did not pass in this case. This is the
expected result, since the CPUs (0-3) that B1 attempts to use exclusively
conflict with those used by A1 (0-1).
The reviewer mentioned they couldn't see my original patch, so I'm
re-quoting the key changes below for clarity:
>diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>index 52468d2c178a..e0d27c9a101a 100644
>--- a/kernel/cgroup/cpuset.c
>+++ b/kernel/cgroup/cpuset.c
>@@ -586,14 +586,14 @@ static inline bool cpusets_are_exclusive(struct cpuset *cs1, struct cpuset *cs2)
> * Returns: true if CPU exclusivity conflict exists, false otherwise
> *
> * Conflict detection rules:
>- * 1. If either cpuset is CPU exclusive, they must be mutually exclusive
>+ * 1. If both cpusets are exclusive, they must be mutually exclusive
> * 2. exclusive_cpus masks cannot intersect between cpusets
> * 3. The allowed CPUs of one cpuset cannot be a subset of another's exclusive CPUs
> */
> static inline bool cpus_excl_conflict(struct cpuset *cs1, struct cpuset *cs2)
> {
>- /* If either cpuset is exclusive, check if they are mutually exclusive */
>- if (is_cpu_exclusive(cs1) || is_cpu_exclusive(cs2))
>+ /* If both cpusets are exclusive, check if they are mutually exclusive */
>+ if (is_cpu_exclusive(cs1) && is_cpu_exclusive(cs2))
> return !cpusets_are_exclusive(cs1, cs2);
>
> /* Exclusive_cpus cannot intersect */
Here are the main changes, where the conflict check for step #6 in Table 2
is performed. And these changes have no effect on cgroup v1.
Thanks,
Sun Shaojie
Powered by blists - more mailing lists