Skip to content

Commit

Permalink
perf evsel: Separate bpf_counter_list and bpf_filters, can be used at…
Browse files Browse the repository at this point in the history
… 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>
  • Loading branch information
Song Liu authored and Arnaldo Carvalho de Melo committed May 26, 2023
1 parent c8268a9 commit c041d33
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions tools/perf/util/evsel.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ void evsel__init(struct evsel *evsel,
evsel->bpf_fd = -1;
INIT_LIST_HEAD(&evsel->config_terms);
INIT_LIST_HEAD(&evsel->bpf_counter_list);
INIT_LIST_HEAD(&evsel->bpf_filters);
perf_evsel__object.init(evsel);
evsel->sample_size = __evsel__sample_size(attr->sample_type);
evsel__calc_id_pos(evsel);
Expand Down
6 changes: 2 additions & 4 deletions tools/perf/util/evsel.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,8 @@ struct evsel {
*/
struct bpf_counter_ops *bpf_counter_ops;

union {
struct list_head bpf_counter_list; /* for perf-stat -b */
struct list_head bpf_filters; /* for perf-record --filter */
};
struct list_head bpf_counter_list; /* for perf-stat -b */
struct list_head bpf_filters; /* for perf-record --filter */

/* for perf-stat --use-bpf */
int bperf_leader_prog_fd;
Expand Down

0 comments on commit c041d33

Please sign in to comment.