BPF List
 help / color / mirror / Atom feed
* [RFC PATCH bpf-next 0/2] bpf: Add generic kfunc bpf_ffs64()
@ 2024-01-31 15:56 Leon Hwang
  2024-01-31 15:56 ` [RFC PATCH bpf-next 1/2] " Leon Hwang
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Leon Hwang @ 2024-01-31 15:56 UTC (permalink / raw)
  To: bpf; +Cc: ast, daniel, andrii, Leon Hwang

This patchset introduces a new generic kfunc bpf_ffs64(). This kfunc
allows bpf to reuse kernel's __ffs64() function to improve ffs
performance in bpf.

In patch "bpf: Add generic kfunc bpf_ffs64()", there is some data to
confirm that this kfunc is able to save around 10ns for every time on
"Intel(R) Xeon(R) Silver 4116 CPU @ 2.10GHz" CPU server, by comparing
with bpf-implemented __ffs64().

However, it will be better when convert this kfunc to "rep bsf" in
JIT on x86, which is able to avoid a call. But, I haven't figure out the
way.

Leon Hwang (2):
  bpf: Add generic kfunc bpf_ffs64()
  selftests/bpf: Add testcases for generic kfunc bpf_ffs64()

 kernel/bpf/helpers.c                          |  7 +++
 .../testing/selftests/bpf/prog_tests/bitops.c | 54 +++++++++++++++++++
 tools/testing/selftests/bpf/progs/bitops.c    | 21 ++++++++
 3 files changed, 82 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/bitops.c
 create mode 100644 tools/testing/selftests/bpf/progs/bitops.c


base-commit: c5809f0c308111adbcdbf95462a72fa79eb267d1
-- 
2.42.1


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

end of thread, other threads:[~2024-03-03 13:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-31 15:56 [RFC PATCH bpf-next 0/2] bpf: Add generic kfunc bpf_ffs64() Leon Hwang
2024-01-31 15:56 ` [RFC PATCH bpf-next 1/2] " Leon Hwang
2024-01-31 15:56 ` [RFC PATCH bpf-next 2/2] selftests/bpf: Add testcases for " Leon Hwang
2024-02-02 22:18 ` [RFC PATCH bpf-next 0/2] bpf: Add " Andrii Nakryiko
2024-02-04 19:19   ` Yonghong Song
2024-02-05 18:18     ` Andrii Nakryiko
2024-02-05 18:34       ` Yonghong Song
2024-03-03 13:18         ` Leon Hwang

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