[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aTmdSMuP0LUAdfO_@elver.google.com>
Date: Wed, 10 Dec 2025 17:18:16 +0100
From: Marco Elver <elver@...gle.com>
To: Peter Zijlstra <peterz@...radead.org>,
Boqun Feng <boqun.feng@...il.com>, Ingo Molnar <mingo@...nel.org>,
Will Deacon <will@...nel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>
Cc: "David S. Miller" <davem@...emloft.net>,
Luc Van Oostenryck <luc.vanoostenryck@...il.com>,
Chris Li <sparse@...isli.org>,
"Paul E. McKenney" <paulmck@...nel.org>,
Alexander Potapenko <glider@...gle.com>,
Arnd Bergmann <arnd@...db.de>, Bart Van Assche <bvanassche@....org>,
Christoph Hellwig <hch@....de>, Dmitry Vyukov <dvyukov@...gle.com>,
Eric Dumazet <edumazet@...gle.com>,
Frederic Weisbecker <frederic@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Herbert Xu <herbert@...dor.apana.org.au>,
Ian Rogers <irogers@...gle.com>, Jann Horn <jannh@...gle.com>,
Joel Fernandes <joelagnelf@...dia.com>,
Johannes Berg <johannes.berg@...el.com>,
Jonathan Corbet <corbet@....net>,
Josh Triplett <josh@...htriplett.org>,
Justin Stitt <justinstitt@...gle.com>, Kees Cook <kees@...nel.org>,
Kentaro Takeda <takedakn@...data.co.jp>,
Lukas Bulwahn <lukas.bulwahn@...il.com>,
Mark Rutland <mark.rutland@....com>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Miguel Ojeda <ojeda@...nel.org>,
Nathan Chancellor <nathan@...nel.org>,
Neeraj Upadhyay <neeraj.upadhyay@...nel.org>,
Nick Desaulniers <nick.desaulniers+lkml@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>,
Thomas Gleixner <tglx@...utronix.de>, Thomas Graf <tgraf@...g.ch>,
Uladzislau Rezki <urezki@...il.com>,
Waiman Long <longman@...hat.com>, kasan-dev@...glegroups.com,
linux-crypto@...r.kernel.org, linux-doc@...r.kernel.org,
linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, linux-security-module@...r.kernel.org,
linux-sparse@...r.kernel.org, linux-wireless@...r.kernel.org,
llvm@...ts.linux.dev, rcu@...r.kernel.org
Subject: Re: [PATCH v4 00/35] Compiler-Based Context- and Locking-Analysis
All,
On Thu, Nov 20, 2025 at 03:49PM +0100, Marco Elver wrote:
> Context Analysis is a language extension, which enables statically
> checking that required contexts are active (or inactive) by acquiring
> and releasing user-definable "context guards". An obvious application is
> lock-safety checking for the kernel's various synchronization primitives
> (each of which represents a "context guard"), and checking that locking
> rules are not violated.
[...]
> A Clang version that supports `-Wthread-safety-pointer` and the new
> alias-analysis of context-guard pointers is required (from this version
> onwards):
>
> https://github.com/llvm/llvm-project/commit/7ccb5c08f0685d4787f12c3224a72f0650c5865e
>
> The minimum required release version will be Clang 22.
>
> This series is also available at this Git tree:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/melver/linux.git/log/?h=ctx-analysis/dev
[...]
I realize that I sent this series at the end of the last release cycle,
and now we're in the merge window, along with LPC going on -- so it
wasn't the best timing (however, it might be something to discuss at
LPC, too :-) .. I'm attending virtually, however :-/).
How to proceed?
I'll be preparing a rebased and retested version of all this when
v6.19-rc1 is out. One outstanding recommendation from Linus was to
investigate compile-times, but as-is, it's unclear there's any notable
overhead per brief investigation: https://lore.kernel.org/all/aR-plHrWDMqRRlcI@elver.google.com/
>From what I can tell most of this has to go through the locking tree,
given the potential for conflict there. However, it is possible to split
this up as follows:
Batch 1:
> compiler_types: Move lock checking attributes to
> compiler-context-analysis.h
> compiler-context-analysis: Add infrastructure for Context Analysis
> with Clang
> compiler-context-analysis: Add test stub
> Documentation: Add documentation for Compiler-Based Context Analysis
> checkpatch: Warn about context_unsafe() without comment
> cleanup: Basic compatibility with context analysis
> lockdep: Annotate lockdep assertions for context analysis
> locking/rwlock, spinlock: Support Clang's context analysis
> compiler-context-analysis: Change __cond_acquires to take return value
> locking/mutex: Support Clang's context analysis
> locking/seqlock: Support Clang's context analysis
> bit_spinlock: Include missing <asm/processor.h>
> bit_spinlock: Support Clang's context analysis
> rcu: Support Clang's context analysis
> srcu: Support Clang's context analysis
> kref: Add context-analysis annotations
> locking/rwsem: Support Clang's context analysis
> locking/local_lock: Include missing headers
> locking/local_lock: Support Clang's context analysis
> locking/ww_mutex: Support Clang's context analysis
> debugfs: Make debugfs_cancellation a context guard struct
> compiler-context-analysis: Remove Sparse support
> compiler-context-analysis: Remove __cond_lock() function-like helper
> compiler-context-analysis: Introduce header suppressions
> compiler: Let data_race() imply disabled context analysis
> MAINTAINERS: Add entry for Context Analysis
Batch 2: Everything below this can wait for the initial support in
mainline, at which point subsystem maintainers can pick them up if
deemed appropriate.
> kfence: Enable context analysis
> kcov: Enable context analysis
> kcsan: Enable context analysis
> stackdepot: Enable context analysis
> rhashtable: Enable context analysis
> printk: Move locking annotation to printk.c
> security/tomoyo: Enable context analysis
> crypto: Enable context analysis
> sched: Enable context analysis for core.c and fair.c
Thanks,
-- Marco
Powered by blists - more mailing lists