Skip to content

Commit d124144

Browse files
authored
libbpf-tools: llcstat: Fix error: redefinition of 'key_info' on aarch64 (#5265)
Rename key_info to llcsta_key_info, at the same time, in order to ensure the consistency of key-value naming, rename value_info to llvstat_value_info. $ make ... BPF llcstat.bpf.o In file included from llcstat.bpf.c:7: ./llcstat.h:13:8: error: redefinition of 'key_info' 13 | struct key_info { | ^ arm64/vmlinux.h:140310:8: note: previous definition is here 140310 | struct key_info { | ^ llcstat.bpf.c:27:6: error: no member named 'cpu' in 'struct key_info' 27 | key.cpu = bpf_get_smp_processor_id(); | ~~~ ^ llcstat.bpf.c:28:6: error: no member named 'pid' in 'struct key_info' 28 | key.pid = pid_tgid >> 32; | ~~~ ^ llcstat.bpf.c:30:7: error: no member named 'tid' in 'struct key_info' 30 | key.tid = (u32)pid_tgid; | ~~~ ^ llcstat.bpf.c:32:7: error: no member named 'tid' in 'struct key_info' 32 | key.tid = key.pid; | ~~~ ^ llcstat.bpf.c:32:17: error: no member named 'pid' in 'struct key_info' 32 | key.tid = key.pid; | ~~~ ^ 6 errors generated. make: *** [Makefile:207: /home/rongtao/Git/bcc/libbpf-tools/.output/llcstat.bpf.o] Error 1 Signed-off-by: Rong Tao <[email protected]>
1 parent 97eaeca commit d124144

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

libbpf-tools/llcstat.bpf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ const volatile bool targ_per_thread = false;
1313
struct {
1414
__uint(type, BPF_MAP_TYPE_HASH);
1515
__uint(max_entries, MAX_ENTRIES);
16-
__type(key, struct key_info);
17-
__type(value, struct value_info);
16+
__type(key, struct llcstat_key_info);
17+
__type(value, struct llcstat_value_info);
1818
} infos SEC(".maps");
1919

2020
static __always_inline
2121
int trace_event(__u64 sample_period, bool miss)
2222
{
23-
struct key_info key = {};
24-
struct value_info *infop, zero = {};
23+
struct llcstat_key_info key = {};
24+
struct llcstat_value_info *infop, zero = {};
2525

2626
u64 pid_tgid = bpf_get_current_pid_tgid();
2727
key.cpu = bpf_get_smp_processor_id();

libbpf-tools/llcstat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ static void print_map(struct bpf_map *map)
139139
{
140140
__u64 total_ref = 0, total_miss = 0, total_hit, hit;
141141
__u32 pid, cpu, tid;
142-
struct key_info lookup_key = { .cpu = -1 }, next_key;
142+
struct llcstat_key_info lookup_key = { .cpu = -1 }, next_key;
143143
int err, fd = bpf_map__fd(map);
144-
struct value_info info;
144+
struct llcstat_value_info info;
145145

146146
while (!bpf_map_get_next_key(fd, &lookup_key, &next_key)) {
147147
err = bpf_map_lookup_elem(fd, &next_key, &info);

libbpf-tools/llcstat.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
#define TASK_COMM_LEN 16
66

7-
struct value_info {
7+
struct llcstat_value_info {
88
__u64 ref;
99
__u64 miss;
1010
char comm[TASK_COMM_LEN];
1111
};
1212

13-
struct key_info {
13+
struct llcstat_key_info {
1414
__u32 cpu;
1515
__u32 pid;
1616
__u32 tid;

0 commit comments

Comments
 (0)