From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB95C2BE7DD; Thu, 11 Dec 2025 12:04:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765454696; cv=none; b=kb7DUC55m61FDK59JzlWWaQNHgRmCrKmv4iTOBtEZVWvmM7cZ2BQjUJsXjCRtJe/N680/NEAHS9F+SNB7yOWD+XLc/yFHS1S2BP86aco0+vHNCTyxN2f6LUW9KDMMH8KzUNtzEpfD9FpmtlNx+/4DT78dd78oDZzZLKTsMKePuk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765454696; c=relaxed/simple; bh=xYB9CZGFY7AgTnKdWBr89d3ngY1+Ue3cetPJG6t6F4k=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=P+EEF7MJuAR5GrwfDDW4T/pl6EeC2+R0xR3UKCLYxowc0c3OfFHmdgJTgPH4nx2VLn4PmAKAHmmysaqp4N2jnjt7TG3isphh+RBMkBV1zmWp2g5+/j1dxo8RrYjNG3siAvlz4sKwQfALecLc5l8TMdeIkSGntdXww+1CqyPU1/I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=Cm3yzuQq; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Cm3yzuQq" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=J5QYsGE2XyUV8dMJUaGHOZ/s846nES10yHj06SSwiHE=; b=Cm3yzuQqYooIj2GZtZDWYEC3ZO S0fg9hzc4Z19Hv5Bc4P16q2CjNQ573CovUIuUpZEbXu9poIjw8goKrUxsrAu3j7Caix5SEmi3eHJ5 ty2o3ZeXS3kqUORWQHfUhEXRPllWuKhXfU6FuRy+jNCn3CPiuhwnM6hD6rLf9Bd5pxh4A4qnGsqmd YA26rLCiywQY1V7BWRwKwRpg85biCy2lzMbTYkXrqgHkp9M0BmSuJ+nlBxwZvhjzGyyfDW1rDJahM onQMIaTpJMWn2CJQspzPC2bN0ZBuwOi8vBCFsSztBk6L098HJ6Am/lBaLXUiYdMTHDu2proPsv+AW SRG+MwEw==; Received: from 2001-1c00-8d85-5700-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:5700:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vTfPW-0000000ECYb-0fah; Thu, 11 Dec 2025 12:04:42 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 803F130301A; Thu, 11 Dec 2025 13:04:41 +0100 (CET) Date: Thu, 11 Dec 2025 13:04:41 +0100 From: Peter Zijlstra To: Marco Elver Cc: Boqun Feng , Ingo Molnar , Will Deacon , "David S. Miller" , Luc Van Oostenryck , Chris Li , "Paul E. McKenney" , Alexander Potapenko , Arnd Bergmann , Bart Van Assche , Christoph Hellwig , Dmitry Vyukov , Eric Dumazet , Frederic Weisbecker , Greg Kroah-Hartman , Herbert Xu , Ian Rogers , Jann Horn , Joel Fernandes , Johannes Berg , Jonathan Corbet , Josh Triplett , Justin Stitt , Kees Cook , Kentaro Takeda , Lukas Bulwahn , Mark Rutland , Mathieu Desnoyers , Miguel Ojeda , Nathan Chancellor , Neeraj Upadhyay , Nick Desaulniers , Steven Rostedt , Tetsuo Handa , Thomas Gleixner , Thomas Graf , Uladzislau Rezki , Waiman Long , kasan-dev@googlegroups.com, linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, linux-sparse@vger.kernel.org, linux-wireless@vger.kernel.org, llvm@lists.linux.dev, rcu@vger.kernel.org Subject: Re: [PATCH v4 02/35] compiler-context-analysis: Add infrastructure for Context Analysis with Clang Message-ID: <20251211120441.GG3911114@noisy.programming.kicks-ass.net> References: <20251120145835.3833031-2-elver@google.com> <20251120145835.3833031-4-elver@google.com> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251120145835.3833031-4-elver@google.com> On Thu, Nov 20, 2025 at 03:49:04PM +0100, Marco Elver wrote: > +/** > + * context_guard_struct() - declare or define a context guard struct > + * @name: struct name > + * > + * Helper to declare or define a struct type that is also a context guard. > + * > + * .. code-block:: c > + * > + * context_guard_struct(my_handle) { > + * int foo; > + * long bar; > + * }; > + * > + * struct some_state { > + * ... > + * }; > + * // ... declared elsewhere ... > + * context_guard_struct(some_state); > + * > + * Note: The implementation defines several helper functions that can acquire > + * and release the context guard. > + */ > +# define context_guard_struct(name, ...) \ > + struct __ctx_guard_type(name) __VA_ARGS__ name; \ > + static __always_inline void __acquire_ctx_guard(const struct name *var) \ > + __attribute__((overloadable)) __no_context_analysis __acquires_ctx_guard(var) { } \ > + static __always_inline void __acquire_shared_ctx_guard(const struct name *var) \ > + __attribute__((overloadable)) __no_context_analysis __acquires_shared_ctx_guard(var) { } \ > + static __always_inline bool __try_acquire_ctx_guard(const struct name *var, bool ret) \ > + __attribute__((overloadable)) __no_context_analysis __try_acquires_ctx_guard(1, var) \ > + { return ret; } \ > + static __always_inline bool __try_acquire_shared_ctx_guard(const struct name *var, bool ret) \ > + __attribute__((overloadable)) __no_context_analysis __try_acquires_shared_ctx_guard(1, var) \ > + { return ret; } \ > + static __always_inline void __release_ctx_guard(const struct name *var) \ > + __attribute__((overloadable)) __no_context_analysis __releases_ctx_guard(var) { } \ > + static __always_inline void __release_shared_ctx_guard(const struct name *var) \ > + __attribute__((overloadable)) __no_context_analysis __releases_shared_ctx_guard(var) { } \ > + static __always_inline void __assume_ctx_guard(const struct name *var) \ > + __attribute__((overloadable)) __assumes_ctx_guard(var) { } \ > + static __always_inline void __assume_shared_ctx_guard(const struct name *var) \ > + __attribute__((overloadable)) __assumes_shared_ctx_guard(var) { } \ > + struct name -typedef struct { +context_guard_struct(rwlock) { struct rwbase_rt rwbase; atomic_t readers; #ifdef CONFIG_DEBUG_LOCK_ALLOC struct lockdep_map dep_map; #endif -} rwlock_t; +}; +typedef struct rwlock rwlock_t; I must say I find the 'guard' naming here somewhat confusing. This is not a guard, but an actual lock type.