linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/3] Use BPF filters for a "perf top -u" workaround
@ 2024-05-16  4:19 Ian Rogers
  2024-05-16  4:19 ` [PATCH v1 1/3] perf bpf filter: Give terms their own enum Ian Rogers
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Ian Rogers @ 2024-05-16  4:19 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Kan Liang, Changbin Du, John Fastabend,
	Andrii Nakryiko, linux-perf-users, linux-kernel, bpf

Allow uid and gid to be terms in BPF filters by first breaking the
connection between filter terms and PERF_SAMPLE_xx values. Calculate
the uid and gid using the bpf_get_current_uid_gid helper, rather than
from a value in the sample. Allow filters to be passed to perf top, this allows:

$ perf top -e cycles:P --filter "uid == $(id -u)"

to work as a "perf top -u" workaround, as "perf top -u" usually fails
due to processes/threads terminating between the /proc scan and the
perf_event_open.

Ian Rogers (3):
  perf bpf filter: Give terms their own enum
  perf bpf filter: Add uid and gid terms
  perf top: Allow filters on events

 tools/perf/Documentation/perf-record.txt     |  2 +-
 tools/perf/Documentation/perf-top.txt        |  4 ++
 tools/perf/builtin-top.c                     |  9 +++
 tools/perf/util/bpf-filter.c                 | 55 ++++++++++++----
 tools/perf/util/bpf-filter.h                 |  5 +-
 tools/perf/util/bpf-filter.l                 | 66 +++++++++----------
 tools/perf/util/bpf-filter.y                 |  7 +-
 tools/perf/util/bpf_skel/sample-filter.h     | 27 +++++++-
 tools/perf/util/bpf_skel/sample_filter.bpf.c | 67 +++++++++++++++-----
 9 files changed, 172 insertions(+), 70 deletions(-)

-- 
2.45.0.rc1.225.g2a3ae87e7f-goog


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-05-20 20:27 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-16  4:19 [PATCH v1 0/3] Use BPF filters for a "perf top -u" workaround Ian Rogers
2024-05-16  4:19 ` [PATCH v1 1/3] perf bpf filter: Give terms their own enum Ian Rogers
2024-05-18  1:36   ` Namhyung Kim
2024-05-18  3:29     ` Ian Rogers
2024-05-20 20:27       ` Namhyung Kim
2024-05-16  4:19 ` [PATCH v1 2/3] perf bpf filter: Add uid and gid terms Ian Rogers
2024-05-16  4:19 ` [PATCH v1 3/3] perf top: Allow filters on events Ian Rogers
2024-05-16  5:04 ` [PATCH v1 0/3] Use BPF filters for a "perf top -u" workaround Ian Rogers
2024-05-16 17:34   ` Ian Rogers
2024-05-18  1:21     ` Namhyung Kim
2024-05-16 21:47   ` Ian Rogers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).