public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] bpf: introduce helper for populating bpf_cpumask
@ 2025-03-05 16:13 Emil Tsalapatis
  2025-03-05 16:13 ` [PATCH v3 1/2] bpf: add kfunc for populating cpumask bits Emil Tsalapatis
  2025-03-05 16:13 ` [PATCH v3 2/2] selftests: bpf: add bpf_cpumask_fill selftests Emil Tsalapatis
  0 siblings, 2 replies; 5+ messages in thread
From: Emil Tsalapatis @ 2025-03-05 16:13 UTC (permalink / raw)
  To: bpf
  Cc: ast, daniel, andrii, martin.lau, eddyz87, yonghong.song, tj,
	memxor, houtao, Emil Tsalapatis

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 :
-----------
v2->v3
v2: https://lore.kernel.org/bpf/20250305021020.1004858-1-emil@etsalapatis.com/

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/20250228003321.1409285-1-emil@etsalapatis.com/

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

Signed-off-by: Emil Tsalapatis (Meta) <emil@etsalapatis.com>

Emil Tsalapatis (2):
  bpf: add kfunc for populating cpumask bits
  selftests: bpf: add bpf_cpumask_fill selftests

 kernel/bpf/cpumask.c                          |  28 +++++
 .../selftests/bpf/prog_tests/cpumask.c        |   3 +
 .../selftests/bpf/progs/cpumask_failure.c     |  38 ++++++
 .../selftests/bpf/progs/cpumask_success.c     | 114 ++++++++++++++++++
 4 files changed, 183 insertions(+)

-- 
2.47.1


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

end of thread, other threads:[~2025-03-05 18:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-05 16:13 [PATCH v3 0/2] bpf: introduce helper for populating bpf_cpumask Emil Tsalapatis
2025-03-05 16:13 ` [PATCH v3 1/2] bpf: add kfunc for populating cpumask bits Emil Tsalapatis
2025-03-05 17:50   ` Alexei Starovoitov
2025-03-05 18:27   ` Tejun Heo
2025-03-05 16:13 ` [PATCH v3 2/2] selftests: bpf: add bpf_cpumask_fill selftests Emil Tsalapatis

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