Skip to content

tracing: Support poll on event hist file

Masami Hiramatsu (Google) linux-kselftest linux-trace-kernel lkml 7 versions – In review

Get series with b4
b4 am 173527246726.464571.11533527581374142406.stgit@devnote2

Versions newest first · linked by author and title

  1. v7 Latest3 patches 1 replyIn review
  2. v63 patches 6 repliesSuperseded
  3. v53 patches 1 replySuperseded
Earlier versions · 4
VersionPostedPatchesRepliesStatus
v43 patches3 repliesSuperseded
v33 patches2 repliesSuperseded
v23 patches0 repliesSuperseded
v1 RFC3 patches2 repliesSuperseded

Patches in v7 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3tracing/hist: Add poll(POLLIN) support on hist fileinclude/linux/trace_events.h kernel/trace/trace_events.c kernel/trace/trace_events_hist.c+94 -30 replies
2/3tracing/hist: Support POLLPRI event for poll on histogramkernel/trace/trace_events_hist.c+26 -30 replies
3/3selftests/tracing: Add hist poll() support testtools/testing/selftests/ftrace/Makefile tools/testing/selftests/ftrace/poll.c tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-poll.tc+150 -01 reply
3/3selftests/tracing: Add hist poll() support testtools/testing/selftests/ftrace/Makefile tools/testing/selftests/ftrace/poll.c tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-poll.tc+150 -00 replies

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchTom ZanussiShuah Khan
1/3R-b
2/3R-b
3/3R-b R-b
3/3R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v7 thread

Cover letter [PATCH v7 0/3] tracing: Support poll on event hist file

Hi,

Here is the 7th version of the series to support polling on event 'hist' file. The previous version is here;

https://lore.kernel.org/all/172907575534.470540.12941248697563459082.stgit@mhiramat.roam.corp.google.com/

This version updates descriptions, use guard() for mutex and fixes selftest problem.

Background
----------
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.

Overview
--------
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.

Usage
-----
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 pri $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,

---

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                       |   14 +++
 kernel/trace/trace_events.c                        |   14 +++
 kernel/trace/trace_events_hist.c                   |   92 +++++++++++++++++++-
 tools/testing/selftests/ftrace/Makefile            |    2 
 tools/testing/selftests/ftrace/poll.c              |   74 ++++++++++++++++
 .../ftrace/test.d/trigger/trigger-hist-poll.tc     |   74 ++++++++++++++++
 6 files changed, 267 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) <[email protected]>