[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250728184318.1839137-2-soham.bagchi@utah.edu>
Date: Mon, 28 Jul 2025 12:43:18 -0600
From: Soham Bagchi <soham.bagchi@...h.edu>
To: dvyukov@...gle.com,
andreyknvl@...il.com,
elver@...gle.com,
akpm@...ux-foundation.org,
tglx@...utronix.de,
glider@...gle.com,
sohambagchi@...look.com,
arnd@...db.de,
kasan-dev@...glegroups.com,
linux-kernel@...r.kernel.org,
corbet@....net,
workflows@...r.kernel.org,
linux-doc@...r.kernel.org
Cc: Soham Bagchi <soham.bagchi@...h.edu>
Subject: [PATCH 2/2] kcov: load acquire coverage count in user-space code
Updating the KCOV documentation to use a load-acquire
operation for the first element of the shared memory
buffer between kernel-space and user-space.
The load-acquire pairs with the write memory barrier
used in kcov_move_area()
Signed-off-by: Soham Bagchi <soham.bagchi@...h.edu>
---
Documentation/dev-tools/kcov.rst | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/Documentation/dev-tools/kcov.rst b/Documentation/dev-tools/kcov.rst
index 6611434e2dd..46450fb46fe 100644
--- a/Documentation/dev-tools/kcov.rst
+++ b/Documentation/dev-tools/kcov.rst
@@ -287,6 +287,11 @@ handle instance id.
The following program demonstrates using KCOV to collect coverage from both
local tasks spawned by the process and the global task that handles USB bus #1:
+The user-space code for KCOV should also use an acquire to fetch the count
+of coverage entries in the shared buffer. This acquire pairs with the
+corresponding write memory barrier (smp_wmb()) on the kernel-side in
+kcov_move_area().
+
.. code-block:: c
/* Same includes and defines as above. */
@@ -361,7 +366,7 @@ local tasks spawned by the process and the global task that handles USB bus #1:
*/
sleep(2);
- n = __atomic_load_n(&cover[0], __ATOMIC_RELAXED);
+ n = __atomic_load_n(&cover[0], __ATOMIC_ACQUIRE);
for (i = 0; i < n; i++)
printf("0x%lx\n", cover[i + 1]);
if (ioctl(fd, KCOV_DISABLE, 0))
--
2.34.1
Powered by blists - more mailing lists