From nobody Sat Feb 7 07:25:53 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 16AD6349B13; Mon, 5 Jan 2026 15:54:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767628496; cv=none; b=Hel0bjIy4avr6JqBUXLnhLHpqqTuVvkajFUDIxeA7Jn/H/ZjLWNh/7eIdZ/Axdlc1xw0U4QigD0cezIFkETDMPPg9SYIUTL5yPQos5yIi5awht/l707QEqrPwd4KqtRS6tZDfEwfGfYTjnCxvg+7JsTmlfkovUTxvkYb4NaDsSI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767628496; c=relaxed/simple; bh=vWem3996FnAb3720FC3qZyK/mRuk5ILrv851qBRmOEQ=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=RLpbTufhxRWlb0UnefoaOid11v4goNXxMH7TSeWo6pbBgr7Yqcuyb+uypaQYmmr5+WYo8Ir1BTE9p0qQRMhXN9pRpbmM+JaUFKSI+qhST1sgRFlN4NVTyMhlQw7uMypg4vTj5u4lLjNlVjriWtCxPuvgP+zdViOMn1n75gBHYwA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=zoga9vu8; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=UtzNVgy7; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="zoga9vu8"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="UtzNVgy7" Date: Mon, 05 Jan 2026 15:54:47 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1767628488; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FmFRdhKSwCueAEElCV3jM9ah56dN9Feo6Xh2fn+40d0=; b=zoga9vu8QF+Gixnh5oaDbRWpoyVRavJ/hf+shTP919qRI4sE5qn22+QGtn1wTAZ4FAlim7 LyjNz4nm/zyl21v+2yeGHIpzFM2c+hVqw85HYosIJDSZkX7GULNX0mbVm/6zuUS+Kz5xuK CimsbmdKBRBtrvhspQ1aOObLYLwEX7gILcOuH/JaaRHaQ76DFxLLOWCAi5qhhMiPYpOe7q vp+i1O7OMtloTS8FVbJ0YE3fOkdSHuVArcERMzVq6IAQvF2j4Nz3KLziLJSFoDmFzRQ9Va HaQmcDx/YkURGRfxMmz4TKK23a1yGDxgBuG5aJUM+hqdeopee4Za/8QtNT1iNg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1767628488; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FmFRdhKSwCueAEElCV3jM9ah56dN9Feo6Xh2fn+40d0=; b=UtzNVgy79VVecfcWG/kbmiTFdjt6abbYbM/4Xcer4r9Knf1DQRikuyllfeHo7xO97p6ASv Jri4kuZ3ZxS/vBAA== From: "tip-bot2 for Marco Elver" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] compiler_types: Move lock checking attributes to compiler-context-analysis.h Cc: Marco Elver , "Peter Zijlstra (Intel)" , Bart Van Assche , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20251219154418.3592607-2-elver@google.com> References: <20251219154418.3592607-2-elver@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <176762848704.510.14557214891213404583.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the locking/core branch of tip: Commit-ID: de15fecae44df8254fa597bad7eb3680a8b1c10c Gitweb: https://git.kernel.org/tip/de15fecae44df8254fa597bad7eb3680a= 8b1c10c Author: Marco Elver AuthorDate: Fri, 19 Dec 2025 16:39:50 +01:00 Committer: Peter Zijlstra CommitterDate: Mon, 05 Jan 2026 16:43:26 +01:00 compiler_types: Move lock checking attributes to compiler-context-analysis.h The conditional definition of lock checking macros and attributes is about to become more complex. Factor them out into their own header for better readability, and to make it obvious which features are supported by which mode (currently only Sparse). This is the first step towards generalizing towards "context analysis". No functional change intended. Signed-off-by: Marco Elver Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Bart Van Assche Link: https://patch.msgid.link/20251219154418.3592607-2-elver@google.com --- include/linux/compiler-context-analysis.h | 32 ++++++++++++++++++++++- include/linux/compiler_types.h | 18 +----------- 2 files changed, 34 insertions(+), 16 deletions(-) create mode 100644 include/linux/compiler-context-analysis.h diff --git a/include/linux/compiler-context-analysis.h b/include/linux/comp= iler-context-analysis.h new file mode 100644 index 0000000..f8af630 --- /dev/null +++ b/include/linux/compiler-context-analysis.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Macros and attributes for compiler-based static context analysis. + */ + +#ifndef _LINUX_COMPILER_CONTEXT_ANALYSIS_H +#define _LINUX_COMPILER_CONTEXT_ANALYSIS_H + +#ifdef __CHECKER__ + +/* Sparse context/lock checking support. */ +# define __must_hold(x) __attribute__((context(x,1,1))) +# define __acquires(x) __attribute__((context(x,0,1))) +# define __cond_acquires(x) __attribute__((context(x,0,-1))) +# define __releases(x) __attribute__((context(x,1,0))) +# define __acquire(x) __context__(x,1) +# define __release(x) __context__(x,-1) +# define __cond_lock(x, c) ((c) ? ({ __acquire(x); 1; }) : 0) + +#else /* !__CHECKER__ */ + +# define __must_hold(x) +# define __acquires(x) +# define __cond_acquires(x) +# define __releases(x) +# define __acquire(x) (void)0 +# define __release(x) (void)0 +# define __cond_lock(x, c) (c) + +#endif /* __CHECKER__ */ + +#endif /* _LINUX_COMPILER_CONTEXT_ANALYSIS_H */ diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index 1280693..ddada1e 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -41,6 +41,8 @@ # define BTF_TYPE_TAG(value) /* nothing */ #endif =20 +#include + /* sparse defines __CHECKER__; see Documentation/dev-tools/sparse.rst */ #ifdef __CHECKER__ /* address spaces */ @@ -51,14 +53,6 @@ # define __rcu __attribute__((noderef, address_space(__rcu))) static inline void __chk_user_ptr(const volatile void __user *ptr) { } static inline void __chk_io_ptr(const volatile void __iomem *ptr) { } -/* context/locking */ -# define __must_hold(x) __attribute__((context(x,1,1))) -# define __acquires(x) __attribute__((context(x,0,1))) -# define __cond_acquires(x) __attribute__((context(x,0,-1))) -# define __releases(x) __attribute__((context(x,1,0))) -# define __acquire(x) __context__(x,1) -# define __release(x) __context__(x,-1) -# define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0) /* other */ # define __force __attribute__((force)) # define __nocast __attribute__((nocast)) @@ -79,14 +73,6 @@ static inline void __chk_io_ptr(const volatile void __io= mem *ptr) { } =20 # define __chk_user_ptr(x) (void)0 # define __chk_io_ptr(x) (void)0 -/* context/locking */ -# define __must_hold(x) -# define __acquires(x) -# define __cond_acquires(x) -# define __releases(x) -# define __acquire(x) (void)0 -# define __release(x) (void)0 -# define __cond_lock(x,c) (c) /* other */ # define __force # define __nocast