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

Configure Feed

Select the types of activity you want to include in your feed.

compiler-context-analysis: Introduce header suppressions

While we can opt in individual subsystems which add the required
annotations, such subsystems inevitably include headers from other
subsystems which may not yet have the right annotations, which then
result in false positive warnings.

Making compatible by adding annotations across all common headers
currently requires an excessive number of __no_context_analysis
annotations, or carefully analyzing non-trivial cases to add the correct
annotations. While this is desirable long-term, providing an incremental
path causes less churn and headaches for maintainers not yet interested
in dealing with such warnings.

Rather than clutter headers unnecessary and mandate all subsystem
maintainers to keep their headers working with context analysis,
suppress all -Wthread-safety warnings in headers. Explicitly opt in
headers with context-enabled primitives.

With this in place, we can start enabling the analysis on more complex
subsystems in subsequent changes.

Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20251219154418.3592607-26-elver@google.com

authored by

Marco Elver and committed by
Peter Zijlstra
c237f1ce e4588c25

+36
+4
scripts/Makefile.context-analysis
··· 4 4 -fexperimental-late-parse-attributes -Wthread-safety \ 5 5 -Wthread-safety-pointer -Wthread-safety-beta 6 6 7 + ifndef CONFIG_WARN_CONTEXT_ANALYSIS_ALL 8 + context-analysis-cflags += --warning-suppression-mappings=$(srctree)/scripts/context-analysis-suppression.txt 9 + endif 10 + 7 11 export CFLAGS_CONTEXT_ANALYSIS := $(context-analysis-cflags)
+32
scripts/context-analysis-suppression.txt
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # 3 + # The suppressions file should only match common paths such as header files. 4 + # For individual subsytems use Makefile directive CONTEXT_ANALYSIS := [yn]. 5 + # 6 + # The suppressions are ignored when CONFIG_WARN_CONTEXT_ANALYSIS_ALL is 7 + # selected. 8 + 9 + [thread-safety] 10 + src:*arch/*/include/* 11 + src:*include/acpi/* 12 + src:*include/asm-generic/* 13 + src:*include/linux/* 14 + src:*include/net/* 15 + 16 + # Opt-in headers: 17 + src:*include/linux/bit_spinlock.h=emit 18 + src:*include/linux/cleanup.h=emit 19 + src:*include/linux/kref.h=emit 20 + src:*include/linux/list*.h=emit 21 + src:*include/linux/local_lock*.h=emit 22 + src:*include/linux/lockdep.h=emit 23 + src:*include/linux/mutex*.h=emit 24 + src:*include/linux/rcupdate.h=emit 25 + src:*include/linux/refcount.h=emit 26 + src:*include/linux/rhashtable.h=emit 27 + src:*include/linux/rwlock*.h=emit 28 + src:*include/linux/rwsem.h=emit 29 + src:*include/linux/seqlock*.h=emit 30 + src:*include/linux/spinlock*.h=emit 31 + src:*include/linux/srcu*.h=emit 32 + src:*include/linux/ww_mutex.h=emit