From: Namhyung Kim <namhyung@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>
Subject: Re: [PATCH] perf ftrace latency: Do not read trace files when BPF is used
Date: Fri, 28 Aug 2026 09:59:54 -0700 [thread overview]
Message-ID: <apG-ij-tYyK9cBSj@google.com> (raw)
In-Reply-To: <CAP-5=fVfmWQaE45Y=pA1rE5JxQLKhfN82+yfRqQE7Hjrb8=aOQ@mail.gmail.com>
Hi Ian,
On Wed, Aug 26, 2026 at 02:36:27PM -0700, Ian Rogers wrote:
> On Wed, Aug 26, 2026 at 11:58 AM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > I've realized that it didn't set up the tracing files when BPF is used
> > so poll() just returns immediately. It ends up with calling poll()
> > unnecessarily in a loop.
> >
> > BPF still needs the loop to wait for the target process exiting or a
> > signal from users. Let's sleep for 1 msec and check that.
> >
> > Cc: Steven Rostedt <rostedt@goodmis.org>
> > Cc: Masami Hiramatsu <mhiramat@kernel.org>
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > ---
> > tools/perf/builtin-ftrace.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
> > index 4f881a40c311ae52..e61b9de11e1e41c7 100644
> > --- a/tools/perf/builtin-ftrace.c
> > +++ b/tools/perf/builtin-ftrace.c
> > @@ -1146,6 +1146,11 @@ static int __cmd_latency(struct perf_ftrace *ftrace)
> >
> > line[0] = '\0';
> > while (!done) {
> > + if (ftrace->target.use_bpf) {
> > + usleep(1000);
> > + continue;
> > + }
> > +
>
> To avoid the busy waiting could we:
> ```
> // Globaly:
> sem_t sig_sem;
> ...
> // Prior to setting up the signal handler:
> sem_init(&sig_sem, 0, 0);
> ...
> // Here:
> if (ftrace->target.use_bpf) {
> sem_wait(&sig_sem);
> } else {
> while (!done) {
> ...
> }
> // In the signal handler:
> if (ftrace->target.use_bpf) {
> sem_post(&sig_sem);
> }
> ...
> // After removing the signal handler:
> sem_destroy(&sig_sem);
> ```
Looks better, will check.
Thanks,
Namhyung
prev parent reply other threads:[~2026-08-28 17:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 18:58 [PATCH] perf ftrace latency: Do not read trace files when BPF is used Namhyung Kim
2026-08-26 19:10 ` sashiko-bot
2026-08-26 21:36 ` Ian Rogers
2026-08-28 16:59 ` Namhyung Kim [this message]
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=apG-ij-tYyK9cBSj@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.