]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/bpf: Remove kmalloc tracing from local storage create bench
authorAmery Hung <ameryhung@gmail.com>
Sat, 11 Apr 2026 01:54:16 +0000 (18:54 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 11 Apr 2026 04:22:31 +0000 (21:22 -0700)
Remove the raw_tp/kmalloc BPF program and its associated reporting from
the local storage create benchmark. The kmalloc count per create is not
a useful metric as different code paths use different allocators (e.g.
kmalloc_nolock vs kzalloc), introducing noise that makes the number
hard to interpret.

Keep total_creates in the summary output as it is useful for normalizing
perf statistics collected alongside the benchmark.

Signed-off-by: Amery Hung <ameryhung@gmail.com>
Link: https://lore.kernel.org/r/20260411015419.114016-2-ameryhung@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/benchs/bench_local_storage_create.c
tools/testing/selftests/bpf/progs/bench_local_storage_create.c

index e2ff8ea1cb79121b83ac1ae53acbe74d0a9f04bb..71e38000ee0673663a71813a32e1589928059be3 100644 (file)
@@ -101,11 +101,6 @@ static void setup(void)
                }
        }
 
-       if (!bpf_program__attach(skel->progs.kmalloc)) {
-               fprintf(stderr, "Error attaching bpf program\n");
-               exit(1);
-       }
-
        threads = calloc(env.producer_cnt, sizeof(*threads));
 
        if (!threads) {
@@ -140,7 +135,6 @@ static void setup(void)
 static void measure(struct bench_res *res)
 {
        res->hits = atomic_swap(&skel->bss->create_cnts, 0);
-       res->drops = atomic_swap(&skel->bss->kmalloc_cnts, 0);
 }
 
 static void *sk_producer(void *input)
@@ -203,28 +197,25 @@ static void *producer(void *input)
 
 static void report_progress(int iter, struct bench_res *res, long delta_ns)
 {
-       double creates_per_sec, kmallocs_per_create;
+       double creates_per_sec;
 
        creates_per_sec = res->hits / 1000.0 / (delta_ns / 1000000000.0);
-       kmallocs_per_create = (double)res->drops / res->hits;
 
        printf("Iter %3d (%7.3lfus): ",
               iter, (delta_ns - 1000000000) / 1000.0);
-       printf("creates %8.3lfk/s (%7.3lfk/prod)",
+       printf("creates %8.3lfk/s (%7.3lfk/prod)\n",
               creates_per_sec, creates_per_sec / env.producer_cnt);
-       printf("%3.2lf kmallocs/create\n", kmallocs_per_create);
 }
 
 static void report_final(struct bench_res res[], int res_cnt)
 {
        double creates_mean = 0.0, creates_stddev = 0.0;
-       long total_creates = 0, total_kmallocs = 0;
+       long total_creates = 0;
        int i;
 
        for (i = 0; i < res_cnt; i++) {
                creates_mean += res[i].hits / 1000.0 / (0.0 + res_cnt);
                total_creates += res[i].hits;
-               total_kmallocs += res[i].drops;
        }
 
        if (res_cnt > 1)  {
@@ -234,9 +225,9 @@ static void report_final(struct bench_res res[], int res_cnt)
                                       (res_cnt - 1.0);
                creates_stddev = sqrt(creates_stddev);
        }
-       printf("Summary: creates %8.3lf \u00B1 %5.3lfk/s (%7.3lfk/prod), ",
-              creates_mean, creates_stddev, creates_mean / env.producer_cnt);
-       printf("%4.2lf kmallocs/create\n", (double)total_kmallocs / total_creates);
+       printf("Summary: creates %8.3lf \u00B1 %5.3lfk/s (%7.3lfk/prod), %ld total\n",
+              creates_mean, creates_stddev, creates_mean / env.producer_cnt,
+              total_creates);
        if (create_owner_errs || skel->bss->create_errs)
                printf("%s() errors %ld create_errs %ld\n",
                       storage_type == BPF_MAP_TYPE_SK_STORAGE ?
index c8ec0d0368e4a15a72c2b166a73ab90615424c97..25ca6045fea3f4d66255e356082ca43ab9dd1f31 100644 (file)
@@ -8,7 +8,6 @@
 
 long create_errs = 0;
 long create_cnts = 0;
-long kmalloc_cnts = 0;
 __u32 bench_pid = 0;
 
 struct storage {
@@ -29,16 +28,6 @@ struct {
        __type(value, struct storage);
 } task_storage_map SEC(".maps");
 
-SEC("raw_tp/kmalloc")
-int BPF_PROG(kmalloc, unsigned long call_site, const void *ptr,
-            size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags,
-            int node)
-{
-       __sync_fetch_and_add(&kmalloc_cnts, 1);
-
-       return 0;
-}
-
 SEC("tp_btf/sched_process_fork")
 int BPF_PROG(sched_process_fork, struct task_struct *parent, struct task_struct *child)
 {