diff options
| author | David S. Miller <davem@davemloft.net> | 2018-05-07 23:35:08 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2018-05-07 23:35:08 -0400 |
| commit | 01adc4851a8090b46c7a5ed9cfc4b97e65abfbf4 (patch) | |
| tree | 2ae02593d7139962648dff203f3f9701e34ccbc3 /tools/testing/selftests/bpf/test_stacktrace_map.c | |
| parent | 18b338f5f9539512e76fd9ebd4c6ca1a0e159e2b (diff) | |
| parent | e94fa1d93117e7f1eb783dc9cae6c70650944449 (diff) | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
Minor conflict, a CHECK was placed into an if() statement
in net-next, whilst a newline was added to that CHECK
call in 'net'. Thanks to Daniel for the merge resolution.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing/selftests/bpf/test_stacktrace_map.c')
| -rw-r--r-- | tools/testing/selftests/bpf/test_stacktrace_map.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/tools/testing/selftests/bpf/test_stacktrace_map.c b/tools/testing/selftests/bpf/test_stacktrace_map.c index 76d85c5d08bd..af111af7ca1a 100644 --- a/tools/testing/selftests/bpf/test_stacktrace_map.c +++ b/tools/testing/selftests/bpf/test_stacktrace_map.c | |||
| @@ -19,14 +19,21 @@ struct bpf_map_def SEC("maps") stackid_hmap = { | |||
| 19 | .type = BPF_MAP_TYPE_HASH, | 19 | .type = BPF_MAP_TYPE_HASH, |
| 20 | .key_size = sizeof(__u32), | 20 | .key_size = sizeof(__u32), |
| 21 | .value_size = sizeof(__u32), | 21 | .value_size = sizeof(__u32), |
| 22 | .max_entries = 10000, | 22 | .max_entries = 16384, |
| 23 | }; | 23 | }; |
| 24 | 24 | ||
| 25 | struct bpf_map_def SEC("maps") stackmap = { | 25 | struct bpf_map_def SEC("maps") stackmap = { |
| 26 | .type = BPF_MAP_TYPE_STACK_TRACE, | 26 | .type = BPF_MAP_TYPE_STACK_TRACE, |
| 27 | .key_size = sizeof(__u32), | 27 | .key_size = sizeof(__u32), |
| 28 | .value_size = sizeof(__u64) * PERF_MAX_STACK_DEPTH, | 28 | .value_size = sizeof(__u64) * PERF_MAX_STACK_DEPTH, |
| 29 | .max_entries = 10000, | 29 | .max_entries = 16384, |
| 30 | }; | ||
| 31 | |||
| 32 | struct bpf_map_def SEC("maps") stack_amap = { | ||
| 33 | .type = BPF_MAP_TYPE_ARRAY, | ||
| 34 | .key_size = sizeof(__u32), | ||
| 35 | .value_size = sizeof(__u64) * PERF_MAX_STACK_DEPTH, | ||
| 36 | .max_entries = 16384, | ||
| 30 | }; | 37 | }; |
| 31 | 38 | ||
| 32 | /* taken from /sys/kernel/debug/tracing/events/sched/sched_switch/format */ | 39 | /* taken from /sys/kernel/debug/tracing/events/sched/sched_switch/format */ |
| @@ -44,7 +51,9 @@ struct sched_switch_args { | |||
| 44 | SEC("tracepoint/sched/sched_switch") | 51 | SEC("tracepoint/sched/sched_switch") |
| 45 | int oncpu(struct sched_switch_args *ctx) | 52 | int oncpu(struct sched_switch_args *ctx) |
| 46 | { | 53 | { |
| 54 | __u32 max_len = PERF_MAX_STACK_DEPTH * sizeof(__u64); | ||
| 47 | __u32 key = 0, val = 0, *value_p; | 55 | __u32 key = 0, val = 0, *value_p; |
| 56 | void *stack_p; | ||
| 48 | 57 | ||
| 49 | value_p = bpf_map_lookup_elem(&control_map, &key); | 58 | value_p = bpf_map_lookup_elem(&control_map, &key); |
| 50 | if (value_p && *value_p) | 59 | if (value_p && *value_p) |
| @@ -52,8 +61,12 @@ int oncpu(struct sched_switch_args *ctx) | |||
| 52 | 61 | ||
| 53 | /* The size of stackmap and stackid_hmap should be the same */ | 62 | /* The size of stackmap and stackid_hmap should be the same */ |
| 54 | key = bpf_get_stackid(ctx, &stackmap, 0); | 63 | key = bpf_get_stackid(ctx, &stackmap, 0); |
| 55 | if ((int)key >= 0) | 64 | if ((int)key >= 0) { |
| 56 | bpf_map_update_elem(&stackid_hmap, &key, &val, 0); | 65 | bpf_map_update_elem(&stackid_hmap, &key, &val, 0); |
| 66 | stack_p = bpf_map_lookup_elem(&stack_amap, &key); | ||
| 67 | if (stack_p) | ||
| 68 | bpf_get_stack(ctx, stack_p, max_len, 0); | ||
| 69 | } | ||
| 57 | 70 | ||
| 58 | return 0; | 71 | return 0; |
| 59 | } | 72 | } |
