Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Add uprobe_multi usdt test code

Adding code in uprobe_multi test binary that defines 50k usdts
and will serve as attach point for uprobe_multi usdt bench test
in following patch.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20230809083440.3209381-25-jolsa@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Jiri Olsa and committed by
Alexei Starovoitov
4cde2d8a 3706919e

+25 -1
+25 -1
tools/testing/selftests/bpf/uprobe_multi.c
··· 2 2 3 3 #include <stdio.h> 4 4 #include <string.h> 5 + #include <sdt.h> 5 6 6 7 #define __PASTE(a, b) a##b 7 8 #define PASTE(a, b) __PASTE(a, b) ··· 54 53 return 0; 55 54 } 56 55 56 + #define PROBE STAP_PROBE(test, usdt); 57 + 58 + #define PROBE10 PROBE PROBE PROBE PROBE PROBE \ 59 + PROBE PROBE PROBE PROBE PROBE 60 + #define PROBE100 PROBE10 PROBE10 PROBE10 PROBE10 PROBE10 \ 61 + PROBE10 PROBE10 PROBE10 PROBE10 PROBE10 62 + #define PROBE1000 PROBE100 PROBE100 PROBE100 PROBE100 PROBE100 \ 63 + PROBE100 PROBE100 PROBE100 PROBE100 PROBE100 64 + #define PROBE10000 PROBE1000 PROBE1000 PROBE1000 PROBE1000 PROBE1000 \ 65 + PROBE1000 PROBE1000 PROBE1000 PROBE1000 PROBE1000 66 + 67 + static int usdt(void) 68 + { 69 + PROBE10000 70 + PROBE10000 71 + PROBE10000 72 + PROBE10000 73 + PROBE10000 74 + return 0; 75 + } 76 + 57 77 int main(int argc, char **argv) 58 78 { 59 79 if (argc != 2) ··· 82 60 83 61 if (!strcmp("bench", argv[1])) 84 62 return bench(); 63 + if (!strcmp("usdt", argv[1])) 64 + return usdt(); 85 65 86 66 error: 87 - fprintf(stderr, "usage: %s <bench>\n", argv[0]); 67 + fprintf(stderr, "usage: %s <bench|usdt>\n", argv[0]); 88 68 return -1; 89 69 }