Skip to content

Commit

Permalink
selftests/bpf: Add uprobe_multi usdt test code
Browse files Browse the repository at this point in the history
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 <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
  • Loading branch information
olsajiri authored and Alexei Starovoitov committed Aug 21, 2023
1 parent 3706919 commit 4cde2d8
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion tools/testing/selftests/bpf/uprobe_multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <stdio.h>
#include <string.h>
#include <sdt.h>

#define __PASTE(a, b) a##b
#define PASTE(a, b) __PASTE(a, b)
Expand Down Expand Up @@ -53,15 +54,38 @@ static int bench(void)
return 0;
}

#define PROBE STAP_PROBE(test, usdt);

#define PROBE10 PROBE PROBE PROBE PROBE PROBE \
PROBE PROBE PROBE PROBE PROBE
#define PROBE100 PROBE10 PROBE10 PROBE10 PROBE10 PROBE10 \
PROBE10 PROBE10 PROBE10 PROBE10 PROBE10
#define PROBE1000 PROBE100 PROBE100 PROBE100 PROBE100 PROBE100 \
PROBE100 PROBE100 PROBE100 PROBE100 PROBE100
#define PROBE10000 PROBE1000 PROBE1000 PROBE1000 PROBE1000 PROBE1000 \
PROBE1000 PROBE1000 PROBE1000 PROBE1000 PROBE1000

static int usdt(void)
{
PROBE10000
PROBE10000
PROBE10000
PROBE10000
PROBE10000
return 0;
}

int main(int argc, char **argv)
{
if (argc != 2)
goto error;

if (!strcmp("bench", argv[1]))
return bench();
if (!strcmp("usdt", argv[1]))
return usdt();

error:
fprintf(stderr, "usage: %s <bench>\n", argv[0]);
fprintf(stderr, "usage: %s <bench|usdt>\n", argv[0]);
return -1;
}

0 comments on commit 4cde2d8

Please sign in to comment.