From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.245 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796356175; b=VahAbYmEJBh/uWb9ZUVWnN0+ll28qvFga/O71MJKgWXiGZwT8/mwfo3TYZMEA14PMDNv gr2DLgabDzj1Gpra94V6dFSlfdjtOjbJF7edZqgVgQaDqjXEGO7PkAR6EOiB1OyuBYY+H b70zlQ44qECdxQAhsh8gy+8RwaRGOFQseehTya+plVl7L9aytKwgtY0sZLUqYSrGz2qhR inYys6hwz5OEDOccZ1LUIzwhyWQt5Ulx7tMcXj8qs8MD/sdwUzBpY5DeqLSaLgvN06bPC WWB9ynERlXlKoVrqQs5vIkIESwZ6wMHvtQI/MNPAMnYk7VvpAdee4ig03e9m2JzzX3w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796356175; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=8NCZMs7HPZi7qlfs1g7MgcCMgaZnqaEC8/hLiJW5XPA=; b=fIfLIwCz4+hDhV5e7iT9pfHuZzgdeHiplPvNiIp4Qvh0701JAHFkFSyflB2l0e/UvuDJ +OZolNX+GisuatFRz4fOJftZuuKJL/ETAHN3FYMBqwmjFNoQN+D1PPyn16R6Z6nBvo1u2 FSTtEHU/VR5DbOGjpdzGj3zJVSzjPnALujpw4bPQGmex9FB33gMiVYYiHD+zdFOzbIdZ4 vOqlz474LTlfiK7W1rwyjaHcI/HJBA4kx1g3w3NxZju4L5Uj3Ym6Jaqek+siZljidsPPi 2QVMORTjxreSEsvzDLrfDJ1k/CTAPqQGEVjJBA1U5w4HcnbMezH3AnkcDB7fvNsL3+A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=AGo85Izu; arc=none smtp.remote-ip=95.215.58.245 Received: from mta1.migadu.com (out-245.mta1.migadu.com [95.215.58.245]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10AAE606A32C for ; Fri, 4 Dec 2026 03:49:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 10AAE606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=AGo85Izu X-Envelope-To: cgroups@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=mHfcr9wNe/5CTXQRe9eTQaKthfuxXNiT0PnyDfBd5pQ=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796356172; v=1; x=1796960972; b=AGo85Izu1J0di/7+WY5o5pdoLfuX7TaEnO2PF2Bu1DJilzNVoGlwCAByXPkJByK9eUvYxjtS 6gqlk23PAbtJu4Cpg1IEY9K+En+haQrmncq9nPx2LsMfiwUMEdU8T8Qp3gBqrTYU/Qw9erQjf8Y 9n4bZE9ldx66B1Myx5lzdeGY= X-Envelope-To: cgroups@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 465c6f0bcd7e2faf; Fri, 04 Dec 2026 03:49:31 +0000 X-Mizu-Trace-ID: 465c6f0bcd7e2faf X-Migadu-Flow: FLOW_OUT Message-ID: <9049fe51-6da7-4387-98b2-da4d027bc003@linux.dev> Date: Fri, 4 Dec 2026 11:49:19 +0800 X-Mailing-List: cgroups@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 00/12] cpuset: rework local partition logic To: Waiman Long , Tejun Heo , Johannes Weiner , =?UTF-8?Q?Michal_Koutn=C3=BD?= Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Ridong Chen , Kyuwon Cho , Hang Zhengyang References: <20261129024431.2485721-1-ridong.chen@linux.dev> From: Ridong Chen In-Reply-To: <20261129024431.2485721-1-ridong.chen@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/29/2026 10:44 AM, Ridong Chen wrote: > From: Ridong Chen > > This is v6 of the cpuset local partition rework [1], which I started > while at Huawei and am now continuing at Xiaomi. Since v4, the fixes and > preparatory changes at the start of the series have been posted > separately, last as [2], and merged into cgroup. This version is based > on cgroup/for-7.5 and only has the part that consolidates the partition > state changes into common helpers, the remaining parts will follow. > > The partition state of a cpuset is currently changed in many places, and > local and remote partitions are handled by different code. > update_parent_effective_cpumask() alone handles five partcmd_* commands > for local partitions, while the remote partition helpers open code the > same updates of partition_root_state, prs_err, effective_xcpus, > subpartitions_cpus and isolated_cpus. > > The idea is to have one set of common helpers to enable, disable and > update a partition. Local and remote partitions only do their own > validation and then call these helpers, and all partition related > state is set or changed only inside them. After this series: > > update_prstate() update_cpumask() > update_cpumasks_hier() cpuset_hotplug_update_tasks() > | > +---------------+---------------+ > | | > v v > +-------------------+ +--------------------+ > | local partition | | remote partition | > | | | | > | validate_local_ | | remote_partition_ | > | partition() | | enable() | > | local_partition_ | | remote_cpus_ | > | enable() | | update() | > | update() | | | > +-------------------+ +--------------------+ > | | > +---------------+---------------+ > | > v > +------------------------------------------------+ > | partition_enable() | > | partition_disable() | > | partition_update() | > +------------------------------------------------+ > | > | partition state, only changed here > v > +------------------------------------------------+ > | cpuset: partition_root_state, prs_err, | > | remote_partition, effective_xcpus, | > | exclusive_cpus | > | global: subpartitions_cpus, isolated_cpus | > +------------------------------------------------+ > > partition_enable() - make a cpuset a valid partition root, or switch > a valid partition between root and isolated > partition_disable() - make a partition a member or invalid, give its > CPUs back to the parent and propagate the change > partition_update() - update the exclusive CPUs of a valid partition > > A partition is disabled with partition_disable() directly, for both > local and remote partitions, as giving the CPUs back to the parent needs > no partition specific handling. > > With this, every caller follows the same pattern (validate, then > enable/disable/update), and it is much easier to see where and why a > partition state changes. > > Patches 1-3 introduce the common helpers and patches 4-6 use them for > remote partitions. Patches 7-11 add validate_local_partition(), > local_partition_enable() and local_partition_update() and convert the > local partition paths, including the hotplug path, to them. Patch 12 > removes update_parent_effective_cpumask() and the partition_cmd enum. > > The series is meant to be functionally equivalent, except that the > failure reason of an invalid partition is kept more accurately. For > example, PERR_CPUSEMPTY of a partition with empty cpuset.cpus and > cpuset.cpus.exclusive is no longer overwritten by PERR_INVCPUS when its > parent changes. > > The remaining parts of the rework, e.g. validate_remote_partition(), > removing the partition field updates left outside the helpers and > simplifying update_prstate(), will be posted as a follow-up series. > > test_cpuset_prs.sh passes with this series applied, with no boot option, > with isolcpus=10-11 and with nohz_full=8-11. > > Changes in v6: > - Rebase onto cgroup/for-7.5. > - Address the review comments from Sashiko and Guopeng. > - Link to v5: https://lore.kernel.org/all/20261114083124.1340140-1-ridong.chen@linux.dev/ > > Changes in v5: > - Drop the RFC tag and rebase onto cgroup/for-7.4-fixes, which has > patches 1-3 of v4 merged [2]. Only post patches 4-14 of v4. > - Call partition_disable() directly, instead of local_ and > remote_partition_disable(). > - Add validate_local_partition() in a separate patch. > - Keep PERR_CPUSEMPTY for empty cpumasks (Sashiko). > - Add __maybe_unused to unused helpers (Guopeng). > - Link to v4: https://lore.kernel.org/all/20261101114206.2434398-1-ridong.chen@linux.dev/ > > [1] https://lore.kernel.org/all/20261101114206.2434398-1-ridong.chen@linux.dev/ > [2] https://lore.kernel.org/all/20261112031931.2815548-1-ridong.chen@linux.dev/ > > Ridong Chen (12): > cpuset: introduce partition_enable() > cpuset: introduce partition_disable() > cpuset: introduce partition_update() > cpuset: use partition_enable() for remote partition enablement > cpuset: use partition_disable() for remote partition disablement > cpuset: use partition_update() for remote partition update > cpuset: introduce validate_local_partition() > cpuset: introduce local_partition_enable() > cpuset: use partition_disable() for local partition disablement > cpuset: use partition_disable() to invalidate local partition > cpuset: introduce local_partition_update() > cpuset: remove update_parent_effective_cpumask > > kernel/cgroup/cpuset.c | 849 +++++++++++++++++++---------------------- > 1 file changed, 401 insertions(+), 448 deletions(-) > > > base-commit: db5a3d08c70b0c656f5455251fadb9b459e9374c Hi Longman, More and more people are now using AI tools to find and fix issues in cpuset partitions, and we have received several partition fixes recently, e.g. [1] and [2]. Each of them adds one more special case to the existing logic, mainly update_parent_effective_cpumask() and its callers, which is already complex and getting harder to maintain. I'm not against AI-assisted bug finding, it does find real issues. But I'd like to move this series forward faster, so that we can stop adding cases to the old logic. With the rework, both issues can be fixed in an obvious place: - [1]: all the local partition paths (enable, cpus update and recovery from invalid) go through validate_local_partition() and validate_partition(), so the fix is just adding a check there that the newly taken active CPUs come from the parent's effective_cpus. - [2]: the root <-> isolated switch is done in partition_switch(), and the fix is calling local_partition_update(), or remote_cpus_update() for a remote partition, at its beginning. Those helpers already take the new CPUs from the parent and invalidate the partition on failure. When you have time, could you help review v6? Your feedback would let me iterate on the series faster. [1] https://lore.kernel.org/cgroups/311db065-5f72-4f8a-9db0-341aea19fa28@linux.dev/T/#t [2] https://lore.kernel.org/cgroups/20261203195843.187930-1-hang.zhengyang1010@gmail.com/T/#t -- Best regards Ridong