From: Leo Yan <leo.yan@linaro.org>
To: Kees Cook <kees@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>, linux-perf-users@vger.kernel.org
Subject: Re: Getting PMU stats on specific syscalls
Date: Wed, 10 Jan 2024 09:52:09 +0800 [thread overview]
Message-ID: <20240110015209.GB44@debian-dev> (raw)
In-Reply-To: <7CD8ADB1-7BAF-4BAD-A8C5-285BC148E691@kernel.org>
On Tue, Jan 09, 2024 at 05:01:59PM -0800, Kees Cook wrote:
[...]
> >> I can't figure out how to limit collection to only time spent during the
> >> syscall I'm interested in. I tried building synthetic events, but that
> >> doesn't seem to work...
> >
> >Hmm.. ok. it seems you want to use PMU only for a syscall.
> >I don't think perf supports that for now, but maybe it's possible
> >to attach custom BPF programs to read perf counters at syscall
> >enter and exit and to save the diff in a map.
>
> Does BPF have access to the PMU counters? I don't know how to even approach writing that though. :P
An alternative is to use ftrace's function_graph tracer to measure a
function duration, e.g.
# cd /sys/kernel/debug/tracing
# echo syscall_function_name > set_graph_function
# echo function_graph > current_tracer
do some test
# cat trace
I think you even can access the PMU counter for measurement duration
in user space - though you might cannot directly measure a specific
syscall, see:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/lib/perf/tests/test-evsel.c#n127
Thanks,
Leo
next prev parent reply other threads:[~2024-01-10 1:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-09 22:55 Getting PMU stats on specific syscalls Kees Cook
2024-01-09 23:52 ` Namhyung Kim
2024-01-10 1:01 ` Kees Cook
2024-01-10 1:52 ` Leo Yan [this message]
[not found] ` <CA+JHD90kw0CX9=E18A7NBJrxdPDQuwrew355RV47oBhn_1s_QQ@mail.gmail.com>
2024-01-10 1:04 ` Kees Cook
2024-01-10 1:45 ` Arnaldo Carvalho de Melo
2024-01-11 0:40 ` Kees Cook
2024-01-11 15:53 ` Arnaldo Carvalho de Melo
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=20240110015209.GB44@debian-dev \
--to=leo.yan@linaro.org \
--cc=kees@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=namhyung@kernel.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;
as well as URLs for NNTP newsgroup(s).