Linux cgroups development
 help / color / mirror / Atom feed
* [RFC PATCH -v4 00/22] cpuset: rework local partition logic
@ 2026-11-01 11:41 Ridong Chen
  2026-11-01 11:41 ` [RFC PATCH -v4 01/22] cpuset: add early empty cpumask check in partition_xcpus_add/del Ridong Chen
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: Ridong Chen @ 2026-11-01 11:41 UTC (permalink / raw)
  To: Waiman Long, Tejun Heo, Johannes Weiner, Michal Koutn?
  Cc: Guopeng Zhang, Ridong Chen, cgroups, linux-kernel, Ridong Chen

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=a, Size: 5452 bytes --]

From: Ridong Chen <chenridong@xiaomi.com>

There have been quite a few partition related fixes recently, most of
them caused by the scattered handling of partition state and the
isolated CPUs in different code paths. This convinces me again that the
rework of the local partition logic is necessary, so I am restarting
this series. As it has been a long time since the last posting, this
series is marked as RFC v4.

The current local partition implementation consolidates all operations
(enable, disable, invalidate, and update) within the large
update_parent_effective_cpumask() function, which exceeds 300 lines.
This monolithic approach has become increasingly difficult to understand
and maintain. Additionally, partition-related fields are updated in
multiple locations, leading to redundant code and potential corner case
oversights.

This patch series refactors the local partition logic by separating
operations into dedicated functions: local_partition_enable(),
local_partition_disable(), and local_partition_update(), creating
symmetry with the existing remote partition infrastructure.

After the rework:
- The code is reduced by about 90 lines (568 insertions, 657
  deletions), and the 312-line update_parent_effective_cpumask() is
  removed.
- Both local and remote partitions go through the same
  partition_enable(), partition_disable() and partition_update()
  helpers, and are validated by validate_local_partition() and
  validate_remote_partition() on top of the common
  validate_partition(). The structure and semantics of each operation
  are much clearer.
- The partition fields are updated in a unified way. The direct writes
  of partition_root_state are reduced from 6 places to 2, and the
  writes of prs_err from 12 places to 3, most of them now done in
  partition_state_update(). The isolation state of the CPUs given back
  to the parent is settled in partition_xcpus_del(), so
  isolated_cpus_release() is removed.

The series is organized as follows:

1. Infrastructure Preparation (Patches 1-3):
   - Code cleanup and preparation for the refactoring work

2. Introduce partition operation helpers (Patches 4-6):
   - Introduce out partition_enable(), partition_disable(), and
     partition_update() functions.

3. Use new helpers for remote partition (Patches 7-9)

4. Local Partition Implementation (Patches 10-13):
   - Separate update_parent_effective_cpumask() into dedicated functions:
     * local_partition_enable()
     * local_partition_disable()
     * local_partition_update()

5. Optimization and Cleanup (Patches 14-22):
   - Remove redundant partition-related operations
   - Additional optimizations based on the new architecture

base-commit: 6d0933ae9d46674a6ea63a87e9e9ab4e662670c9

---

Changes in RFC v4:
1. Rebase on the next-20261028 and adapt patches 3-22 to the current
   partition code.
2. Add patch 2 to settle the isolation state of CPUs given back to the
   parent in partition_xcpus_del(), replacing isolated_cpus_release().
3. Fix several issues of the hotplug, prs_err and remote partition
   update handling found in review and testing.
4. The issues fixed by Waiman's series [1] are also covered by this
   rework, and its new test cases pass with this series applied.

[1] https://lore.kernel.org/all/20261030190701.78308-1-longman@redhat.com/

RESEND: https://lore.kernel.org/all/20251225123058.231765-1-chenridong@huaweicloud.com/

Changes in RESEND:
1. Rebase on the next-20251219

Changes from RFC v2:
1. Dropped the bugfix (already merged/fixed upstream)
2. Rebased onto next
3. Introduced partition_switch to handle root state switches
4. Directly use local_partition_disable()—no longer first introduce
   local_partition_invalidate() before unifying the two
5. Incorporated modifications based on Longman's suggestions

Changes in RFC v1:
1. Added bugfix for root partition isolcpus at series start.
2. Completed helper function implementations when first introduced.
3. Split larger patches into smaller, more reviewable units.
4. Incorporated feedback from Longman.

Chen Ridong (21):
  cpuset: add early empty cpumask check in partition_xcpus_add/del
  cpuset: generalize the validate_partition() interface
  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 local_partition_enable()
  cpuset: introduce local_partition_disable()
  cpuset: use local_partition_disable() to invalidate local partition
  cpuset: introduce local_partition_update()
  cpuset: remove update_parent_effective_cpumask
  cpuset: remove redundant partition field updates
  cpuset: simplify partition update logic for hotplug tasks
  cpuset: use partition_disable for compute_partition_effective_cpumask
  cpuset: use validate_local_partition in local_partition_enable
  cpuset: introduce validate_remote_partition
  cpuset: simplify the update_prstate() function
  cpuset: remove prs_err clear when notify_partition_change
  cpuset: remove unnecessary validation in partition_cpus_change

Ridong Chen (1):
  cpuset: settle isolation state when CPUs are given back to parent

 kernel/cgroup/cpuset.c | 1225 +++++++++++++++++++---------------------
 1 file changed, 568 insertions(+), 657 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2026-11-01 11:45 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-01 11:41 [RFC PATCH -v4 00/22] cpuset: rework local partition logic Ridong Chen
2026-11-01 11:41 ` [RFC PATCH -v4 01/22] cpuset: add early empty cpumask check in partition_xcpus_add/del Ridong Chen
2026-11-01 11:41 ` [RFC PATCH -v4 02/22] cpuset: settle isolation state when CPUs are given back to parent Ridong Chen
2026-11-01 11:41 ` [RFC PATCH -v4 03/22] cpuset: generalize the validate_partition() interface Ridong Chen
2026-11-01 11:41 ` [RFC PATCH -v4 04/22] cpuset: introduce partition_enable() Ridong Chen
2026-11-01 11:41 ` [RFC PATCH -v4 05/22] cpuset: introduce partition_disable() Ridong Chen
2026-11-01 11:41 ` [RFC PATCH -v4 06/22] cpuset: introduce partition_update() Ridong Chen
2026-11-01 11:41 ` [RFC PATCH -v4 07/22] cpuset: use partition_enable() for remote partition enablement Ridong Chen
2026-11-01 11:41 ` [RFC PATCH -v4 08/22] cpuset: use partition_disable() for remote partition disablement Ridong Chen
2026-11-01 11:41 ` [RFC PATCH -v4 09/22] cpuset: use partition_update() for remote partition update Ridong Chen
2026-11-01 11:41 ` [RFC PATCH -v4 10/22] cpuset: introduce local_partition_enable() Ridong Chen
2026-11-01 11:41 ` [RFC PATCH -v4 11/22] cpuset: introduce local_partition_disable() Ridong Chen
2026-11-01 11:41 ` [RFC PATCH -v4 12/22] cpuset: use local_partition_disable() to invalidate local partition Ridong Chen
2026-11-01 11:41 ` [RFC PATCH -v4 13/22] cpuset: introduce local_partition_update() Ridong Chen
2026-11-01 11:41 ` [RFC PATCH -v4 14/22] cpuset: remove update_parent_effective_cpumask Ridong Chen
2026-11-01 11:41 ` [RFC PATCH -v4 15/22] cpuset: remove redundant partition field updates Ridong Chen
2026-11-01 11:42 ` [RFC PATCH -v4 16/22] cpuset: simplify partition update logic for hotplug tasks Ridong Chen
2026-11-01 11:42 ` [RFC PATCH -v4 17/22] cpuset: use partition_disable for compute_partition_effective_cpumask Ridong Chen
2026-11-01 11:42 ` [RFC PATCH -v4 18/22] cpuset: use validate_local_partition in local_partition_enable Ridong Chen
2026-11-01 11:42 ` [RFC PATCH -v4 19/22] cpuset: introduce validate_remote_partition Ridong Chen
2026-11-01 11:42 ` [RFC PATCH -v4 20/22] cpuset: simplify the update_prstate() function Ridong Chen
2026-11-01 11:42 ` [RFC PATCH -v4 21/22] cpuset: remove prs_err clear when notify_partition_change Ridong Chen
2026-11-01 11:42 ` [RFC PATCH -v4 22/22] cpuset: remove unnecessary validation in partition_cpus_change Ridong Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox