From: Marco Elver <elver@google.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Peter Zijlstra <peterz@infradead.org>,
Steven Rostedt <rostedt@goodmis.org>,
Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Will Deacon <will@kernel.org>, Boqun Feng <boqun.feng@gmail.com>,
Waiman Long <longman@redhat.com>,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
Bart Van Assche <bvanassche@acm.org>
Subject: Re: [PATCH tip/locking/core] compiler-context-analysis: Support immediate acquisition after initialization
Date: Fri, 16 Jan 2026 16:37:55 +0100 [thread overview]
Message-ID: <aWpbU3Msh2q-bRH5@elver.google.com> (raw)
In-Reply-To: <20260116152741.GA19823@lst.de>
On Fri, Jan 16, 2026 at 04:27PM +0100, Christoph Hellwig wrote:
> On Fri, Jan 16, 2026 at 04:20:16PM +0100, Peter Zijlstra wrote:
> > is *much* clearer than something like:
> >
> > spinlock_init(&obj->lock);
> > // init
> > spinlock_deinit(&obj->lock);
> >
> > Exactly because it has explicit scope. (also my deinit naming might not
> > be optimal, it is ambiguous at best, probably confusing).
>
> WTF is spinlock_deinit even supposed to be?
>
> I though this is about:
>
> spin_lock_init(&obj->lock);
> spin_lock(&obj->lock);
>
> > Not to mention that the scope things are far more robust vs error paths.
>
> They are just a really hacked up clumsy way to provide what a very
> limited version of what the capability analys provides, while messing
> up the code.
There might be more design options we're missing, but thus far I think
it's this patch (using the "reentrant promotion" approach) vs. scoped
init guards.
* Scoped init guards [1]: Sound, requires explicit
guard(type_init) (or scoped_guard) for guarded member
initialization.
* Reentrant init (this patch): Less intrusive, foo_init() just
works. Misses double-locks immediately after init.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/melver/linux.git/log/?h=ctx-analysis/init-guards
FWIW, on the C++ side, Clang's Thread Safety Analysis just completely
disables itself in constructors to allow guarded member init. So we're
already doing better than that. :-)
As for why this simpler patch, I stand by my points from [2]; trading
false positives against false negatives so that things "just work" does
have merit, too.
[2] https://lore.kernel.org/all/CANpmjNPm5861mmHYMHoC9ErRfbLxmTy=MYwfsGC-YTpgP+z-Bw@mail.gmail.com/
I'm more or less indifferent, though would slightly favor the simpler
patch (this one), but can live with either. I can send out [1] for
reference, and you can choose.
Thanks,
-- Marco
next prev parent reply other threads:[~2026-01-16 15:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 0:51 [PATCH tip/locking/core] compiler-context-analysis: Support immediate acquisition after initialization Marco Elver
2026-01-15 17:22 ` Bart Van Assche
2026-01-15 17:58 ` Marco Elver
2026-01-15 18:04 ` Bart Van Assche
2026-01-15 21:33 ` Peter Zijlstra
2026-01-16 1:17 ` Marco Elver
2026-01-16 15:07 ` Peter Zijlstra
2026-01-16 15:10 ` Christoph Hellwig
2026-01-16 15:20 ` Peter Zijlstra
2026-01-16 15:27 ` Peter Zijlstra
2026-01-16 15:27 ` Christoph Hellwig
2026-01-16 15:37 ` Marco Elver [this message]
2026-01-16 15:47 ` Peter Zijlstra
2026-01-19 9:10 ` Christoph Hellwig
2026-01-22 1:24 ` Steven Rostedt
2026-01-22 6:25 ` Christoph Hellwig
2026-01-22 9:15 ` Marco Elver
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aWpbU3Msh2q-bRH5@elver.google.com \
--to=elver@google.com \
--cc=boqun.feng@gmail.com \
--cc=bvanassche@acm.org \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=longman@redhat.com \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.