From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Tom Zanussi <zanussi@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Shuah Khan <shuah@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [RFC PATCH 0/3] tracing: Support poll on event hist file
Date: Wed, 3 Jul 2024 08:08:14 +0900 [thread overview]
Message-ID: <20240703080814.c8bbe5b27ad70a5520262a6d@kernel.org> (raw)
In-Reply-To: <4ec0e4822293763691d8699750b0df88385ab646.camel@kernel.org>
On Sun, 30 Jun 2024 16:07:43 -0500
Tom Zanussi <zanussi@kernel.org> wrote:
> Hi Masami,
>
> On Wed, 2024-06-26 at 00:16 +0900, Masami Hiramatsu (Google) wrote:
> > Hi,
> >
> > Here is an RFC patch to support polling on event 'hist' file.
> >
> > There has been interest in allowing user programs to monitor kernel
> > events in real time. Ftrace provides `trace_pipe` interface to wait
> > on events in the ring buffer, but it is needed to wait until filling
> > up a page with events in the ring buffer. We can also peek the
> > `trace` file periodically, but that is inefficient way to monitor
> > a randomely happening event.
> >
> > This patch set allows user to `poll`(or `select`, `epoll`) on event
> > histogram interface. As you know each event has its own `hist` file
> > which shows histograms generated by trigger action. So user can set
> > a new hist trigger on any event you want to monitor, and poll on the
> > `hist` file until it is updated.
> >
> > There are 2 poll events are supported, POLLIN and POLLPRI. POLLIN
> > means that there are any readable update on `hist` file and this
> > event will be flashed only when you call read(). So, this is
> > useful if you want to read the histogram periodically.
> > The other POLLPRI event is for monitoring trace event. Like the
> > POLLIN, this will be returned when the histogram is updated, but
> > you don't need to read() the file and use poll() again.
> >
> > Note that this waits for histogram update (not event arrival), thus
> > you must set a histogram on the event at first.
> >
> > Here is an example usage:
> >
> > ----
> > TRACEFS=/sys/kernel/tracing
> > EVENT=$TRACEFS/events/sched/sched_process_free
> >
> > # setup histogram trigger and enable event
> > echo "hist:key=comm" >> $EVENT/trigger
> > echo 1 > $EVENT/enable
> >
> > # Wait for update
> > poll $EVENT/hist
> >
> > # Event arrived.
> > echo "process free event is comming"
> > tail $TRACEFS/trace
> > ----
> >
> > The 'poll' command is in the selftest patch.
> >
> > You can take this series also from here;
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/mhiramat/linux.git/log/?h=topic/event-hist-poll
> >
> > Thank you,
>
> I think this is a clever use of the histogram files, and will be very
> useful for real-time monitoring apps. I'm looking forward to using it
> myself - thanks for doing this.
>
> For the whole series,
>
> Reviewed-by: Tom Zanussi <zanussi@kernel.org>
Thanks Tom!
I found an issue in the selftests (can not support old stable kernel) so
let me update it.
Thank you,
>
> >
> > ---
> >
> > Masami Hiramatsu (Google) (3):
> > tracing/hist: Add poll(POLLIN) support on hist file
> > tracing/hist: Support POLLPRI event for poll on histogram
> > selftests/tracing: Add hist poll() support test
> >
> >
> > include/linux/trace_events.h | 5 +
> > kernel/trace/trace_events.c | 18 ++++
> > kernel/trace/trace_events_hist.c | 101
> > +++++++++++++++++++-
> > tools/testing/selftests/ftrace/Makefile | 3 +
> > tools/testing/selftests/ftrace/poll.c | 34 +++++++
> > .../ftrace/test.d/trigger/trigger-hist-poll.tc | 46 +++++++++
> > 6 files changed, 204 insertions(+), 3 deletions(-)
> > create mode 100644 tools/testing/selftests/ftrace/poll.c
> > create mode 100644
> > tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-poll.tc
> >
> > --
> > Masami Hiramatsu (Google) <mhiramat@kernel.org>
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
prev parent reply other threads:[~2024-07-02 23:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-25 15:16 [RFC PATCH 0/3] tracing: Support poll on event hist file Masami Hiramatsu (Google)
2024-06-25 15:17 ` [RFC PATCH 1/3] tracing/hist: Add poll(POLLIN) support on " Masami Hiramatsu (Google)
2024-06-25 15:17 ` [RFC PATCH 2/3] tracing/hist: Support POLLPRI event for poll on histogram Masami Hiramatsu (Google)
2024-06-25 15:17 ` [RFC PATCH 3/3] selftests/tracing: Add hist poll() support test Masami Hiramatsu (Google)
2024-06-30 21:07 ` [RFC PATCH 0/3] tracing: Support poll on event hist file Tom Zanussi
2024-07-02 23:08 ` Masami Hiramatsu [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=20240703080814.c8bbe5b27ad70a5520262a6d@kernel.org \
--to=mhiramat@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=rostedt@goodmis.org \
--cc=shuah@kernel.org \
--cc=zanussi@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 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.