Skip to content

bpf: introduce helper for populating bpf_cpumask

Emil Tsalapatis bpf 7 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest4 patches 3 repliesApplied 4/4
  2. v64 patches 4 repliesSuperseded
  3. v54 patches 2 repliesSuperseded
Earlier versions · 4
VersionPostedPatchesRepliesStatus
v43 patches5 repliesApplied 3/3
v32 patches2 repliesSuperseded
v22 patches1 replySuperseded
v12 patches6 repliesSuperseded

Changelog from the cover letter

Patches in v7 All 4 applied

#Subject and filesSizeRepliesApplied
1/4bpf: add kfunc for populating cpumask bitskernel/bpf/cpumask.c+33 -00 repliesApplied
2/4selftests: bpf: add bpf_cpumask_populate selfteststools/testing/selftests/bpf/prog_tests/cpumask.c tools/testing/selftests/bpf/progs/cpumask_common.h tools/testing/selftests/bpf/progs/cpumask_failure.c +1 more+161 -01 replyApplied
3/4bpf: fix missing kdoc string fields in cpumask.ckernel/bpf/cpumask.c+20 -01 replyApplied
4/4selftests: bpf: fix duplicate selftests in cpumask_success.tools/testing/selftests/bpf/prog_tests/cpumask.c tools/testing/selftests/bpf/progs/cpumask_success.c+1 -21 replyApplied

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchHou TaoTejun Heo
1/4A-b A-b
2/4A-b
3/4A-b
4/4A-b

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

Read the v7 thread

Cover letter [PATCH v7 0/4] bpf: introduce helper for populating bpf_cpumask

Some BPF programs like scx schedulers have their own internal CPU mask types, mask types, which they must transform into struct bpf_cpumask instances before passing them to scheduling-related kfuncs. There is currently no way to efficiently populate the bitfield of a bpf_cpumask from BPF memory, and programs must use multiple bpf_cpumask_[set, clear] calls to do so. Introduce a kfunc helper to populate the bitfield of a bpf_cpumask from valid BPF memory with a single call.

Changelog :
-----------
v6->v7 v6:https://lore.kernel.org/bpf/[email protected]/

Addressed feedback by Hou Tao:
* Removed RUN_TESTS invocation causing tests to run twice
* Added is_test_task guard to new selftests
* Removed extraneous __success attribute from existing selftests

v5->v6 v5:https://lore.kernel.org/bpf/[email protected]/

Addressed feedback by Hou Tao:
* Removed __success attributes from cpumask selftests
* Fixed stale patch description that used old function name

v4->v5
v4: https://lore.kernel.org/bpf/[email protected]/

Addressed feedback by Hou Tao:
* Readded the tests in tools/selftests/bpf/prog_tests/cpumask.c, turns out the selftest entries were not duplicates.
* Removed stray whitespace in selftest.
* Add patch the missing selftest to prog_tests/cpumask.c
* Explicitly annotate all cpumask selftests with __success

The last patch could very well be its own cleanup patch, but I rolled it into this series because it came up in the discussion. If the last patch in the series has any issues I'd be fine with applying the first 3 patches and dealing with it separately.

v3->v4
v3: https://lore.kernel.org/bpf/[email protected]/

* Removed new tests from tools/selftests/bpf/prog_tests/cpumask.c because
they were being run twice.

Addressed feedback by Alexei Starovoitov:
* Added missing return value in function kdoc
* Added an additional patch fixing some missing kdoc fields in kernel/bpf/cpumask.c

Addressed feedback by Tejun Heo:
* Renamed the kfunc to bpf_cpumask_populate to avoid confusion w/ bitmap_fill()

v2->v3
v2: https://lore.kernel.org/bpf/[email protected]/

Addressed feedback by Alexei Starovoitov:
* Added back patch descriptions dropped from v1->v2
* Elide the alignment check for archs with efficient unaligned accesses

v1->v2
v1: https://lore.kernel.org/bpf/[email protected]/

Addressed feedback by Hou Tao:
* Add check that the input buffer is aligned to sizeof(long)
* Adjust input buffer size check to use bitmap_size()
* Add selftest for checking the bit pattern of the bpf_cpumask
* Moved all selftests into existing files

Emil Tsalapatis (4):
bpf: add kfunc for populating cpumask bits
selftests: bpf: add bpf_cpumask_populate selftests
bpf: fix missing kdoc string fields in cpumask.c
selftests: bpf: fix duplicate selftests in cpumask_success.

 kernel/bpf/cpumask.c                          |  53 ++++++++
 .../selftests/bpf/prog_tests/cpumask.c        |   5 +-
 .../selftests/bpf/progs/cpumask_common.h      |   1 +
 .../selftests/bpf/progs/cpumask_failure.c     |  38 ++++++
 .../selftests/bpf/progs/cpumask_success.c     | 120 +++++++++++++++++-
 5 files changed, 215 insertions(+), 2 deletions(-)
Signature · 1 line
2.47.1