Skip to content

Commit

Permalink
samples/bpf: stress test bpf_get_stackid
Browse files Browse the repository at this point in the history
increase stress by also calling bpf_get_stackid() from
various *spin* functions

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Alexei Starovoitov authored and David S. Miller committed Mar 9, 2016
1 parent 9d8b612 commit 7dcc42b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions samples/bpf/spintest_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <linux/netdevice.h>
#include <linux/version.h>
#include <uapi/linux/bpf.h>
#include <uapi/linux/perf_event.h>
#include "bpf_helpers.h"

struct bpf_map_def SEC("maps") my_map = {
Expand All @@ -23,6 +24,13 @@ struct bpf_map_def SEC("maps") my_map2 = {
.max_entries = 1024,
};

struct bpf_map_def SEC("maps") stackmap = {
.type = BPF_MAP_TYPE_STACK_TRACE,
.key_size = sizeof(u32),
.value_size = PERF_MAX_STACK_DEPTH * sizeof(u64),
.max_entries = 10000,
};

#define PROG(foo) \
int foo(struct pt_regs *ctx) \
{ \
Expand All @@ -32,6 +40,7 @@ int foo(struct pt_regs *ctx) \
bpf_map_update_elem(&my_map, &v, &v, BPF_ANY); \
bpf_map_update_elem(&my_map2, &v, &v, BPF_ANY); \
bpf_map_delete_elem(&my_map2, &v); \
bpf_get_stackid(ctx, &stackmap, BPF_F_REUSE_STACKID); \
return 0; \
}

Expand Down

0 comments on commit 7dcc42b

Please sign in to comment.