~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/progs/trigger_bench.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 // Copyright (c) 2020 Facebook
  3 #include <linux/bpf.h>
  4 #include <asm/unistd.h>
  5 #include <bpf/bpf_helpers.h>
  6 #include <bpf/bpf_tracing.h>
  7 #include "bpf_misc.h"
  8 
  9 char _license[] SEC("license") = "GPL";
 10 
 11 #define CPU_MASK 255
 12 #define MAX_CPUS (CPU_MASK + 1) /* should match MAX_BUCKETS in benchs/bench_trigger.c */
 13 
 14 /* matches struct counter in bench.h */
 15 struct counter {
 16         long value;
 17 } __attribute__((aligned(128)));
 18 
 19 struct counter hits[MAX_CPUS];
 20 
 21 static __always_inline void inc_counter(void)
 22 {
 23         int cpu = bpf_get_smp_processor_id();
 24 
 25         __sync_add_and_fetch(&hits[cpu & CPU_MASK].value, 1);
 26 }
 27 
 28 SEC("?uprobe")
 29 int bench_trigger_uprobe(void *ctx)
 30 {
 31         inc_counter();
 32         return 0;
 33 }
 34 
 35 const volatile int batch_iters = 0;
 36 
 37 SEC("?raw_tp")
 38 int trigger_count(void *ctx)
 39 {
 40         int i;
 41 
 42         for (i = 0; i < batch_iters; i++)
 43                 inc_counter();
 44 
 45         return 0;
 46 }
 47 
 48 SEC("?raw_tp")
 49 int trigger_driver(void *ctx)
 50 {
 51         int i;
 52 
 53         for (i = 0; i < batch_iters; i++)
 54                 (void)bpf_get_numa_node_id(); /* attach point for benchmarking */
 55 
 56         return 0;
 57 }
 58 
 59 extern int bpf_modify_return_test_tp(int nonce) __ksym __weak;
 60 
 61 SEC("?raw_tp")
 62 int trigger_driver_kfunc(void *ctx)
 63 {
 64         int i;
 65 
 66         for (i = 0; i < batch_iters; i++)
 67                 (void)bpf_modify_return_test_tp(0); /* attach point for benchmarking */
 68 
 69         return 0;
 70 }
 71 
 72 SEC("?kprobe/bpf_get_numa_node_id")
 73 int bench_trigger_kprobe(void *ctx)
 74 {
 75         inc_counter();
 76         return 0;
 77 }
 78 
 79 SEC("?kretprobe/bpf_get_numa_node_id")
 80 int bench_trigger_kretprobe(void *ctx)
 81 {
 82         inc_counter();
 83         return 0;
 84 }
 85 
 86 SEC("?kprobe.multi/bpf_get_numa_node_id")
 87 int bench_trigger_kprobe_multi(void *ctx)
 88 {
 89         inc_counter();
 90         return 0;
 91 }
 92 
 93 SEC("?kretprobe.multi/bpf_get_numa_node_id")
 94 int bench_trigger_kretprobe_multi(void *ctx)
 95 {
 96         inc_counter();
 97         return 0;
 98 }
 99 
100 SEC("?fentry/bpf_get_numa_node_id")
101 int bench_trigger_fentry(void *ctx)
102 {
103         inc_counter();
104         return 0;
105 }
106 
107 SEC("?fexit/bpf_get_numa_node_id")
108 int bench_trigger_fexit(void *ctx)
109 {
110         inc_counter();
111         return 0;
112 }
113 
114 SEC("?fmod_ret/bpf_modify_return_test_tp")
115 int bench_trigger_fmodret(void *ctx)
116 {
117         inc_counter();
118         return -22;
119 }
120 
121 SEC("?tp/bpf_test_run/bpf_trigger_tp")
122 int bench_trigger_tp(void *ctx)
123 {
124         inc_counter();
125         return 0;
126 }
127 
128 SEC("?raw_tp/bpf_trigger_tp")
129 int bench_trigger_rawtp(void *ctx)
130 {
131         inc_counter();
132         return 0;
133 }
134 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php