Skip to content

Commit c041d33

Browse files
liu-song-6acmel
authored andcommitted
perf evsel: Separate bpf_counter_list and bpf_filters, can be used at the same time
'struct evsel' uses a union for the two lists. This turned out to be error prone. For example: [root@quaco ~]# perf stat --bpf-prog 5246 Error: cpu-clock event does not have sample flags 66c660 failed to set filter "(null)" on event cpu-clock with 2 (No such file or directory) [root@quaco ~]# perf stat --bpf-prog 5246 Fix this issue by separating the two lists. Fixes: 56ec945 ("perf bpf filter: Implement event sample filtering") Signed-off-by: Song Liu <song@kernel.org> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: kernel-team@meta.com Link: https://lore.kernel.org/r/20230519235757.3613719-1-song@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent c8268a9 commit c041d33

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

tools/perf/util/evsel.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ void evsel__init(struct evsel *evsel,
282282
evsel->bpf_fd = -1;
283283
INIT_LIST_HEAD(&evsel->config_terms);
284284
INIT_LIST_HEAD(&evsel->bpf_counter_list);
285+
INIT_LIST_HEAD(&evsel->bpf_filters);
285286
perf_evsel__object.init(evsel);
286287
evsel->sample_size = __evsel__sample_size(attr->sample_type);
287288
evsel__calc_id_pos(evsel);

tools/perf/util/evsel.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,8 @@ struct evsel {
151151
*/
152152
struct bpf_counter_ops *bpf_counter_ops;
153153

154-
union {
155-
struct list_head bpf_counter_list; /* for perf-stat -b */
156-
struct list_head bpf_filters; /* for perf-record --filter */
157-
};
154+
struct list_head bpf_counter_list; /* for perf-stat -b */
155+
struct list_head bpf_filters; /* for perf-record --filter */
158156

159157
/* for perf-stat --use-bpf */
160158
int bperf_leader_prog_fd;

0 commit comments

Comments
 (0)