Re: [PATCH v5 10/36] locking/mutex: Support Clang's context analysis
Steven Rostedt <[email protected]> Fri, 9 Jan 2026 08:07:15 -0500
| Newsgroups | org.kernel.vger.linux-sparse,dev.linux.lists.llvm,org.kernel.vger.linux-crypto,org.kernel.vger.linux-doc,org.kernel.vger.linux-kbuild,org.kernel.vger.linux-kernel,org.kernel.vger.linux-security-module,org.kernel.vger.linux-wireless,org.kernel.vger.rcu,org.kvack.linux-mm |
|---|---|
| Message-ID | <[email protected]> |
On Fri, 9 Jan 2026 07:02:49 +0100 Christoph Hellwig <[email protected]> wrote: > On Fri, Jan 09, 2026 at 12:26:55AM +0100, Marco Elver wrote: > > Probably the most idiomatic option is to just factor out construction. > > Clearly separating complex object construction from use also helps > > readability regardless, esp. where concurrency is involved. We could > > document such advice somewhere. > > Initializing and locking a mutex (or spinlock, or other primitive) is a > not too unusual pattern, often used when inserting an object into a > hash table or other lookup data structure. So supporting it without > creating pointless wrapper functions would be really useful. One thing > that would be nice to have and probably help here is to have lock > initializers that create the lock in a held state. Right. If tooling can't handle a simple pattern of initializing a lock than taking it, that's a hard show stopper of adding that tooling. -- Steve