From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ian Rogers <irogers@google.com>,
Kan Liang <kan.liang@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org,
Stephane Eranian <eranian@google.com>
Subject: [PATCH 0/4] perf bpf-filter: Add cgroup filter term (v1)
Date: Mon, 26 Aug 2024 15:10:41 -0700 [thread overview]
Message-ID: <20240826221045.1202305-1-namhyung@kernel.org> (raw)
Hello,
I'm adding a new 'cgroup' filter term in the filter expression so that
it can be used in the BPF.
The cgroup filter takes a pathname and allows either '==' or '!='
operators only. The requires '--all-cgroups' option so it can see the
cgroup_id in the sample data. Actually BPF programs can get the
cgroup of the current task without looking sample data, but I added it
for consistency with other fields.
$ sudo perf record --synth=cgroup -e cycles --filter 'cgroup > /' -a true
perf_bpf_filter: cgroup accepts '==' or '!=' only
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
--filter <filter>
event filter
$ sudo perf record -e cycles --filter 'cgroup == /' \
-a --synth=cgroup -o- sleep 1 | perf report -i- -s cgroup
Error: cycles event does not have PERF_SAMPLE_CGROUP
Hint: please add --all-cgroups option to perf record
Failed to process filter entries
failed to set filter "BPF" on event cycles with 2 (No such file or directory)
incompatible file format (rerun with -v to learn more)
On the filter syntax, it used to reject arbitrary strings. But it
needs to handle strings because of the cgroup paths. For now, the bpf
filter parser will reject strings if it's not used for cgroups.
For now, it only supports the exact matching of target cgroups. So
specifying the root cgroup ("/") will match tasks in the root cgroup
directly (not in the descendants).
$ sudo perf record --all-cgroups -e cycles --filter 'cgroup == /' \
-a --synth=cgroup -o- sleep 1 | perf report -i- -s cgroup
...
#
# Total Lost Samples: 0
#
# Samples: 621 of event 'cycles'
# Event count (approx.): 108101281
#
# Overhead Cgroup
# ........ ......
#
100.00% /
Thanks,
Namhyung
Namhyung Kim (4):
perf report: Fix segfault when 'sym' sort key is not used
perf bpf-filter: Add build dependency to header files
perf bpf-filter: Support filtering on cgroups
perf test: Add perf record cgroup filtering test
tools/perf/tests/shell/record_bpf_filter.sh | 39 ++++++++++++++++++--
tools/perf/util/Build | 4 +-
tools/perf/util/bpf-filter.c | 1 +
tools/perf/util/bpf-filter.l | 28 +++++++++++---
tools/perf/util/bpf-filter.y | 28 +++++++++++++-
tools/perf/util/bpf_skel/sample-filter.h | 2 +-
tools/perf/util/bpf_skel/sample_filter.bpf.c | 4 +-
tools/perf/util/bpf_skel/vmlinux/vmlinux.h | 1 +
tools/perf/util/hist.c | 2 +-
9 files changed, 94 insertions(+), 15 deletions(-)
--
2.46.0.295.g3b9ea8a38a-goog
next reply other threads:[~2024-08-26 22:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-26 22:10 Namhyung Kim [this message]
2024-08-26 22:10 ` [PATCH 1/4] perf report: Fix segfault when 'sym' sort key is not used Namhyung Kim
2024-08-28 21:23 ` Arnaldo Carvalho de Melo
2024-08-26 22:10 ` [PATCH 2/4] perf bpf-filter: Add build dependency to header files Namhyung Kim
2024-08-26 22:10 ` [PATCH 3/4] perf bpf-filter: Support filtering on cgroups Namhyung Kim
2024-08-26 22:10 ` [PATCH 4/4] perf test: Add perf record cgroup filtering test Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240826221045.1202305-1-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®