]> www.infradead.org Git - users/jedix/linux-maple.git/commit
tracing/hist: Add poll(POLLIN) support on hist file
authorMasami Hiramatsu (Google) <mhiramat@kernel.org>
Fri, 27 Dec 2024 04:07:57 +0000 (13:07 +0900)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Tue, 7 Jan 2025 16:44:49 +0000 (11:44 -0500)
commit1bd13edbbed6e7e396f1aab92b224a4775218e68
treef6e3cd314894a1d799115fec2475e2d5ce513765
parent22bec11a569983f39c6061cb82279e7de9e3bdfc
tracing/hist: Add poll(POLLIN) support on hist file

Add poll syscall support on the `hist` file. The Waiter will be waken
up when the histogram is updated with POLLIN.

Currently, there is no way to wait for a specific event in userspace.
So user needs to peek the `trace` periodicaly, or wait on `trace_pipe`.
But it is not a good idea to peek at the `trace` for an event that
randomly happens. And `trace_pipe` is not coming back until a page is
filled with events.

This allows a user to wait for a specific event on the `hist` file. User
can set a histogram trigger on the event which they want to monitor
and poll() on its `hist` file. Since this poll() returns POLLIN, the next
poll() will return soon unless a read() happens on that hist file.

NOTE: To read the hist file again, you must set the file offset to 0,
but just for monitoring the event, you may not need to read the
histogram.

Cc: Shuah Khan <shuah@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://lore.kernel.org/173527247756.464571.14236296701625509931.stgit@devnote2
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Reviewed-by: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
include/linux/trace_events.h
kernel/trace/trace_events.c
kernel/trace/trace_events_hist.c