Skip to content

lib/group_cpus: rework grp_spread_init_one() and make it O(1)

Yury Norov lkml 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest9 patches 7 repliesIn review
  2. v49 patches 3 repliesSuperseded
  3. v37 patches 13 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v26 patches9 repliesSuperseded
v14 patches1 replySuperseded

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9cpumask: introduce for_each_cpu_and_from()include/linux/cpumask.h include/linux/find.h+14 -03 replies
2/9lib/group_cpus: optimize inner loop in grp_spread_init_one()lib/group_cpus.c+7 -72 replies
3/9lib/group_cpus: relax atomicity requirement in grp_spread_init_one()lib/group_cpus.c+4 -40 replies
4/9lib/group_cpus: optimize outer loop in grp_spread_init_one()lib/group_cpus.c+8 -62 replies
5/9lib/group_cpus: don't zero cpumasks in group_cpus_evenly() on allocationlib/group_cpus.c+2 -20 replies
6/9lib/group_cpus: drop unneeded cpumask_empty() call in __group_cpus_evenly()lib/group_cpus.c+8 -60 replies
7/9cpumask: define cleanup function for cpumasksinclude/linux/cpumask.h+5 -00 replies
8/9lib/group_cpus: rework group_cpus_evenly()lib/group_cpus.c+25 -540 replies
9/9lib/group_cpus: simplify group_cpus_evenly() for morelib/group_cpus.c+8 -70 replies

Reviews trailers per patch

1 of 9 patches has a Reviewed-by or Acked-by.

PatchMing Lei
1/9
2/9
3/9NAKed-by
4/9
5/9
6/9R-b
7/9
8/9
9/9

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH v5 0/9] lib/group_cpus: rework grp_spread_init_one() and make it O(1)

grp_spread_init_one() implementation is sub-optimal because it traverses bitmaps from the beginning, instead of picking from the previous iteration.

Fix it and use find_bit API where appropriate. While here, optimize cpumasks allocation and drop unneeded cpumask_empty() call.

---
v1: https://lore.kernel.org/all/ZW5MI3rKQueLM0Bz@yury-ThinkPad/T/
v2: https://lore.kernel.org/lkml/ZXKNVRu3AfvjaFhK@fedora/T/
v3: https://lore.kernel.org/lkml/[email protected]/T/
v4: https://lore.kernel.org/lkml/[email protected]/T/
v5: add CPUMASK_NULL macro and use it to initialize cpumask_var_t
variables properly.

On cpumask_var_t initialization issue:

The idea of having different types behind the same typedef has been considered nasty for quite a while. See a comment in include/linux/cpumask.h for example.

Now that I'm trying to adopt kernel cleanup machinery to cpumasks, it reveals another disadvantage of this approach - there's no way to assign a cpumask_var_t variable at declaration time, which is required by cleanup implementation.

To fix that, in v5 I added a CPUMASK_NULL macro as a workaround. This CPUMASK_NULL would be also useful for those converting existing codebase to enable cleanup variables.

On a long term, it's better to drop CPUMASK_OFFSTACK entirely. Moreover, it's used only on Power and x86 machines if NR_CPUS >= 8K (unless people enable it explicitly, and nobody bothers doing that in a real life). But it requires some more discussions with Power and x64 people...

Meanwhile, I'm going to submit a patchset that deprecates cpumask_var_t, and adds a new set of allocators which would support initialization at declaration time.

Yury Norov (9):
cpumask: introduce for_each_cpu_and_from() lib/group_cpus: optimize inner loop in grp_spread_init_one() lib/group_cpus: relax atomicity requirement in grp_spread_init_one() lib/group_cpus: optimize outer loop in grp_spread_init_one() lib/group_cpus: don't zero cpumasks in group_cpus_evenly() on
allocation
lib/group_cpus: drop unneeded cpumask_empty() call in

    __group_cpus_evenly()

cpumask: define cleanup function for cpumasks lib/group_cpus: rework group_cpus_evenly() lib/group_cpus: simplify group_cpus_evenly() for more

 include/linux/cpumask.h |  16 ++++++
 include/linux/find.h    |   3 ++
 lib/group_cpus.c        | 110 ++++++++++++++++------------------------
 3 files changed, 62 insertions(+), 67 deletions(-)
Signature · 1 line
2.40.1