]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
tracing: Wake up poll waiters for hist files when removing an event
authorPetr Pavlu <petr.pavlu@suse.com>
Thu, 19 Feb 2026 16:27:02 +0000 (17:27 +0100)
committerSasha Levin <sashal@kernel.org>
Wed, 4 Mar 2026 12:21:35 +0000 (07:21 -0500)
[ Upstream commit 9678e53179aa7e907360f5b5b275769008a69b80 ]

The event_hist_poll() function attempts to verify whether an event file is
being removed, but this check may not occur or could be unnecessarily
delayed. This happens because hist_poll_wakeup() is currently invoked only
from event_hist_trigger() when a hist command is triggered. If the event
file is being removed, no associated hist command will be triggered and a
waiter will be woken up only after an unrelated hist command is triggered.

Fix the issue by adding a call to hist_poll_wakeup() in
remove_event_file_dir() after setting the EVENT_FILE_FL_FREED flag. This
ensures that a task polling on a hist file is woken up and receives
EPOLLERR.

Cc: stable@vger.kernel.org
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Tom Zanussi <zanussi@kernel.org>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Link: https://patch.msgid.link/20260219162737.314231-3-petr.pavlu@suse.com
Fixes: 1bd13edbbed6 ("tracing/hist: Add poll(POLLIN) support on hist file")
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/trace_events.h
kernel/trace/trace_events.c

index 04307a19cde30587d9cbfcc87bc2f4b3713b084f..64ada9cc38864c639ad688c2dfa94db33405cbef 100644 (file)
@@ -682,6 +682,11 @@ static inline void hist_poll_wakeup(void)
 
 #define hist_poll_wait(file, wait)     \
        poll_wait(file, &hist_poll_wq, wait)
+
+#else
+static inline void hist_poll_wakeup(void)
+{
+}
 #endif
 
 #define __TRACE_EVENT_FLAGS(name, value)                               \
index 5cf55a9c6fad4b02ca11309d9b5cb34ec52fc55a..e4ce7f856f6300273ad3b1605bb8207ce5e74296 100644 (file)
@@ -1296,6 +1296,9 @@ static void remove_event_file_dir(struct trace_event_file *file)
        free_event_filter(file->filter);
        file->flags |= EVENT_FILE_FL_FREED;
        event_file_put(file);
+
+       /* Wake up hist poll waiters to notice the EVENT_FILE_FL_FREED flag. */
+       hist_poll_wakeup();
 }
 
 /*