Commit 9678e531 authored by Petr Pavlu's avatar Petr Pavlu Committed by Steven Rostedt (Google)
Browse files

tracing: Wake up poll waiters for hist files when removing an event



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: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
Link: https://patch.msgid.link/20260219162737.314231-3-petr.pavlu@suse.com


Fixes: 1bd13edb ("tracing/hist: Add poll(POLLIN) support on hist file")
Signed-off-by: default avatarPetr Pavlu <petr.pavlu@suse.com>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent f0a0da1f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -683,6 +683,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)				\
+3 −0
Original line number Diff line number Diff line
@@ -1311,6 +1311,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();
}

/*