From 55f2184bbbd5415c6378359e1c28e0a9da97e66f Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Fri, 1 Apr 2022 08:41:17 -0400 Subject: [PATCH] Fix: notification: kernel: consumption of event notification stalls MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Observed issue ============== Using: lttng add-trigger --condition event-rule-matches --type kernel:tracepoint --name "sched_waking" --capture comm --action notify The sessiond receives multiple event notifications from the kernel event source then stop receiving despite the kernel event source buffer being full. Cause ===== It turns out that the kernel event source, when reaching near the end of its buffer capacity, raises the POLLPRI [1] flag and not the POLLIN flag. Solution ======== lttng-modules stretches a bit the usage of POLLPRI as defined by the man page (man 2 poll): There is some exceptional condition on the file descriptor. Possibilities include: * There is out-of-band data on a TCP socket (see tcp(7)). * A pseudoterminal master in packet mode has seen a state change on the slave (see ioctl_tty(2)). * A cgroup.events file has been modified (see cgroups(7)). Still, even if lttng-modules changes how it does things, lttng-tools needs to support other lttng-modules versions. Thus, add LPOLLPRI (EPOLLPRI/POLLPRI) to the event mask when dealing with notification event sources. Note ===== In the future, during the poll loop we could also prioritize event sources in POLLPRI 'state'. Known drawbacks ========= None. References ========== [1] https://github.com/lttng/lttng-modules/blob/c312bda00d2dc10ce5f6c1189acbefee5c6c8c6c/src/lttng-abi.c#L1169 Signed-off-by: Mathieu Desnoyers Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau Change-Id: Ieb428ef1037c8eb197b489a38a1ae5216ac63d4b --- src/bin/lttng-sessiond/notification-thread-events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/lttng-sessiond/notification-thread-events.c b/src/bin/lttng-sessiond/notification-thread-events.c index 1388b3ce3..1e8618c60 100644 --- a/src/bin/lttng-sessiond/notification-thread-events.c +++ b/src/bin/lttng-sessiond/notification-thread-events.c @@ -2039,7 +2039,7 @@ int handle_notification_thread_command_add_tracer_event_source( lttng_domain_type_str(domain_type)); /* Adding the read side pipe to the event poll. */ - ret = lttng_poll_add(&state->events, tracer_event_source_fd, LPOLLIN | LPOLLERR); + ret = lttng_poll_add(&state->events, tracer_event_source_fd, LPOLLPRI | LPOLLIN | LPOLLERR); if (ret < 0) { ERR("Failed to add tracer event source to poll set: tracer_event_source_fd = %d, domain = '%s'", tracer_event_source_fd, -- 2.34.1