workflows.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Soham Bagchi <soham.bagchi@utah.edu>
To: elver@google.com
Cc: akpm@linux-foundation.org, andreyknvl@gmail.com, arnd@arndb.de,
	corbet@lwn.net, dvyukov@google.com, glider@google.com,
	kasan-dev@googlegroups.com, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, soham.bagchi@utah.edu,
	sohambagchi@outlook.com, tglx@linutronix.de,
	workflows@vger.kernel.org
Subject: [PATCH v2] kcov: load acquire coverage count in user-space code
Date: Sun,  3 Aug 2025 12:05:58 -0600	[thread overview]
Message-ID: <20250803180558.2967962-1-soham.bagchi@utah.edu> (raw)
In-Reply-To: <CANpmjNPWzJZrAFT3-013GJhksK0jkB6n0HmF+h0hdoQUwGuxfA@mail.gmail.com>

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@utah.edu>
---

Changes in v2:
- note for load-acquire shifted to block comment
  in code rather than in the preceding paragraphs
---
 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..40a4b500073 100644
--- a/Documentation/dev-tools/kcov.rst
+++ b/Documentation/dev-tools/kcov.rst
@@ -361,7 +361,12 @@ 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);
+        /*
+         * The load to the coverage count should be an acquire to pair with 
+         * pair with the corresponding write memory barrier (smp_wmb()) on 
+         * the kernel-side in kcov_move_area().
+         */
+	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


  reply	other threads:[~2025-08-03 18:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-28 18:43 [PATCH 1/2] kcov: use write memory barrier after memcpy() in kcov_move_area() Soham Bagchi
2025-07-28 18:43 ` [PATCH 2/2] kcov: load acquire coverage count in user-space code Soham Bagchi
2025-07-28 20:32   ` Marco Elver
2025-08-03 18:05     ` Soham Bagchi [this message]
2025-08-04  6:00       ` [PATCH v2] " Marco Elver
2025-08-07  0:36         ` Andrew Morton
2025-07-28 20:26 ` [PATCH 1/2] kcov: use write memory barrier after memcpy() in kcov_move_area() Marco Elver

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250803180558.2967962-1-soham.bagchi@utah.edu \
    --to=soham.bagchi@utah.edu \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@gmail.com \
    --cc=arnd@arndb.de \
    --cc=corbet@lwn.net \
    --cc=dvyukov@google.com \
    --cc=elver@google.com \
    --cc=glider@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sohambagchi@outlook.com \
    --cc=tglx@linutronix.de \
    --cc=workflows@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox