bench
char bench[] = " bench sched messaging -g 10 -l 5000 > /dev/null 2>&1";
strbuf_add(&sb, bench, strlen(bench));
static int bench_uprobe__setup_bpf_skel(enum bench_uprobe bench __maybe_unused) { return 0; }
static int bench_uprobe(int argc, const char **argv, enum bench_uprobe bench)
if (bench != BENCH_UPROBE__BASELINE && bench_uprobe__setup_bpf_skel(bench) < 0)
if (bench != BENCH_UPROBE__BASELINE)
static int bench_uprobe__setup_bpf_skel(enum bench_uprobe bench)
switch (bench) {
fprintf(stderr, "Invalid bench: %d\n", bench);
static struct bench breakpoint_benchmarks[] = {
static struct bench uprobe_benchmarks[] = {
struct bench *benchmarks;
#define for_each_bench(coll, bench) \
for (bench = coll->benchmarks; bench && bench->name; bench++)
struct bench *bench;
for_each_bench(coll, bench)
printf("%14s: %s\n", bench->name, bench->summary);
struct bench *bench;
for_each_bench(coll, bench) {
if (!bench->fn)
printf("# Running %s/%s benchmark...\n", coll->name, bench->name);
argv[1] = bench->name;
run_bench(coll->name, bench->name, bench->fn, 1, argv);
struct bench *bench;
for_each_bench(coll, bench) {
if (strcmp(bench->name, argv[1]))
printf("# Running '%s/%s' benchmark:\n", coll->name, bench->name);
ret = run_bench(coll->name, bench->name, bench->fn, argc-1, argv+1);
static struct bench numa_benchmarks[] = {
static struct bench sched_benchmarks[] = {
static struct bench syscall_benchmarks[] = {
static struct bench mem_benchmarks[] = {
static struct bench futex_benchmarks[] = {
static struct bench epoll_benchmarks[] = {
static struct bench internals_benchmarks[] = {
if (bench->argp) {
bench_parsers[0].argp = bench->argp;
bench_parsers[0].header = bench->name;
const struct bench *bench = NULL;
extern const struct bench bench_count_global;
extern const struct bench bench_count_local;
extern const struct bench bench_rename_base;
extern const struct bench bench_rename_kprobe;
extern const struct bench bench_rename_kretprobe;
extern const struct bench bench_rename_rawtp;
extern const struct bench bench_rename_fentry;
extern const struct bench bench_rename_fexit;
extern const struct bench bench_trig_usermode_count;
extern const struct bench bench_trig_syscall_count;
extern const struct bench bench_trig_kernel_count;
extern const struct bench bench_trig_kprobe;
extern const struct bench bench_trig_kretprobe;
extern const struct bench bench_trig_kprobe_multi;
extern const struct bench bench_trig_kretprobe_multi;
extern const struct bench bench_trig_fentry;
extern const struct bench bench_trig_kprobe_multi_all;
extern const struct bench bench_trig_kretprobe_multi_all;
extern const struct bench bench_trig_fexit;
extern const struct bench bench_trig_fmodret;
extern const struct bench bench_trig_tp;
extern const struct bench bench_trig_rawtp;
extern const struct bench bench_trig_uprobe_nop;
extern const struct bench bench_trig_uretprobe_nop;
extern const struct bench bench_trig_uprobe_push;
extern const struct bench bench_trig_uretprobe_push;
extern const struct bench bench_trig_uprobe_ret;
extern const struct bench bench_trig_uretprobe_ret;
extern const struct bench bench_trig_uprobe_multi_nop;
extern const struct bench bench_trig_uretprobe_multi_nop;
extern const struct bench bench_trig_uprobe_multi_push;
extern const struct bench bench_trig_uretprobe_multi_push;
extern const struct bench bench_trig_uprobe_multi_ret;
extern const struct bench bench_trig_uretprobe_multi_ret;
extern const struct bench bench_trig_uprobe_nop5;
extern const struct bench bench_trig_uretprobe_nop5;
extern const struct bench bench_trig_uprobe_multi_nop5;
extern const struct bench bench_trig_uretprobe_multi_nop5;
extern const struct bench bench_rb_libbpf;
extern const struct bench bench_rb_custom;
extern const struct bench bench_pb_libbpf;
extern const struct bench bench_pb_custom;
extern const struct bench bench_bloom_lookup;
extern const struct bench bench_bloom_update;
extern const struct bench bench_bloom_false_positive;
extern const struct bench bench_hashmap_without_bloom;
extern const struct bench bench_hashmap_with_bloom;
extern const struct bench bench_bpf_loop;
extern const struct bench bench_strncmp_no_helper;
extern const struct bench bench_strncmp_helper;
extern const struct bench bench_bpf_hashmap_full_update;
extern const struct bench bench_local_storage_cache_seq_get;
extern const struct bench bench_local_storage_cache_interleaved_get;
extern const struct bench bench_local_storage_cache_hashmap_control;
extern const struct bench bench_local_storage_tasks_trace;
extern const struct bench bench_bpf_hashmap_lookup;
extern const struct bench bench_local_storage_create;
extern const struct bench bench_htab_mem;
extern const struct bench bench_crypto_encrypt;
extern const struct bench bench_crypto_decrypt;
extern const struct bench bench_sockmap;
extern const struct bench bench_lpm_trie_noop;
extern const struct bench bench_lpm_trie_baseline;
extern const struct bench bench_lpm_trie_lookup;
extern const struct bench bench_lpm_trie_insert;
extern const struct bench bench_lpm_trie_update;
extern const struct bench bench_lpm_trie_delete;
extern const struct bench bench_lpm_trie_free;
static const struct bench *benchs[] = {
bench = benchs[i];
if (!bench) {
printf("Setting up benchmark '%s'...\n", bench->name);
if (bench->validate)
bench->validate();
if (bench->setup)
bench->setup();
if (!bench->consumer_thread) {
bench->consumer_thread, (void *)(long)i);
if (!bench->producer_thread) {
bench->producer_thread, (void *)(long)i);
printf("Benchmark '%s' started.\n", bench->name);
bench->measure(res);
if (bench->report_progress)
bench->report_progress(iter, res, delta_ns);
if (bench->report_final)
bench->report_final(state.results + env.warmup_sec,
extern const struct bench *bench;
const struct bench bench_bloom_lookup = {
const struct bench bench_bloom_update = {
const struct bench bench_bloom_false_positive = {
const struct bench bench_hashmap_without_bloom = {
const struct bench bench_hashmap_with_bloom = {
const struct bench bench_crypto_encrypt = {
const struct bench bench_crypto_decrypt = {
const struct bench bench_bpf_hashmap_full_update = {
const struct bench bench_bpf_hashmap_lookup = {
const struct bench bench_bpf_loop = {
const struct bench bench_count_global = {
const struct bench bench_count_local = {
const struct bench bench_htab_mem = {
const struct bench bench_local_storage_cache_seq_get = {
const struct bench bench_local_storage_cache_interleaved_get = {
const struct bench bench_local_storage_cache_hashmap_control = {
const struct bench bench_local_storage_create = {
const struct bench bench_local_storage_tasks_trace = {
ctx.bench = lpm_trie_bench__open_and_load();
if (!ctx.bench) {
ctx.bench->bss->nr_entries = args.nr_entries;
ctx.bench->bss->prefixlen = args.prefixlen;
ctx.bench->bss->random = args.random;
if (lpm_trie_bench__attach(ctx.bench)) {
struct lpm_trie_bench *bench;
fd = bpf_map__fd(ctx.bench->maps.trie_map);
ctx.bench->bss->op = LPM_OP_NOOP;
ctx.bench->bss->op = LPM_OP_BASELINE;
ctx.bench->bss->op = LPM_OP_LOOKUP;
ctx.bench->bss->op = LPM_OP_INSERT;
ctx.bench->bss->op = LPM_OP_UPDATE;
ctx.bench->bss->op = LPM_OP_DELETE;
ctx.bench->bss->op = LPM_OP_FREE;
res->hits = atomic_swap(&ctx.bench->bss->hits, 0);
res->duration_ns = atomic_swap(&ctx.bench->bss->duration_ns, 0);
int fd = bpf_map__fd(ctx.bench->maps.trie_map);
switch (ctx.bench->bss->op) {
ctx.bench->bss->op);
int fd = bpf_program__fd(ctx.bench->progs.run_bench);
opts.retval, ctx.bench->bss->op);
const struct bench bench_lpm_trie_noop = {
const struct bench bench_lpm_trie_baseline = {
const struct bench bench_lpm_trie_lookup = {
const struct bench bench_lpm_trie_insert = {
const struct bench bench_lpm_trie_update = {
const struct bench bench_lpm_trie_delete = {
const struct bench bench_lpm_trie_free = {
const struct bench bench_rename_base = {
const struct bench bench_rename_kprobe = {
const struct bench bench_rename_kretprobe = {
const struct bench bench_rename_rawtp = {
const struct bench bench_rename_fentry = {
const struct bench bench_rename_fexit = {
const struct bench bench_rb_libbpf = {
const struct bench bench_rb_custom = {
const struct bench bench_pb_libbpf = {
const struct bench bench_pb_custom = {
const struct bench bench_sockmap = {
const struct bench bench_strncmp_no_helper = {
const struct bench bench_strncmp_helper = {
const struct bench bench_trig_syscall_count = {
const struct bench bench_trig_##KIND = { \
const struct bench bench_trig_##KIND = { \
return bench();
static int bench(void)