Skip to content

kcsan: Compound read-write instrumentation

Marco Elver linux-arch lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest8 patches 2 repliesIn review
  2. v18 patches 13 repliesSuperseded

Changes in v2 from the cover letter

* Fix CC_HAS_TSAN_COMPOUND_READ_BEFORE_WRITE: s/--param -tsan/--param tsan/
* Add some {} for readability.
* Rewrite commit message of 'kcsan: Skew delay to be longer for certain access types'.
* Update comment for gen-atomic-instrumented.sh.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8kcsan: Support compounded read-write instrumentationinclude/linux/kcsan-checks.h kernel/kcsan/core.c kernel/kcsan/report.c +1 more+53 -210 replies
2/8objtool, kcsan: Add __tsan_read_write to uaccess whitelisttools/objtool/check.c+5 -00 replies
3/8kcsan: Skew delay to be longer for certain access typeskernel/kcsan/core.c+7 -30 replies
4/8kcsan: Add missing CONFIG_KCSAN_IGNORE_ATOMICS checkskernel/kcsan/core.c+22 -80 replies
5/8kcsan: Test support for compound instrumentationkernel/kcsan/kcsan-test.c lib/Kconfig.kcsan+56 -140 replies
6/8instrumented.h: Introduce read-write instrumentation hooksinclude/linux/instrumented.h+30 -00 replies
7/8asm-generic/bitops: Use instrument_read_write() where appropriateinclude/asm-generic/bitops/instrumented-atomic.h include/asm-generic/bitops/instrumented-lock.h include/asm-generic/bitops/instrumented-non-atomic.h+7 -70 replies
8/8locking/atomics: Use read-write instrumentation for atomic RMWsinclude/asm-generic/atomic-instrumented.h scripts/atomic/gen-atomic-instrumented.sh+180 -1710 replies

Reviews trailers per patch

1 of 8 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchPeter Zijlstra (Intel)
SeriesA-b
1/8
2/8A-b
3/8
4/8
5/8
6/8
7/8
8/8

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/8] kcsan: Compound read-write instrumentation

This series adds support for enabling compounded read-write instrumentation, if supported by the compiler (Clang 12 will be the first compiler to support the feature). The new instrumentation is emitted for sets of memory accesses in the same basic block to the same address with at least one read appearing before a write. These typically result from compound operations such as ++, --, +=, -=, |=, &=, etc. but also equivalent forms such as "var = var + 1".

We can then benefit from improved performance (fewer instrumentation calls) and better reporting for such accesses. In addition, existing explicit instrumentation via instrumented.h was updated to use explicit read-write instrumentation where appropriate, so we can also benefit from the better report generation.

v2:
* Fix CC_HAS_TSAN_COMPOUND_READ_BEFORE_WRITE: s/--param -tsan/--param tsan/
* Add some {} for readability.
* Rewrite commit message of 'kcsan: Skew delay to be longer for certain access types'.
* Update comment for gen-atomic-instrumented.sh.

Marco Elver (8):
kcsan: Support compounded read-write instrumentation objtool, kcsan: Add __tsan_read_write to uaccess whitelist
kcsan: Skew delay to be longer for certain access types
kcsan: Add missing CONFIG_KCSAN_IGNORE_ATOMICS checks
kcsan: Test support for compound instrumentation instrumented.h: Introduce read-write instrumentation hooks asm-generic/bitops: Use instrument_read_write() where appropriate locking/atomics: Use read-write instrumentation for atomic RMWs

 include/asm-generic/atomic-instrumented.h     | 330 +++++++++---------
 .../asm-generic/bitops/instrumented-atomic.h  |   6 +-
 .../asm-generic/bitops/instrumented-lock.h    |   2 +-
 .../bitops/instrumented-non-atomic.h          |   6 +-
 include/linux/instrumented.h                  |  30 ++
 include/linux/kcsan-checks.h                  |  45 ++-
 kernel/kcsan/core.c                           |  51 ++-
 kernel/kcsan/kcsan-test.c                     |  65 +++-
 kernel/kcsan/report.c                         |   4 +
 lib/Kconfig.kcsan                             |   5 +
 scripts/Makefile.kcsan                        |   2 +-
 scripts/atomic/gen-atomic-instrumented.sh     |  21 +-
 tools/objtool/check.c                         |   5 +
 13 files changed, 354 insertions(+), 218 deletions(-)
Signature · 1 line
2.28.0.rc0.142.g3c755180ce-goog