linux_dsm_epyc7002/kernel/kcsan
Marco Elver 757a4cefde kcsan: Add support for scoped accesses
This adds support for scoped accesses, where the memory range is checked
for the duration of the scope. The feature is implemented by inserting
the relevant access information into a list of scoped accesses for
the current execution context, which are then checked (until removed)
on every call (through instrumentation) into the KCSAN runtime.

An alternative, more complex, implementation could set up a watchpoint for
the scoped access, and keep the watchpoint set up. This, however, would
require first exposing a handle to the watchpoint, as well as dealing
with cases such as accesses by the same thread while the watchpoint is
still set up (and several more cases). It is also doubtful if this would
provide any benefit, since the majority of delay where the watchpoint
is set up is likely due to the injected delays by KCSAN.  Therefore,
the implementation in this patch is simpler and avoids hurting KCSAN's
main use-case (normal data race detection); it also implicitly increases
scoped-access race-detection-ability due to increased probability of
setting up watchpoints by repeatedly calling __kcsan_check_access()
throughout the scope of the access.

The implementation required adding an additional conditional branch to
the fast-path. However, the microbenchmark showed a *speedup* of ~5%
on the fast-path. This appears to be due to subtly improved codegen by
GCC from moving get_ctx() and associated load of preempt_count earlier.

Suggested-by: Boqun Feng <boqun.feng@gmail.com>
Suggested-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
2020-04-13 17:18:11 -07:00
..
atomic.h kcsan: Add current->state to implicitly atomic accesses 2020-03-25 09:56:00 -07:00
core.c kcsan: Add support for scoped accesses 2020-04-13 17:18:11 -07:00
debugfs.c kcsan: Add current->state to implicitly atomic accesses 2020-03-25 09:56:00 -07:00
encoding.h kcsan: Prefer __always_inline for fast-path 2020-03-21 09:40:19 +01:00
kcsan.h kcsan: Avoid blocking producers in prepare_report() 2020-04-13 17:18:11 -07:00
Makefile kcsan, trace: Make KCSAN compatible with tracing 2020-03-21 09:44:41 +01:00
report.c kcsan: Add support for scoped accesses 2020-04-13 17:18:11 -07:00
test.c kcsan: Fix 0-sized checks 2020-03-21 09:42:42 +01:00