Skip to content

cpuset: rework local partition logic

Ridong Chen cgroups lkml sashiko-reviews 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest12 patches 4 repliesIn review
  2. v1 RFC22 patches 6 repliesSuperseded

Changes in v5 from the cover letter

- 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/[email protected]/

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12cpuset: introduce partition_enable()kernel/cgroup/cpuset.c+56 -02 replies
2/12cpuset: introduce partition_disable()kernel/cgroup/cpuset.c+66 -00 replies
3/12cpuset: introduce partition_update()kernel/cgroup/cpuset.c+52 -00 replies
4/12cpuset: use partition_enable() for remote partition enablementkernel/cgroup/cpuset.c+3 -100 replies
5/12cpuset: use partition_disable() for remote partition disablementkernel/cgroup/cpuset.c+8 -490 replies
6/12cpuset: use partition_update() for remote partition updatekernel/cgroup/cpuset.c+6 -221 reply
7/12cpuset: introduce validate_local_partition()kernel/cgroup/cpuset.c+61 -00 replies
8/12cpuset: introduce local_partition_enable()kernel/cgroup/cpuset.c+46 -380 replies
9/12cpuset: use partition_disable() for local partition disablementkernel/cgroup/cpuset.c+2 -170 replies
10/12cpuset: use partition_disable() to invalidate local partitionkernel/cgroup/cpuset.c+24 -160 replies
11/12cpuset: introduce local_partition_update()kernel/cgroup/cpuset.c+143 -581 reply
12/12cpuset: remove update_parent_effective_cpumaskkernel/cgroup/cpuset.c+6 -3230 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [PATCH v5 00/12] cpuset: rework local partition logic

From: Ridong Chen <[email protected]>

This is v5 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/for-7.4-fixes. This version is based on it 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. Patches 10-12, which change the hotplug path in between, are also tested individually.

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/[email protected]/

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

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 | 856 +++++++++++++++++++----------------------
 1 file changed, 398 insertions(+), 458 deletions(-)

base-commit: e234ed1bb82c96a5643fd70784f16cf3d72eeed3

Signature · 1 line
2.34.1