* [PATCH] perf: separate bpf_counter_list and bpf_filters
@ 2023-05-19 23:57 Song Liu
2023-05-26 19:03 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 2+ messages in thread
From: Song Liu @ 2023-05-19 23:57 UTC (permalink / raw)
To: linux-kernel; +Cc: acme, jolsa, kernel-team, Song Liu, Namhyung Kim
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)
Fix this issue by separating the two lists.
Fixes: 56ec9457a4a2 ("perf bpf filter: Implement event sample filtering")
Signed-off-by: Song Liu <song@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/evsel.c | 1 +
tools/perf/util/evsel.h | 6 ++----
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 2f5910b31fa9..c2dbb5647e75 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -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);
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index df8928745fc6..0f54f28a69c2 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -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;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] perf: separate bpf_counter_list and bpf_filters
2023-05-19 23:57 [PATCH] perf: separate bpf_counter_list and bpf_filters Song Liu
@ 2023-05-26 19:03 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-05-26 19:03 UTC (permalink / raw)
To: Song Liu; +Cc: linux-kernel, acme, jolsa, kernel-team, Namhyung Kim
Em Fri, May 19, 2023 at 04:57:57PM -0700, Song Liu escreveu:
> 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)
>
> Fix this issue by separating the two lists.
Thanks, applied.
- Arnaldo
> Fixes: 56ec9457a4a2 ("perf bpf filter: Implement event sample filtering")
> Signed-off-by: Song Liu <song@kernel.org>
> Acked-by: Namhyung Kim <namhyung@kernel.org>
> ---
> tools/perf/util/evsel.c | 1 +
> tools/perf/util/evsel.h | 6 ++----
> 2 files changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index 2f5910b31fa9..c2dbb5647e75 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -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);
> diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
> index df8928745fc6..0f54f28a69c2 100644
> --- a/tools/perf/util/evsel.h
> +++ b/tools/perf/util/evsel.h
> @@ -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;
> --
> 2.34.1
>
--
- Arnaldo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-26 19:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-19 23:57 [PATCH] perf: separate bpf_counter_list and bpf_filters Song Liu
2023-05-26 19:03 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox