Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

instrumented.h: Introduce read-write instrumentation hooks

Introduce read-write instrumentation hooks, to more precisely denote an
operation's behaviour.

KCSAN is able to distinguish compound instrumentation, and with the new
instrumentation we then benefit from improved reporting. More
importantly, read-write compound operations should not implicitly be
treated as atomic, if they aren't actually atomic.

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>

authored by

Marco Elver and committed by
Paul E. McKenney
00047c2e bec4a247

+30
+30
include/linux/instrumented.h
··· 43 43 } 44 44 45 45 /** 46 + * instrument_read_write - instrument regular read-write access 47 + * 48 + * Instrument a regular write access. The instrumentation should be inserted 49 + * before the actual write happens. 50 + * 51 + * @ptr address of access 52 + * @size size of access 53 + */ 54 + static __always_inline void instrument_read_write(const volatile void *v, size_t size) 55 + { 56 + kasan_check_write(v, size); 57 + kcsan_check_read_write(v, size); 58 + } 59 + 60 + /** 46 61 * instrument_atomic_read - instrument atomic read access 47 62 * 48 63 * Instrument an atomic read access. The instrumentation should be inserted ··· 85 70 { 86 71 kasan_check_write(v, size); 87 72 kcsan_check_atomic_write(v, size); 73 + } 74 + 75 + /** 76 + * instrument_atomic_read_write - instrument atomic read-write access 77 + * 78 + * Instrument an atomic read-write access. The instrumentation should be 79 + * inserted before the actual write happens. 80 + * 81 + * @ptr address of access 82 + * @size size of access 83 + */ 84 + static __always_inline void instrument_atomic_read_write(const volatile void *v, size_t size) 85 + { 86 + kasan_check_write(v, size); 87 + kcsan_check_atomic_read_write(v, size); 88 88 } 89 89 90 90 /**