Skip to content

Commit 5a89753

Browse files
liu-song-6acmel
authored andcommitted
perf bpf_skel: Do not use typedef to avoid error on old clang
When building bpf_skel with clang-10, typedef causes confusions like: libbpf: map 'prev_readings': unexpected def kind var. Fix this by removing the typedef. Fixes: 7fac83a ("perf stat: Introduce 'bperf' to share hardware PMCs with BPF") Reported-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Song Liu <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent f7c4e85 commit 5a89753

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

tools/perf/util/bpf_skel/bperf.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

tools/perf/util/bpf_skel/bperf_follower.bpf.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,21 @@
33
#include "vmlinux.h"
44
#include <bpf/bpf_helpers.h>
55
#include <bpf/bpf_tracing.h>
6-
#include "bperf.h"
76
#include "bperf_u.h"
87

9-
reading_map diff_readings SEC(".maps");
10-
reading_map accum_readings SEC(".maps");
8+
struct {
9+
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
10+
__uint(key_size, sizeof(__u32));
11+
__uint(value_size, sizeof(struct bpf_perf_event_value));
12+
__uint(max_entries, 1);
13+
} diff_readings SEC(".maps");
14+
15+
struct {
16+
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
17+
__uint(key_size, sizeof(__u32));
18+
__uint(value_size, sizeof(struct bpf_perf_event_value));
19+
__uint(max_entries, 1);
20+
} accum_readings SEC(".maps");
1121

1222
struct {
1323
__uint(type, BPF_MAP_TYPE_HASH);

tools/perf/util/bpf_skel/bperf_leader.bpf.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "vmlinux.h"
44
#include <bpf/bpf_helpers.h>
55
#include <bpf/bpf_tracing.h>
6-
#include "bperf.h"
76

87
struct {
98
__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
@@ -12,8 +11,19 @@ struct {
1211
__uint(map_flags, BPF_F_PRESERVE_ELEMS);
1312
} events SEC(".maps");
1413

15-
reading_map prev_readings SEC(".maps");
16-
reading_map diff_readings SEC(".maps");
14+
struct {
15+
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
16+
__uint(key_size, sizeof(__u32));
17+
__uint(value_size, sizeof(struct bpf_perf_event_value));
18+
__uint(max_entries, 1);
19+
} prev_readings SEC(".maps");
20+
21+
struct {
22+
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
23+
__uint(key_size, sizeof(__u32));
24+
__uint(value_size, sizeof(struct bpf_perf_event_value));
25+
__uint(max_entries, 1);
26+
} diff_readings SEC(".maps");
1727

1828
SEC("raw_tp/sched_switch")
1929
int BPF_PROG(on_switch)

0 commit comments

Comments
 (0)