Skip to content

kernel/cpu.c: eliminate some indirection

Rasmus Villemoes lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5kernel/cpu.c: change type of cpu_possible_bits and friendskernel/cpu.c+22 -220 replies
2/5kernel/cpu.c: export __cpu_xyz_maskinclude/linux/cpumask.h kernel/cpu.c+13 -50 replies
3/5drivers/base/cpu.c: use __cpu_xyz_mask directlydrivers/base/cpu.c+5 -50 replies
4/5kernel/cpu.c: eliminate cpu_xyz_maskinclude/linux/cpumask.h kernel/cpu.c+4 -120 replies
5/5kernel/cpu.c: make set_cpu_xyz static inlinesinclude/linux/cpumask.h kernel/cpu.c+39 -380 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 0/5] kernel/cpu.c: eliminate some indirection

The four cpumasks cpu_{possible,online,present,active}_bits are exposed readonly via the corresponding const variables cpu_xyz_mask. But they are also accessible for arbitrary writing via the exposed functions set_cpu_xyz. There's quite a bit of code throughout the kernel which iterates over or otherwise accesses these bitmaps, and having the access go via the cpu_xyz_mask variables is simply a useless indirection.

The first four patches eliminate the cpu_xyz_mask variables by simply exposing the actual bitmaps, after renaming them to discourage direct access - that still happens through cpu_xyz_mask, which are now simply macros with the same type and value as they used to have.

After that, there's no longer any reason to have the setter functions be out-of-line: The boolean parameter is almost always a literal true or false, so by making them static inlines they will usually compile to one or two instructions.

Altogether, bloat-o-meter reports a saving of ~2600 bytes.

Rasmus Villemoes (5):
kernel/cpu.c: change type of cpu_possible_bits and friends kernel/cpu.c: export __cpu_xyz_mask drivers/base/cpu.c: use __cpu_xyz_mask directly kernel/cpu.c: eliminate cpu_xyz_mask kernel/cpu.c: make set_cpu_xyz static inlines

 drivers/base/cpu.c      | 10 ++++----
 include/linux/cpumask.h | 55 +++++++++++++++++++++++++++++++++++-------
 kernel/cpu.c            | 64 ++++++++++---------------------------------------
 3 files changed, 65 insertions(+), 64 deletions(-)
Signature · 1 line
2.1.3