public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] Add new bpf_cpumask_weight() kfunc
@ 2023-12-07 21:08 David Vernet
  2023-12-07 21:08 ` [PATCH bpf-next 1/2] bpf: Add " David Vernet
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: David Vernet @ 2023-12-07 21:08 UTC (permalink / raw)
  To: bpf
  Cc: ast, daniel, andrii, martin.lau, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, linux-kernel,
	kernel-team

It can be useful to query how many bits are set in a cpumask. For
example, if you want to perform special logic for the last remaining
core that's set in a mask. This logic is already exposed through the
main kernel's cpumask header as cpumask_weight(), so it would be useful
to add a new bpf_cpumask_weight() kfunc which wraps it and does the
same.

This patch series was built and tested on top of commit 2146f7fe6e02
("Merge branch 'allocate-bpf-trampoline-on-bpf_prog_pack'").

David Vernet (2):
  bpf: Add bpf_cpumask_weight() kfunc
  selftests/bpf: Add test for bpf_cpumask_weight() kfunc

 Documentation/bpf/cpumasks.rst                |  2 +-
 kernel/bpf/cpumask.c                          | 12 ++++++
 .../selftests/bpf/prog_tests/cpumask.c        |  1 +
 .../selftests/bpf/progs/cpumask_common.h      |  1 +
 .../selftests/bpf/progs/cpumask_success.c     | 43 +++++++++++++++++++
 5 files changed, 58 insertions(+), 1 deletion(-)

-- 
2.42.1


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

end of thread, other threads:[~2023-12-10  5:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-07 21:08 [PATCH bpf-next 0/2] Add new bpf_cpumask_weight() kfunc David Vernet
2023-12-07 21:08 ` [PATCH bpf-next 1/2] bpf: Add " David Vernet
2023-12-08  4:37   ` Yonghong Song
2023-12-07 21:08 ` [PATCH bpf-next 2/2] selftests/bpf: Add test for " David Vernet
2023-12-08  4:39   ` Yonghong Song
2023-12-10  5:40 ` [PATCH bpf-next 0/2] Add new " patchwork-bot+netdevbpf

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