From: Jérémie Galarneau Date: Tue, 7 Jul 2020 22:55:19 +0000 (-0400) Subject: Fix: kconsumer: missing wait for metadata thread in do_sync_metadata X-Git-Tag: v2.12.2~23 X-Git-Url: https://git.lttng.org/?a=commitdiff_plain;h=835322daf113621378d9ecc5b0f366ba1abaeb62;hp=835322daf113621378d9ecc5b0f366ba1abaeb62;p=lttng-tools.git Fix: kconsumer: missing wait for metadata thread in do_sync_metadata The `do_sync_metadata` function is invoked everytime a data sub-buffer is consumed in live mode. In the user space case, lttng_ustconsumer_sync_metadata() returns EAGAIN (positive) when there is new metadata to consume. This causes the "metadata rendez-vous" synchronization to take place. However, the kernel variant of this function returns 0 when there is new data to consume, causing the "rendez-vous" to be skipped. I have not observed an issue caused by this first-hand, but the check appears bogus and skips over an essential synchronization step. This check has been in place since at least 2013, although the callees and their return values may have changed at some point in the past. Solution -------- The user space and kernel code paths mix various return code conventions (negative errno, positive errno, 0/-1) which makes it difficult to understand the final return codes and most likely lead to this confusion in the first place. Moreover, returning EAGAIN to indicate that data is ready to be consumed is not appropriate in view of the existing conventions in the code base. An explicit `enum sync_metadata_status` is returned by the domains' sync_metadata operations which allows the common code to handle the various conditions in a straight-forward manner and for the "rendez-vous" to take place in the kernel case. Reported-by: Francis Deslauriers Signed-off-by: Jérémie Galarneau Change-Id: Ib022eee97054c0b376853dd05593e3b94bc9a8ca ---