diff options
| author | Ingo Molnar <mingo@kernel.org> | 2026-05-29 09:51:02 +0200 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2026-05-29 09:51:03 +0200 |
| commit | 174bead9f0d8eedb5881963b30ec11fbd0a76b9d (patch) | |
| tree | be6ca223efccff924461e8acdf64e5863f4a7d41 /lib | |
| parent | d351e375440284891fd5993fb01a6bf9df5fb7cc (diff) | |
| parent | f45c5c4adb27540d43302155e2fbaeca6c3c6d03 (diff) | |
| download | linux-next-history-174bead9f0d8eedb5881963b30ec11fbd0a76b9d.tar.gz | |
Merge branch into tip/master: 'locking/context'
# New commits in locking/context:
f45c5c4adb27 ("compiler-context-analysis: Bump required Clang version to 23")
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Kconfig.debug | 4 | ||||
| -rw-r--r-- | lib/test_context-analysis.c | 24 |
2 files changed, 26 insertions, 2 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 8ff5adcfe1e0a..b0f3028a213df 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -630,7 +630,7 @@ config DEBUG_FORCE_WEAK_PER_CPU config WARN_CONTEXT_ANALYSIS bool "Compiler context-analysis warnings" - depends on CC_IS_CLANG && CLANG_VERSION >= 220100 + depends on CC_IS_CLANG && CLANG_VERSION >= 230000 # Branch profiling re-defines "if", which messes with the compiler's # ability to analyze __cond_acquires(..), resulting in false positives. depends on !TRACE_BRANCH_PROFILING @@ -641,7 +641,7 @@ config WARN_CONTEXT_ANALYSIS and releasing user-definable "context locks". Clang's name of the feature is "Thread Safety Analysis". Requires - Clang 22.1.0 or later. + Clang 23 or later. Produces warnings by default. Select CONFIG_WERROR if you wish to turn these warnings into errors. diff --git a/lib/test_context-analysis.c b/lib/test_context-analysis.c index 06b4a6a028e0e..316f4dfcda651 100644 --- a/lib/test_context-analysis.c +++ b/lib/test_context-analysis.c @@ -159,6 +159,10 @@ TEST_SPINLOCK_COMMON(read_lock, struct test_mutex_data { struct mutex mtx; int counter __guarded_by(&mtx); + + struct mutex mtx2; + int anyread __guarded_by(&mtx, &mtx2); + int *anyptr __pt_guarded_by(&mtx, &mtx2); }; static void __used test_mutex_init(struct test_mutex_data *d) @@ -219,6 +223,26 @@ static void __used test_mutex_cond_guard(struct test_mutex_data *d) } } +static void __used test_mutex_multiguard(struct test_mutex_data *d) +{ + mutex_lock(&d->mtx); + (void)d->anyread; + (void)*d->anyptr; + mutex_unlock(&d->mtx); + + mutex_lock(&d->mtx2); + (void)d->anyread; + (void)*d->anyptr; + mutex_unlock(&d->mtx2); + + mutex_lock(&d->mtx); + mutex_lock(&d->mtx2); + d->anyread++; + (*d->anyptr)++; + mutex_unlock(&d->mtx2); + mutex_unlock(&d->mtx); +} + struct test_seqlock_data { seqlock_t sl; int counter __guarded_by(&sl); |
