[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260121202427.099c36ab@gandalf.local.home>
Date: Wed, 21 Jan 2026 20:24:27 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Christoph Hellwig <hch@....de>, Marco Elver <elver@...gle.com>, Ingo
Molnar <mingo@...nel.org>, Thomas Gleixner <tglx@...utronix.de>, Will
Deacon <will@...nel.org>, Boqun Feng <boqun.feng@...il.com>, Waiman Long
<longman@...hat.com>, linux-kernel@...r.kernel.org, llvm@...ts.linux.dev,
Bart Van Assche <bvanassche@....org>
Subject: Re: [PATCH tip/locking/core] compiler-context-analysis: Support
immediate acquisition after initialization
On Fri, 16 Jan 2026 16:47:54 +0100
Peter Zijlstra <peterz@...radead.org> wrote:
> struct obj {
> spinlock_t lock;
> int state __guarded_by(lock);
> };
>
> struct obj *create_obj(void)
> {
> struct obj *obj = kzmalloc(sizeof(*obj), GFP_KERNEL);
> if (!obj)
> return NULL;
>
> spin_lock_init(&obj->lock);
> obj->state = INIT_STATE; // error: ->state demands ->lock is held
> }
I haven't seen all the other approaches, but would a macro be able to hide
it with some kind of obfuscation from the compiler?
GUARD_INIT(obj->state, INIT_STATE);
which would be something like a WRITE_ONCE() macro. I'm not sure what
tooling there is to disable checks for a small bit of code like this.
-- Steve
Powered by blists - more mailing lists