mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-21 23:16:50 +08:00
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
This commit is contained in:
committed by
Peter Zijlstra
parent
e4588c25c9
commit
c237f1ceee
@@ -4,4 +4,8 @@ context-analysis-cflags := -DWARN_CONTEXT_ANALYSIS \
|
||||
-fexperimental-late-parse-attributes -Wthread-safety \
|
||||
-Wthread-safety-pointer -Wthread-safety-beta
|
||||
|
||||
ifndef CONFIG_WARN_CONTEXT_ANALYSIS_ALL
|
||||
context-analysis-cflags += --warning-suppression-mappings=$(srctree)/scripts/context-analysis-suppression.txt
|
||||
endif
|
||||
|
||||
export CFLAGS_CONTEXT_ANALYSIS := $(context-analysis-cflags)
|
||||
|
||||
32
scripts/context-analysis-suppression.txt
Normal file
32
scripts/context-analysis-suppression.txt
Normal file
@@ -0,0 +1,32 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# The suppressions file should only match common paths such as header files.
|
||||
# For individual subsytems use Makefile directive CONTEXT_ANALYSIS := [yn].
|
||||
#
|
||||
# The suppressions are ignored when CONFIG_WARN_CONTEXT_ANALYSIS_ALL is
|
||||
# selected.
|
||||
|
||||
[thread-safety]
|
||||
src:*arch/*/include/*
|
||||
src:*include/acpi/*
|
||||
src:*include/asm-generic/*
|
||||
src:*include/linux/*
|
||||
src:*include/net/*
|
||||
|
||||
# Opt-in headers:
|
||||
src:*include/linux/bit_spinlock.h=emit
|
||||
src:*include/linux/cleanup.h=emit
|
||||
src:*include/linux/kref.h=emit
|
||||
src:*include/linux/list*.h=emit
|
||||
src:*include/linux/local_lock*.h=emit
|
||||
src:*include/linux/lockdep.h=emit
|
||||
src:*include/linux/mutex*.h=emit
|
||||
src:*include/linux/rcupdate.h=emit
|
||||
src:*include/linux/refcount.h=emit
|
||||
src:*include/linux/rhashtable.h=emit
|
||||
src:*include/linux/rwlock*.h=emit
|
||||
src:*include/linux/rwsem.h=emit
|
||||
src:*include/linux/seqlock*.h=emit
|
||||
src:*include/linux/spinlock*.h=emit
|
||||
src:*include/linux/srcu*.h=emit
|
||||
src:*include/linux/ww_mutex.h=emit
|
||||
Reference in New Issue
Block a user