perf bench: Add benchmark of find_next_bit
Ian Rogers
reviewerPATCH v2 1/1 perf bench: Add benchmark of find_next_bit
for_each_set_bit, or similar functions like for_each_cpu, may be hot within the kernel. If many bits were set then one could imagine on Intel a "bt" instruction with every bit may be faster than the function call and word length find_next_bit logic. Add a benchmark to measure this.
This benchmark on AMD rome and Intel skylakex shows "bt" is not a good option except for very small bitmaps.
Signed-off-by Ian Rogers <[email protected]>
--- tools/perf/bench/Build | 1 + tools/perf/bench/bench.h | 1 + tools/perf/bench/find-bit-bench.c | 135 ++++++++++++++++++++++++++++++ tools/perf/builtin-bench.c | 1 + 4 files changed, 138 insertions(+) create mode 100644 tools/perf/bench/find-bit-bench.c
tools/perf/bench/Build +1 -0
@@ -10,6 +10,7 @@ perf-y += epoll-wait.o perf-y += epoll-ctl.o perf-y += synthesize.o perf-y += kallsyms-parse.o +perf-y += find-bit-bench.o perf-$(CONFIG_X86_64) += mem-memcpy-x86-64-lib.o perf-$(CONFIG_X86_64) += mem-memcpy-x86-64-asm.o
tools/perf/bench/bench.h +1 -0
@@ -35,6 +35,7 @@ int bench_sched_messaging(int argc, const char **argv);int bench_sched_pipe (int argc,const char **argv);int bench_mem_memcpy (int argc,const char **argv);int bench_mem_memset (int argc,const char **argv); +int bench_mem_find_bit (int argc,const char **argv);int bench_futex_hash (int argc,const char **argv);int bench_futex_wake (int argc,const char **argv);int bench_futex_wake_parallel (int argc,const char **argv);
tools/perf/bench/find-bit-bench.c new file +135 -0
135 lines not on this page · raw message
tools/perf/builtin-bench.c +1 -0
@@ -52,6 +52,7 @@ static struct bench sched_benchmarks[] = {static struct bench mem_benchmarks[] = { {"memcpy" ,"Benchmark for memcpy() functions" , bench_mem_memcpy }, {"memset" ,"Benchmark for memset() functions" , bench_mem_memset }, + {"find_bit" ,"Benchmark for find_bit() functions" , bench_mem_find_bit }, {"all" ,"Run all memory access benchmarks" ,NULL }, {NULL ,NULL ,NULL } };
Signature · 1 line
2.28.0.163.g6104cc2f0b6-goog