Re: [PATCH -rcu/kcsan 16/23] locking/atomics, kcsan: Add instrumentation for barriers

From
Marco Elver <elver@google.com>
Date
2021-10-05 12:17:10
Also in
linux-arch, linux-kbuild, linux-mm, lkml
Reply to
Peter Zijlstra, 2021-10-05
On Tue, 5 Oct 2021 at 14:03, Peter Zijlstra [off-list ref] wrote:
On Tue, Oct 05, 2021 at 12:58:58PM +0200, Marco Elver wrote:
quoted
@@ -59,6 +60,7 @@ atomic_add(int i, atomic_t *v)
 static __always_inline int
 atomic_add_return(int i, atomic_t *v)
 {
+     kcsan_mb();
      instrument_atomic_read_write(v, sizeof(*v));
      return arch_atomic_add_return(i, v);
 }
This and others,.. is this actually correct? Should that not be
something like:

        kscan_mb();
        instrument_atomic_read_write(...);
        ret = arch_atomic_add_return(i, v);
        kcsan_mb();
        return ret;

?
In theory, yes, but right now it's redundant.

Because right now KCSAN only models "buffering", and no "prefetching".
So there's no way that a later instruction would be reordered before
this point. And atomic accesses are never considered for reordering,
so it's also impossible that it would  be reordered later.

Each kcsan_mb() is a call, so right now it makes sense to just have 1
call to be a bit more efficient.
Thread (36 messages) 36 messages, 2 authors, last reply 2021-11-11
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help