From nobody Sun Feb 8 02:21:27 2026 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D33AF3570AE for ; Mon, 19 Jan 2026 09:40:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768815651; cv=none; b=dafIyr9/SQdBC+hcEX1EUWSkbqoIsvs/DsPJPfL65m89KCGHhNEfJhfFJcUbJ1ejkeB0/DyaG/IC9rxRFfW1jJQKK25p+z7Oj0C2ni7SgosDmInG9goSciEC5ildi8FvuBD1dM695bdK2mLv3YKEheHoomnlxqLJWoSWY37Q0pY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768815651; c=relaxed/simple; bh=KgBNkhyWNQ2k0IPDloVTMBnOWkgGfX49s05GA2EIxpQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=NHIFyu+ZHI8l2KjgZb+bKAJCDXUNtzy5b8irLRIDawJM9i2ZUSd/ZNAGamfDsNewXQH93Y+GMMljPjQ+5SUAEC5+QracIYzGZf2B8mvJrvop1HbPHTswmdFNE4Dv4fxx8fJIFkCpnHLBFSYfNr5cov39ps1FgFIvaB+nJnXp3zo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--elver.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=bm81DMjF; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--elver.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bm81DMjF" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-47d3ba3a49cso43825485e9.2 for ; Mon, 19 Jan 2026 01:40:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768815648; x=1769420448; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=FVzjIjtVdiVPjpEIkbADcVmmkIUg4nu9DkgIt9tpdDQ=; b=bm81DMjFfdktpqHH9slPweWJXUfFPptm5Ji2niPZAjiAzpdizmvIaHTJ08W+JlSqUx puWfEACgRHBpwKfJldW9LTqVn2fSr7Br7fQxDMgTVPmeJAPWz6kxogQo3gEK81ZyT0LA vOJyFMQjL/TYcQqymCTP0/BlmOwIyTwC8X6jTKM7H2mFWJJEmpDjyF+WeuwueVegZIo9 h9ZjKE1uOhveVyDK5uLNqCN9GEjEzLeFwNJAV7lzLClOz2etstR8RG7K7b0wLCxxqALF +wqmRO1sovhlMxbgAOLaSj6rir+Eqvdw3NQVOs6UpAhcuGXAv1g9M3929XmuDA0/msRS ND8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768815648; x=1769420448; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FVzjIjtVdiVPjpEIkbADcVmmkIUg4nu9DkgIt9tpdDQ=; b=PKGRIdXZxk3xIQgC8y9x+J41eUyUL+bC5fT+35C6373w//6VKQ6PmWmVdn0ESqxbkx 0rEx9qgQ8WoG7upsLmjkMn/XY9TG86DMuECqrTEGBfuepR++1qoDhHVtl1VNZxJmCLiX z8L+HTqhTuGR23AfUO+pe4QGQmHJW37zcKHfkWKV8sfLUMicGQWcJdXHSYfdO4iAtHLH eMIOFr30EtHEXNAQHMlBVGnc0tQeNa4ejXfNrtNEFxHr9Jh1cUSGB6oxaR5TaT5UJVn4 rSuBypNWMk/RPRfwii9wYEdULYvG5gM1d6GoaGzFQkblEtdTDXG4L7kk5DLnQMorjVXo kyGw== X-Forwarded-Encrypted: i=1; AJvYcCVJY8Ef+6YP8zToHV+Ea8kNtL8AhVeA6rrHE4RwvRRp3AC7RyyTpYqA+Fy5laI0uDt7fyhQAvn6ksNO9BA=@vger.kernel.org X-Gm-Message-State: AOJu0Yw9CSytc8locPrO3fo3FgSTrKQNokbQCMzyf7pKxPJYQtc+4k91 ntxajQz9UhW9i5tJYMM0vY5+dnarg7PABPEfyk/X8Cd6ZHXtIX9hTUreUpzn0qXqVE0JkjIk4wv FNw== X-Received: from wmaz14.prod.google.com ([2002:a05:600c:6d8e:b0:477:a1f9:138c]) (user=elver job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:4e89:b0:475:dd89:acb with SMTP id 5b1f17b1804b1-4801eb035ecmr125513305e9.22.1768815648401; Mon, 19 Jan 2026 01:40:48 -0800 (PST) Date: Mon, 19 Jan 2026 10:05:51 +0100 In-Reply-To: <20260119094029.1344361-1-elver@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260119094029.1344361-1-elver@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260119094029.1344361-2-elver@google.com> Subject: [PATCH tip/locking/core 1/6] cleanup: Make __DEFINE_LOCK_GUARD handle commas in initializers From: Marco Elver To: elver@google.com, Peter Zijlstra , Ingo Molnar Cc: Thomas Gleixner , Will Deacon , Boqun Feng , Waiman Long , Christoph Hellwig , Steven Rostedt , Bart Van Assche , kasan-dev@googlegroups.com, llvm@lists.linux.dev, linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, kernel test robot Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Initialization macros can expand to structure initializers containing commas, which when used as a "lock" function resulted in errors such as: >> include/linux/spinlock.h:582:56: error: too many arguments provided to f= unction-like macro invocation 582 | DEFINE_LOCK_GUARD_1(raw_spinlock_init, raw_spinlock_t, raw_spin_= lock_init(_T->lock), /* */) | ^ include/linux/spinlock.h:113:17: note: expanded from macro 'raw_spin_loc= k_init' 113 | do { *(lock) =3D __RAW_SPIN_LOCK_UNLOCKED(lock); } while= (0) | ^ include/linux/spinlock_types_raw.h:70:19: note: expanded from macro '__R= AW_SPIN_LOCK_UNLOCKED' 70 | (raw_spinlock_t) __RAW_SPIN_LOCK_INITIALIZER(lockname) | ^ include/linux/spinlock_types_raw.h:67:34: note: expanded from macro '__R= AW_SPIN_LOCK_INITIALIZER' 67 | RAW_SPIN_DEP_MAP_INIT(lockname) } | ^ include/linux/cleanup.h:496:9: note: macro '__DEFINE_LOCK_GUARD_1' defin= ed here 496 | #define __DEFINE_LOCK_GUARD_1(_name, _type, _lock) = \ | ^ include/linux/spinlock.h:582:1: note: parentheses are required around ma= cro argument containing braced initializer list 582 | DEFINE_LOCK_GUARD_1(raw_spinlock_init, raw_spinlock_t, raw_spin_= lock_init(_T->lock), /* */) | ^ | ( include/linux/cleanup.h:558:60: note: expanded from macro 'DEFINE_LOCK_G= UARD_1' 558 | __DEFINE_UNLOCK_GUARD(_name, _type, _unlock, __VA_ARGS__) = \ | = ^ Make __DEFINE_LOCK_GUARD_0 and __DEFINE_LOCK_GUARD_1 variadic so that __VA_ARGS__ captures everything. Reported-by: kernel test robot Signed-off-by: Marco Elver --- include/linux/cleanup.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/cleanup.h b/include/linux/cleanup.h index ee6df68c2177..dbc4162921e9 100644 --- a/include/linux/cleanup.h +++ b/include/linux/cleanup.h @@ -493,22 +493,22 @@ static __always_inline void class_##_name##_destructo= r(class_##_name##_t *_T) \ \ __DEFINE_GUARD_LOCK_PTR(_name, &_T->lock) =20 -#define __DEFINE_LOCK_GUARD_1(_name, _type, _lock) \ +#define __DEFINE_LOCK_GUARD_1(_name, _type, ...) \ static __always_inline class_##_name##_t class_##_name##_constructor(_type= *l) \ __no_context_analysis \ { \ class_##_name##_t _t =3D { .lock =3D l }, *_T =3D &_t; \ - _lock; \ + __VA_ARGS__; \ return _t; \ } =20 -#define __DEFINE_LOCK_GUARD_0(_name, _lock) \ +#define __DEFINE_LOCK_GUARD_0(_name, ...) \ static __always_inline class_##_name##_t class_##_name##_constructor(void)= \ __no_context_analysis \ { \ class_##_name##_t _t =3D { .lock =3D (void*)1 }, \ *_T __maybe_unused =3D &_t; \ - _lock; \ + __VA_ARGS__; \ return _t; \ } =20 --=20 2.52.0.457.g6b5491de43-goog From nobody Sun Feb 8 02:21:27 2026 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90F4F35772D for ; Mon, 19 Jan 2026 09:40:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768815655; cv=none; b=hYoRm0NbLx90Gp/Mpy5mGEW0mt4hFxL9MycKuCiTpEuZc7oDyfV7sdWZY9riPFGZYY5jlXZ3gYyrrmY9aTJdd/0SW4HQPR75+Y6JeGg7J2z/CIOkNCFCuzLAG1/gc4P9BHwOzejDD2XyH1JvSEIL/q5n8yY8hmWVX61U12A2JgU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768815655; c=relaxed/simple; bh=gYPjePwKj6eP1K5hbASZ5QpHpt6NcrjYVrUhGil1MoU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=PjHsqnLJv4ADiugFV/LihkZ9JfYhQt7bMRnlqXqA3MmmhMDhH7i1KbiwtBYxWVOZHvK4VZbZY/loPZFovRZFuaRozS27kkpluit0EV7GVa0XDkDW1NnTAOQpPV8zlz6sWOytzALwFrGJEpN6YLZF7osIyhnw7U0nUwfuqxFDTXY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--elver.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=V9pI/kLf; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--elver.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="V9pI/kLf" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-47d4029340aso38520235e9.3 for ; Mon, 19 Jan 2026 01:40:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768815651; x=1769420451; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=HreKJW6Uhd9IMPcJS7ezcF4nMQIgMSBOdw1/CLSMwUI=; b=V9pI/kLfZ8YReQ1cXoHEFYQJdotoYuZF4CtjU87J4Fs7VR4goUk0EbGbzg9aaXM+B9 aDheBL7S6dZmCuoLvlb5nLoh4lO8h8OfLR7eWg7IiG8Jz+2pDmSchswspjB/EiPZRE1I 41jOlv8Hhh31rTaic2tGzN4DKlZwFgxzIz5wsnxXu0M4QIFOskuwNosY3P5JIWeuSli5 03WjmlLfjYX0o+wUepcNcF5LMRog1hnq/xyd9V8yOMnNUhE+Krs6nFjvYcODR5PtbYHU T/MJPeyp+pEP7mT4CGR7VqdSV5bSXkm9kL2K7MWwGF6m2XHrJjDVI8+PRu5FgeuNeiuu 64/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768815651; x=1769420451; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HreKJW6Uhd9IMPcJS7ezcF4nMQIgMSBOdw1/CLSMwUI=; b=WV7SRAnY/joTWRzhVJIbUWrRfi7Bh1Csv2TaIe6spVMnGQ7ZCD4MRDjUlyFW/kx+UM J66z+GxJozQjazvZWOuHGAOflKYx919Vk1pkhM46a3ddqYmonBA5uOsAd6B80f8pQHw+ jxkwDnC4MQxWLmfQxXlT4/3i9hn9yaWSQtYAxhevMiUe+BW2nM+74V8+uuiU1FRv161m flzPfFCJwe7ChI5xeAFXtiHOUsf1qmg5ZOiZN99dn8ak0MMpSO/TEZao/0dpgqta4iy4 Mu0xMPcytJNryhP09yQ1lZCM1vY16AoTHG8hgmFSAa8H692OeZKVnA7+UYAGdNTkyFOt 36jQ== X-Forwarded-Encrypted: i=1; AJvYcCW9yM8SEmuWo3X6Z3Rh7gaHO7kUlbgjrUl1IOzvhC+HY/HUzszUBQ85Jg3PFeqrq/+9m0Id8d7nRd2rHck=@vger.kernel.org X-Gm-Message-State: AOJu0YzGSC5zovdFZ7K1JekBiRzspH6R7+nHJ7yQuk5BCBHt3Bl8H+Pi RfnWlkj4ZM1r6HMELxGnGhNOCVOEwdpF5eNNcu2w2b3b9OCsPKDsGBupbvEm0B2uqKIG7mclVuj PXg== X-Received: from wmbd23.prod.google.com ([2002:a05:600c:58d7:b0:477:9654:b44c]) (user=elver job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:138a:b0:477:1af2:f40a with SMTP id 5b1f17b1804b1-4801e33c066mr161283195e9.17.1768815650997; Mon, 19 Jan 2026 01:40:50 -0800 (PST) Date: Mon, 19 Jan 2026 10:05:52 +0100 In-Reply-To: <20260119094029.1344361-1-elver@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260119094029.1344361-1-elver@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260119094029.1344361-3-elver@google.com> Subject: [PATCH tip/locking/core 2/6] compiler-context-analysis: Introduce scoped init guards From: Marco Elver To: elver@google.com, Peter Zijlstra , Ingo Molnar Cc: Thomas Gleixner , Will Deacon , Boqun Feng , Waiman Long , Christoph Hellwig , Steven Rostedt , Bart Van Assche , kasan-dev@googlegroups.com, llvm@lists.linux.dev, linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add scoped init guard definitions for common synchronization primitives supported by context analysis. The scoped init guards treat the context as active within initialization scope of the underlying context lock, given initialization implies exclusive access to the underlying object. This allows initialization of guarded members without disabling context analysis, while documenting initialization from subsequent usage. The documentation is updated with the new recommendation. Where scoped init guards are not provided or cannot be implemented (ww_mutex omitted for lack of multi-arg guard initializers), the alternative is to just disable context analysis where guarded members are initialized. Link: https://lore.kernel.org/all/20251212095943.GM3911114@noisy.programmin= g.kicks-ass.net/ Suggested-by: Peter Zijlstra Signed-off-by: Marco Elver --- Documentation/dev-tools/context-analysis.rst | 30 ++++++++++++++++++-- include/linux/compiler-context-analysis.h | 9 ++---- include/linux/local_lock.h | 8 ++++++ include/linux/local_lock_internal.h | 1 + include/linux/mutex.h | 3 ++ include/linux/rwsem.h | 4 +++ include/linux/seqlock.h | 5 ++++ include/linux/spinlock.h | 12 ++++++++ lib/test_context-analysis.c | 16 +++++------ 9 files changed, 70 insertions(+), 18 deletions(-) diff --git a/Documentation/dev-tools/context-analysis.rst b/Documentation/d= ev-tools/context-analysis.rst index e69896e597b6..54d9ee28de98 100644 --- a/Documentation/dev-tools/context-analysis.rst +++ b/Documentation/dev-tools/context-analysis.rst @@ -83,9 +83,33 @@ Currently the following synchronization primitives are s= upported: `bit_spinlock`, RCU, SRCU (`srcu_struct`), `rw_semaphore`, `local_lock_t`, `ww_mutex`. =20 -For context locks with an initialization function (e.g., `spin_lock_init()= `), -calling this function before initializing any guarded members or globals -prevents the compiler from issuing warnings about unguarded initialization. +To initialize variables guarded by a context lock with an initialization +function (``type_init(&lock)``), prefer using ``guard(type_init)(&lock)`` = or +``scoped_guard(type_init, &lock) { ... }`` to initialize such guarded memb= ers +or globals in the enclosing scope. This initializes the context lock and t= reats +the context as active within the initialization scope (initialization impl= ies +exclusive access to the underlying object). + +For example:: + + struct my_data { + spinlock_t lock; + int counter __guarded_by(&lock); + }; + + void init_my_data(struct my_data *d) + { + ... + guard(spinlock_init)(&d->lock); + d->counter =3D 0; + ... + } + +Alternatively, initializing guarded variables can be done with context ana= lysis +disabled, preferably in the smallest possible scope (due to lack of any ot= her +checking): either with a ``context_unsafe(var =3D init)`` expression, or by +marking small initialization functions with the ``__context_unsafe(init)`` +attribute. =20 Lockdep assertions, such as `lockdep_assert_held()`, inform the compiler's context analysis that the associated synchronization primitive is held aft= er diff --git a/include/linux/compiler-context-analysis.h b/include/linux/comp= iler-context-analysis.h index db7e0d48d8f2..27ea01adeb2c 100644 --- a/include/linux/compiler-context-analysis.h +++ b/include/linux/compiler-context-analysis.h @@ -32,13 +32,8 @@ /* * The "assert_capability" attribute is a bit confusingly named. It does n= ot * generate a check. Instead, it tells the analysis to *assume* the capabi= lity - * is held. This is used for: - * - * 1. Augmenting runtime assertions, that can then help with patterns beyo= nd the - * compiler's static reasoning abilities. - * - * 2. Initialization of context locks, so we can access guarded variables = right - * after initialization (nothing else should access the same object yet= ). + * is held. This is used for augmenting runtime assertions, that can then = help + * with patterns beyond the compiler's static reasoning abilities. */ # define __assumes_ctx_lock(...) __attribute__((assert_capability(__VA_AR= GS__))) # define __assumes_shared_ctx_lock(...) __attribute__((assert_shared_capab= ility(__VA_ARGS__))) diff --git a/include/linux/local_lock.h b/include/linux/local_lock.h index 99c06e499375..b8830148a859 100644 --- a/include/linux/local_lock.h +++ b/include/linux/local_lock.h @@ -104,6 +104,8 @@ DEFINE_LOCK_GUARD_1(local_lock_nested_bh, local_lock_t = __percpu, local_lock_nested_bh(_T->lock), local_unlock_nested_bh(_T->lock)) =20 +DEFINE_LOCK_GUARD_1(local_lock_init, local_lock_t, local_lock_init(_T->loc= k), /* */) + DECLARE_LOCK_GUARD_1_ATTRS(local_lock, __acquires(_T), __releases(*(local_= lock_t __percpu **)_T)) #define class_local_lock_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(local_loc= k, _T) DECLARE_LOCK_GUARD_1_ATTRS(local_lock_irq, __acquires(_T), __releases(*(lo= cal_lock_t __percpu **)_T)) @@ -112,5 +114,11 @@ DECLARE_LOCK_GUARD_1_ATTRS(local_lock_irqsave, __acqui= res(_T), __releases(*(loca #define class_local_lock_irqsave_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(l= ocal_lock_irqsave, _T) DECLARE_LOCK_GUARD_1_ATTRS(local_lock_nested_bh, __acquires(_T), __release= s(*(local_lock_t __percpu **)_T)) #define class_local_lock_nested_bh_constructor(_T) WITH_LOCK_GUARD_1_ATTRS= (local_lock_nested_bh, _T) +DECLARE_LOCK_GUARD_1_ATTRS(local_lock_init, __acquires(_T), __releases(*(l= ocal_lock_t **)_T)) +#define class_local_lock_init_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(loca= l_lock_init, _T) + +DEFINE_LOCK_GUARD_1(local_trylock_init, local_trylock_t, local_trylock_ini= t(_T->lock), /* */) +DECLARE_LOCK_GUARD_1_ATTRS(local_trylock_init, __acquires(_T), __releases(= *(local_trylock_t **)_T)) +#define class_local_trylock_init_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(l= ocal_trylock_init, _T) =20 #endif diff --git a/include/linux/local_lock_internal.h b/include/linux/local_lock= _internal.h index e8c4803d8db4..4521c40895f8 100644 --- a/include/linux/local_lock_internal.h +++ b/include/linux/local_lock_internal.h @@ -6,6 +6,7 @@ #include #include #include +#include #include =20 #ifndef CONFIG_PREEMPT_RT diff --git a/include/linux/mutex.h b/include/linux/mutex.h index 89977c215cbd..6b12009351d2 100644 --- a/include/linux/mutex.h +++ b/include/linux/mutex.h @@ -254,6 +254,7 @@ extern int atomic_dec_and_mutex_lock(atomic_t *cnt, str= uct mutex *lock) __cond_a DEFINE_LOCK_GUARD_1(mutex, struct mutex, mutex_lock(_T->lock), mutex_unloc= k(_T->lock)) DEFINE_LOCK_GUARD_1_COND(mutex, _try, mutex_trylock(_T->lock)) DEFINE_LOCK_GUARD_1_COND(mutex, _intr, mutex_lock_interruptible(_T->lock),= _RET =3D=3D 0) +DEFINE_LOCK_GUARD_1(mutex_init, struct mutex, mutex_init(_T->lock), /* */) =20 DECLARE_LOCK_GUARD_1_ATTRS(mutex, __acquires(_T), __releases(*(struct mute= x **)_T)) #define class_mutex_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(mutex, _T) @@ -261,6 +262,8 @@ DECLARE_LOCK_GUARD_1_ATTRS(mutex_try, __acquires(_T), _= _releases(*(struct mutex #define class_mutex_try_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(mutex_try,= _T) DECLARE_LOCK_GUARD_1_ATTRS(mutex_intr, __acquires(_T), __releases(*(struct= mutex **)_T)) #define class_mutex_intr_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(mutex_int= r, _T) +DECLARE_LOCK_GUARD_1_ATTRS(mutex_init, __acquires(_T), __releases(*(struct= mutex **)_T)) +#define class_mutex_init_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(mutex_ini= t, _T) =20 extern unsigned long mutex_get_owner(struct mutex *lock); =20 diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h index 8da14a08a4e1..ea1bbdb57a47 100644 --- a/include/linux/rwsem.h +++ b/include/linux/rwsem.h @@ -280,6 +280,10 @@ DECLARE_LOCK_GUARD_1_ATTRS(rwsem_write_try, __acquires= (_T), __releases(*(struct DECLARE_LOCK_GUARD_1_ATTRS(rwsem_write_kill, __acquires(_T), __releases(*(= struct rw_semaphore **)_T)) #define class_rwsem_write_kill_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(rws= em_write_kill, _T) =20 +DEFINE_LOCK_GUARD_1(rwsem_init, struct rw_semaphore, init_rwsem(_T->lock),= /* */) +DECLARE_LOCK_GUARD_1_ATTRS(rwsem_init, __acquires(_T), __releases(*(struct= rw_semaphore **)_T)) +#define class_rwsem_init_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(rwsem_ini= t, _T) + /* * downgrade write lock to read lock */ diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index 113320911a09..22216df47b0f 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h @@ -14,6 +14,7 @@ */ =20 #include +#include #include #include #include @@ -1359,4 +1360,8 @@ static __always_inline void __scoped_seqlock_cleanup_= ctx(struct ss_tmp **s) #define scoped_seqlock_read(_seqlock, _target) \ __scoped_seqlock_read(_seqlock, _target, __UNIQUE_ID(seqlock)) =20 +DEFINE_LOCK_GUARD_1(seqlock_init, seqlock_t, seqlock_init(_T->lock), /* */) +DECLARE_LOCK_GUARD_1_ATTRS(seqlock_init, __acquires(_T), __releases(*(seql= ock_t **)_T)) +#define class_seqlock_init_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(seqlock= _init, _T) + #endif /* __LINUX_SEQLOCK_H */ diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index 396b8c5d6c1b..7b11991c742a 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h @@ -582,6 +582,10 @@ DEFINE_LOCK_GUARD_1_COND(raw_spinlock_irqsave, _try, DECLARE_LOCK_GUARD_1_ATTRS(raw_spinlock_irqsave_try, __acquires(_T), __rel= eases(*(raw_spinlock_t **)_T)) #define class_raw_spinlock_irqsave_try_constructor(_T) WITH_LOCK_GUARD_1_A= TTRS(raw_spinlock_irqsave_try, _T) =20 +DEFINE_LOCK_GUARD_1(raw_spinlock_init, raw_spinlock_t, raw_spin_lock_init(= _T->lock), /* */) +DECLARE_LOCK_GUARD_1_ATTRS(raw_spinlock_init, __acquires(_T), __releases(*= (raw_spinlock_t **)_T)) +#define class_raw_spinlock_init_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(ra= w_spinlock_init, _T) + DEFINE_LOCK_GUARD_1(spinlock, spinlock_t, spin_lock(_T->lock), spin_unlock(_T->lock)) @@ -626,6 +630,10 @@ DEFINE_LOCK_GUARD_1_COND(spinlock_irqsave, _try, DECLARE_LOCK_GUARD_1_ATTRS(spinlock_irqsave_try, __acquires(_T), __release= s(*(spinlock_t **)_T)) #define class_spinlock_irqsave_try_constructor(_T) WITH_LOCK_GUARD_1_ATTRS= (spinlock_irqsave_try, _T) =20 +DEFINE_LOCK_GUARD_1(spinlock_init, spinlock_t, spin_lock_init(_T->lock), /= * */) +DECLARE_LOCK_GUARD_1_ATTRS(spinlock_init, __acquires(_T), __releases(*(spi= nlock_t **)_T)) +#define class_spinlock_init_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(spinlo= ck_init, _T) + DEFINE_LOCK_GUARD_1(read_lock, rwlock_t, read_lock(_T->lock), read_unlock(_T->lock)) @@ -664,5 +672,9 @@ DEFINE_LOCK_GUARD_1(write_lock_irqsave, rwlock_t, DECLARE_LOCK_GUARD_1_ATTRS(write_lock_irqsave, __acquires(_T), __releases(= *(rwlock_t **)_T)) #define class_write_lock_irqsave_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(w= rite_lock_irqsave, _T) =20 +DEFINE_LOCK_GUARD_1(rwlock_init, rwlock_t, rwlock_init(_T->lock), /* */) +DECLARE_LOCK_GUARD_1_ATTRS(rwlock_init, __acquires(_T), __releases(*(rwloc= k_t **)_T)) +#define class_rwlock_init_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(rwlock_i= nit, _T) + #undef __LINUX_INSIDE_SPINLOCK_H #endif /* __LINUX_SPINLOCK_H */ diff --git a/lib/test_context-analysis.c b/lib/test_context-analysis.c index 1c5a381461fc..0f05943d957f 100644 --- a/lib/test_context-analysis.c +++ b/lib/test_context-analysis.c @@ -35,7 +35,7 @@ static void __used test_common_helpers(void) }; \ static void __used test_##class##_init(struct test_##class##_data *d) \ { \ - type_init(&d->lock); \ + guard(type_init)(&d->lock); \ d->counter =3D 0; \ } \ static void __used test_##class(struct test_##class##_data *d) \ @@ -83,7 +83,7 @@ static void __used test_common_helpers(void) =20 TEST_SPINLOCK_COMMON(raw_spinlock, raw_spinlock_t, - raw_spin_lock_init, + raw_spinlock_init, raw_spin_lock, raw_spin_unlock, raw_spin_trylock, @@ -109,7 +109,7 @@ static void __used test_raw_spinlock_trylock_extra(stru= ct test_raw_spinlock_data =20 TEST_SPINLOCK_COMMON(spinlock, spinlock_t, - spin_lock_init, + spinlock_init, spin_lock, spin_unlock, spin_trylock, @@ -163,7 +163,7 @@ struct test_mutex_data { =20 static void __used test_mutex_init(struct test_mutex_data *d) { - mutex_init(&d->mtx); + guard(mutex_init)(&d->mtx); d->counter =3D 0; } =20 @@ -226,7 +226,7 @@ struct test_seqlock_data { =20 static void __used test_seqlock_init(struct test_seqlock_data *d) { - seqlock_init(&d->sl); + guard(seqlock_init)(&d->sl); d->counter =3D 0; } =20 @@ -275,7 +275,7 @@ struct test_rwsem_data { =20 static void __used test_rwsem_init(struct test_rwsem_data *d) { - init_rwsem(&d->sem); + guard(rwsem_init)(&d->sem); d->counter =3D 0; } =20 @@ -475,7 +475,7 @@ static DEFINE_PER_CPU(struct test_local_lock_data, test= _local_lock_data) =3D { =20 static void __used test_local_lock_init(struct test_local_lock_data *d) { - local_lock_init(&d->lock); + guard(local_lock_init)(&d->lock); d->counter =3D 0; } =20 @@ -519,7 +519,7 @@ static DEFINE_PER_CPU(struct test_local_trylock_data, t= est_local_trylock_data) =3D =20 static void __used test_local_trylock_init(struct test_local_trylock_data = *d) { - local_trylock_init(&d->lock); + guard(local_trylock_init)(&d->lock); d->counter =3D 0; } =20 --=20 2.52.0.457.g6b5491de43-goog From nobody Sun Feb 8 02:21:27 2026 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 891C9357A54 for ; Mon, 19 Jan 2026 09:40:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768815657; cv=none; b=X1F8VHiu2byov0KZC5kLl1mItoPvHBRyigavjxPZT+jYCyxuR4JueSCb9P6WAm0Amcy1fghRrNVt4/sszfb6QmAoZfnoaYYibCV+6iB5Gr8SP3OTAYsPSYZuTW14NykN96x0FKSnFc/xyk4C/ToqQcDfGfgYmPYxUnr2FFLoIBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768815657; c=relaxed/simple; bh=imqmTq6qC6AvvOLRifzHIuTmTh3LUGINsRwO5tNrj/Y=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=soij/RCdAECcj9cwmnb3cGEaYdoIAoZ2wNk+LoY6++zG4OgdEFpn8ouvSQYdGAf758r/+vhwngP3pS65nm5PMbastcRDEOwKWNLO7pko7h1ZCdlOJCwPohKaiCgoCYiW1/I3jdKdjiA38VtdhZvIrvcUCp9fdJQ0jm7w9/ZGlPc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--elver.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=L0VmLEdg; arc=none smtp.client-ip=209.85.221.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--elver.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="L0VmLEdg" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-434302283dcso3190629f8f.0 for ; Mon, 19 Jan 2026 01:40:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768815654; x=1769420454; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ewHt49qLKu+2CyU8hq2cJxrH6CXFZn4CCknA2bnTf50=; b=L0VmLEdgoX6kCOGL+kVmGoou8lkrcSDOzhY4t3FvkKZVtXnffe2NED9Ya/eFvT073L 9qeidD7dBAfbdSFEhPGSQYdWlA78OmsNTD45oqGOil2WnYmQSwLpc3SLv37vF5BuVMzj /9mUS/gLpY84Divp/8aksNlIbLVBfInc4eKrBAOR/xsE8V5cAoPRgBPNGwMq+t1JUKO6 aQXcPLFEFuRoFsKOaHZ7O1n4BG0BMTyIpbZSJclAZHpFkwYzF6GvGEpS9uoV3pIj1Y4I 80Ts40bFE/H33kCqH5NXBZTm27PpFkoSTpVjB694pHSmUS6dPgJ9grJp6CqygVLJfTYc QHqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768815654; x=1769420454; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ewHt49qLKu+2CyU8hq2cJxrH6CXFZn4CCknA2bnTf50=; b=eAr9lI05UmxnkdNYR3vLtSUxvu/1Y+nduOm+/U1M3QLTOuoSWFEGlrFYx7j9J8t5BC YUEFeWr3NWqp5JbXL8MCxG0unKUGWX8P9HqgylI/UurjcF0a3h5LLAgqmGaczUPWyRXP UM84VgUYzu8XIemZcDGmhjfI4K0THjWivirEDp6vQ9yt9eM9Q8UScLplWUCwfxcM6NWI p4xMo9uhT0KCw8nfDGkh0yNWln8miLkN799yWoAfAA9XEKqOEcdzrnrfICJLDIq9PWWR 5Fh660E3m8ZHT1+pYfHY9ET3mijpmW8yzlX18IoEW5XWoHbD3Jy4x4Ddky+F/2TjrlvB yYpA== X-Forwarded-Encrypted: i=1; AJvYcCW2buQphYTYmRW7jvQrtSbKJC+/XJScHik9w7/pz7yvgLiavHxKxdb0YZykzQyZztV6FdsFKRDr6rpLa+w=@vger.kernel.org X-Gm-Message-State: AOJu0YzSV9dHBWPFRJlOqWWoKyDnxQr5DoSSWvLmUZlOyky/0WtoMQUl G5j5Q/ezC31aQbtYjVdSRrGCRPzRjiJOhSS7Sooa2YsXr5MMSdfcu/hycGAv70IV2dRcoUG4ZN2 kGw== X-Received: from wrsz3.prod.google.com ([2002:a5d:4c83:0:b0:430:fcb8:38c0]) (user=elver job=prod-delivery.src-stubby-dispatcher) by 2002:a5d:64e9:0:b0:432:5bf9:cf22 with SMTP id ffacd0b85a97d-435699709f8mr14538540f8f.3.1768815653726; Mon, 19 Jan 2026 01:40:53 -0800 (PST) Date: Mon, 19 Jan 2026 10:05:53 +0100 In-Reply-To: <20260119094029.1344361-1-elver@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260119094029.1344361-1-elver@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260119094029.1344361-4-elver@google.com> Subject: [PATCH tip/locking/core 3/6] kcov: Use scoped init guard From: Marco Elver To: elver@google.com, Peter Zijlstra , Ingo Molnar Cc: Thomas Gleixner , Will Deacon , Boqun Feng , Waiman Long , Christoph Hellwig , Steven Rostedt , Bart Van Assche , kasan-dev@googlegroups.com, llvm@lists.linux.dev, linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert lock initialization to scoped guarded initialization where lock-guarded members are initialized in the same scope. This ensures the context analysis treats the context as active during member initialization. This is required to avoid errors once implicit context assertion is removed. Signed-off-by: Marco Elver --- kernel/kcov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/kcov.c b/kernel/kcov.c index 6cbc6e2d8aee..5397d0c14127 100644 --- a/kernel/kcov.c +++ b/kernel/kcov.c @@ -530,7 +530,7 @@ static int kcov_open(struct inode *inode, struct file *= filep) kcov =3D kzalloc(sizeof(*kcov), GFP_KERNEL); if (!kcov) return -ENOMEM; - spin_lock_init(&kcov->lock); + guard(spinlock_init)(&kcov->lock); kcov->mode =3D KCOV_MODE_DISABLED; kcov->sequence =3D 1; refcount_set(&kcov->refcount, 1); --=20 2.52.0.457.g6b5491de43-goog From nobody Sun Feb 8 02:21:27 2026 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 573A53587B1 for ; Mon, 19 Jan 2026 09:40:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768815660; cv=none; b=lFpsrLHyGmYElmhszDMPz+RajVMEmoz4S//zbBOOLI9aQb4qWvEF4EiZZBkH9QUM6VNNg+janmLIYRMY2PwPmlmLHzr4DtFgn/KRhQ1TcAa/eUoB1XEnRwb/vVDfLYT+mfCer5dlvSxw00A9u9NgymTArHzwQ193qzeNMawyaFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768815660; c=relaxed/simple; bh=y9/1uLJMC7+X7yi1h38x4esMDvrYwSDX9pt6Sh+Dy/I=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=bXzDEGiYLlt1ph02C0OLb9Pwo1frs55Ojige1E3ooe+TFcqW9GG8fVHfzaBSSkm8mMpVi0R2jQUWrEgVfvIXNiMCWcw5UO5VhuT72CyUkUG5G5mhAcWjVpa33/pRgNYSw4iPrp11/s+M1z9Dx7pYr1npeR3LN4yC6ISICK1vrqM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--elver.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=lSImHJBn; arc=none smtp.client-ip=209.85.221.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--elver.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lSImHJBn" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-430fc83f58dso2779816f8f.2 for ; Mon, 19 Jan 2026 01:40:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768815657; x=1769420457; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=CA3Nu437Rj+eAevya/i4iek0cQKs4Ymlx+qux+GVc44=; b=lSImHJBn+H6dS9/VrEouBwalyZflWzpJgQBwyX65HgE62415Bckxo4Bu/5W8G0TZzH ZWm070IlDWr73MbNf+U9SOQ1927APAYEc5S6T5+xGmYROb5bFuBAMbssknpHrzBTJvfq zxz6HmOUw4dO0X2Ziwe6p2S9qfFP01tYL79zXp6ca34KHL2vz7nXNNT0l5kp1Z8w2n0f Mm9p9jvGl0j28oYIvUix+b2KaEwTPY7pTji2P51gSrS/ubz6j6lUGRET9TFa1ffQacBV B1Ggusozm+sqPd2mhGIUicx7ioCLsPI6kIr+HXRgJeqLZQ830oXjTWWYBycc8mmlbNoU mV1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768815657; x=1769420457; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CA3Nu437Rj+eAevya/i4iek0cQKs4Ymlx+qux+GVc44=; b=XP1ReDYXCpt5J4AjkyE5Ms3HOkbGZste5wgQUpCzrVn2BqXc46SgBY9AJOLDZeX0Ep LlXNAAi0r89W7skEP4kxtqgRSH0Q9QOpdHoVasKiwdTouVqj7aC6FHY9Ty9B17ak0PW3 m4nyQlh8jmO2jBPM9AaZpfslBRW4+uuGVKV5ZS6FsZg6GTJkog9ozSJV7IPn7ocmkAUU v4/u7WBYbUshGD5aJiBNOaa2KEUD2sVyWq560V66djjx5YXIRHVYfSCdPNDawz2yyshx wwuFf/GEohlxFtckJ3LtysXpX5wy1zYkGPWyccJ+rZrxoZlghUgtJgyoI7fKUpITJecS 14fQ== X-Forwarded-Encrypted: i=1; AJvYcCUM1oQUgz2jc4b41bmCkHC6LiASURg19sXMFafjKZJb4W1M3wPcjgkiGaTmZLQFa8hzUW9tAh6cKtlPR14=@vger.kernel.org X-Gm-Message-State: AOJu0YwK+Ofl4j6o4W9LR47nwudzRMmdlw29uNZMZJDPePbxo8r2bqCa gtPTw8TTIE/N6gQ3GxD4YXTBwSZRXBQwxcEa6WmpfHhP8FAtXeR3VDcc4l2Gig0hq2MP1D8Baxr x4w== X-Received: from wmbka9.prod.google.com ([2002:a05:600c:5849:b0:480:2880:4d51]) (user=elver job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600d:6413:10b0:480:1e40:3d2 with SMTP id 5b1f17b1804b1-4801e400518mr100658775e9.29.1768815656749; Mon, 19 Jan 2026 01:40:56 -0800 (PST) Date: Mon, 19 Jan 2026 10:05:54 +0100 In-Reply-To: <20260119094029.1344361-1-elver@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260119094029.1344361-1-elver@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260119094029.1344361-5-elver@google.com> Subject: [PATCH tip/locking/core 4/6] crypto: Use scoped init guard From: Marco Elver To: elver@google.com, Peter Zijlstra , Ingo Molnar Cc: Thomas Gleixner , Will Deacon , Boqun Feng , Waiman Long , Christoph Hellwig , Steven Rostedt , Bart Van Assche , kasan-dev@googlegroups.com, llvm@lists.linux.dev, linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert lock initialization to scoped guarded initialization where lock-guarded members are initialized in the same scope. This ensures the context analysis treats the context as active during member initialization. This is required to avoid errors once implicit context assertion is removed. Signed-off-by: Marco Elver --- crypto/crypto_engine.c | 2 +- crypto/drbg.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crypto/crypto_engine.c b/crypto/crypto_engine.c index 1653a4bf5b31..afb6848f7df4 100644 --- a/crypto/crypto_engine.c +++ b/crypto/crypto_engine.c @@ -453,7 +453,7 @@ struct crypto_engine *crypto_engine_alloc_init_and_set(= struct device *dev, snprintf(engine->name, sizeof(engine->name), "%s-engine", dev_name(dev)); =20 - spin_lock_init(&engine->queue_lock); + guard(spinlock_init)(&engine->queue_lock); crypto_init_queue(&engine->queue, qlen); =20 engine->kworker =3D kthread_run_worker(0, "%s", engine->name); diff --git a/crypto/drbg.c b/crypto/drbg.c index 0a6f6c05a78f..21b339c76cca 100644 --- a/crypto/drbg.c +++ b/crypto/drbg.c @@ -1780,7 +1780,7 @@ static inline int __init drbg_healthcheck_sanity(void) if (!drbg) return -ENOMEM; =20 - mutex_init(&drbg->drbg_mutex); + guard(mutex_init)(&drbg->drbg_mutex); drbg->core =3D &drbg_cores[coreref]; drbg->reseed_threshold =3D drbg_max_requests(drbg); =20 --=20 2.52.0.457.g6b5491de43-goog From nobody Sun Feb 8 02:21:27 2026 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42C43358D0A for ; Mon, 19 Jan 2026 09:41:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768815663; cv=none; b=YfF6C4uKyYjxmdCQv0DP1+3pB8eZ1CVociVhtI8aL1r+ZKUBXU3zAffvafLw+VyDHQZNYiUVoef2taMrSoOeIsPiCJ4e1+1Ik59y7yVpT/KKdXxTT0hNRZ1FHnz2U61rpoN8LnB+qW+NAXgm+x6ueUGX1WkY5rusViPrWRmaLOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768815663; c=relaxed/simple; bh=fI1glmYoH1DqxqK83xKlTtx/Ar+iZrLYeSgCJ+MEbqk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=iRMQ0enH5nOuJU+Zi5MeTEiDct6nKQRy5r6wVbxfZKaM8tIVC3b2OeuOUY8Zb/73xZUXUJg1UT3OJpNeR6Va6VQt0OpQpVvHGteJrupfy0jrjsIfYa6U3dgHgDZ+RaKX1TPE00q05I6PpxwMADNT2SZAIRDSryUfQJrU7uoiQ3A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--elver.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=uu0zsUK2; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--elver.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="uu0zsUK2" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-477c49f273fso38248585e9.3 for ; Mon, 19 Jan 2026 01:41:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768815660; x=1769420460; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=5O5shuIyt2OF6tzGpJJeUtztHqWv8B89x7ZKRetoFcY=; b=uu0zsUK23jzmEiaM2Subjz/ybCMO0DMBce9778NGTfo96iqoQN8UXZCF7eAGW1zAT3 4bXPHXoe4IY5Ab74cv7dW31EZpR0dAPxrNmiOqWzKk1duMMqVIfwXumBLoV6SLivHliF OVGP31IrWiXyDXqxnrIMDT07qTvhg5kaA2eebblQxjVyRlzpwrKlyvxmgXw2uiYRSt4a qQkayttv06jd9yRvkrwzByurgxm1GzM2kHfF2jfp0JcvmcjoKD8Gt4yh4FMawZOogYYJ gib4rQeHt5rR/+JTTx9fvr3DO0QmcBz87i8Ktb0EwJX3xBvcluAHub0hFBzJewhzcXUx f69g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768815660; x=1769420460; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5O5shuIyt2OF6tzGpJJeUtztHqWv8B89x7ZKRetoFcY=; b=mlkR/xpFRFK8o/CZcBRm0YOM68urqf78NubCpIuKPfyKlewmxcp/GTa6pgPBtskIji nE63dQkJGrTNG1UGfk8c1fscEc3WneK4mCeK5SyNkqtz7OnTUcsxJToBleo2c+i9GMy6 fi17R/DSeJaV6VhJVSEvpvPtEJAiNUKcBisKaY+xOQOyQEBoqmyewCIIBgdkj51vVwCX AbO6NCfMblx/tbQnQTB/kAOk8/OeoW+z+0xaQ3zLRoYgzcNmbowoFq0TpE7P5b3KNrIn QJI3yIgEoDLMY6rIX4WAk3thDAmjAv8KSHXEgQOJws8o/auuMsgPeK0JEkI2aVNPw4J6 DurA== X-Forwarded-Encrypted: i=1; AJvYcCV81T02KPnIqVmv5IrmCg6mfioNUB8j2WyVtaSLdjd3R4I7E8Iz4tbkl6SRvwrkRLDsGG3c7uI6Omlsp5M=@vger.kernel.org X-Gm-Message-State: AOJu0YzuiAVKLpC6kr3gd+t/yM6NuLd/Xj8hNVTW/xEOX3pWtxkrsnTQ gwdLjlLbq17jKy0SRv6FpWES4h2NuHdFKWuSGqEQ22ZBiWTE6v5bkhXJDYJgqAJei+CS+waFG8w +Fw== X-Received: from wmbhb2.prod.google.com ([2002:a05:600c:8682:b0:480:3842:3532]) (user=elver job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:8b81:b0:480:32da:f338 with SMTP id 5b1f17b1804b1-48032daf48bmr41618245e9.14.1768815659820; Mon, 19 Jan 2026 01:40:59 -0800 (PST) Date: Mon, 19 Jan 2026 10:05:55 +0100 In-Reply-To: <20260119094029.1344361-1-elver@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260119094029.1344361-1-elver@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260119094029.1344361-6-elver@google.com> Subject: [PATCH tip/locking/core 5/6] tomoyo: Use scoped init guard From: Marco Elver To: elver@google.com, Peter Zijlstra , Ingo Molnar Cc: Thomas Gleixner , Will Deacon , Boqun Feng , Waiman Long , Christoph Hellwig , Steven Rostedt , Bart Van Assche , kasan-dev@googlegroups.com, llvm@lists.linux.dev, linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert lock initialization to scoped guarded initialization where lock-guarded members are initialized in the same scope. This ensures the context analysis treats the context as active during member initialization. This is required to avoid errors once implicit context assertion is removed. Signed-off-by: Marco Elver --- security/tomoyo/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c index 86ce56c32d37..7e1f825d903b 100644 --- a/security/tomoyo/common.c +++ b/security/tomoyo/common.c @@ -2557,7 +2557,7 @@ int tomoyo_open_control(const u8 type, struct file *f= ile) =20 if (!head) return -ENOMEM; - mutex_init(&head->io_sem); + guard(mutex_init)(&head->io_sem); head->type =3D type; switch (type) { case TOMOYO_DOMAINPOLICY: --=20 2.52.0.457.g6b5491de43-goog From nobody Sun Feb 8 02:21:27 2026 Received: from mail-ej1-f73.google.com (mail-ej1-f73.google.com [209.85.218.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DAE3A358D03 for ; Mon, 19 Jan 2026 09:41:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768815666; cv=none; b=jP2Y/A6dJvGtVH/F4rx8iW4tjRUyd6L9GBnbeJ3f91qxUv+/4IQ7IRFH/iiDLcOMH8pRqK3IjhbOl51m5wgOjLU6slktabGIuTb3yZuYLExtaoNUwMSLX20jdwf95fbLqtxkugq+xReT6PL7fdmS0IE7YGipqbflObqIZT8Fr/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768815666; c=relaxed/simple; bh=Rz5y7C4R6h2lPczYksr0SVq/IrzgSt5kMTodp36I+ag=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Eb+BvBht71QhVOdFOie8E7ZW2KGSKvZdpatqLYb7lvxJNBPWYQr+4h5X4KBthgUq3K1+xWpB20LqUpcFdBg6QW9802ndt5Xuj/OkQtyH6Ki8n0KCv+ObzguXvdq6NrD/BOgH/erxmX6OStF2wOucA1mr74pFcLUNpR5JDwY5o54= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--elver.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=QsrldsFN; arc=none smtp.client-ip=209.85.218.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--elver.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QsrldsFN" Received: by mail-ej1-f73.google.com with SMTP id a640c23a62f3a-b87039c9a43so489090266b.1 for ; Mon, 19 Jan 2026 01:41:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768815662; x=1769420462; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=hOlRW9xg19eCgYwriGsA0YBy8PVXki3QHZit/P09OME=; b=QsrldsFN3DHYzrDh1yE2q76dxLD3aFkiydurI0ZYXeZIS1vMwzMjMIH6+HILZ4rjzK 7656x/aaTHydyYZLfWkFhLa5SBr+rh1+u7Z/2blUXLW3sgUvHSj6TsEjg3zsCwHlbFkh mc5zf/hzIS9n0M3mS4TxZqzsN5ifzpNIgCeAHgerAjcsm2O7v5nsjAWNYQpoRIsMLsRb EriSXMa3/Dm3bkBm4tSW7cD3Wyu/bDGSPDtx57U/cVZ3XbTPyWcTPCaF3AX6oK85Cgjl VWSg9cxhnQpZ4tIQttfTnDmMuxLi4yDeQC7asHb1V7oWm3Vmj7ol95ETQ5Uz7+LAoBt1 tSGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768815662; x=1769420462; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hOlRW9xg19eCgYwriGsA0YBy8PVXki3QHZit/P09OME=; b=ejK1WD0+Rftxr1VtSYcgJthcGjSvykNdZ3WIRKT5B37e8wyq7Yj8okhXIHqZo3yz5T RglZNUZWTaIxtSAcOx6AuMjzoqpd5k5oOMtd0YhXOEduaGTx9mK83cFUT9AB+Vme9D2h b8sOTZROMdYwRGh1dXLvOkpRU7gwPGrE+8Q2zFEWvwuvZZ6ezgdo4x0qT4gjyS9uhVsO HM40PPCDkKz8fm1hr49Jn8sifVWh9KpbTrNcg351qu1tk0tOZkzdDUcy/SUNrMAv0CNp mH1xzkrnvgRyH/48iZbfOA0JI4/QB7/BOKAIXyFXY0kagxMDtGlwc7UwHeRqn/nQLaYM QaCw== X-Forwarded-Encrypted: i=1; AJvYcCVly5/tlnSYkFEGI1vZO59JNw9r3la5u/RRNc8FJPK2Ad5KeO0woNVSuKX6bqhd3LzbkzXLESMleOT4aNA=@vger.kernel.org X-Gm-Message-State: AOJu0Yxv5XzdkX2GriNgcJnaKcGcyaWT3rNhP3zeNVqItwsG0OQgGuwd zDo1kLEaQXckDHconYw4s8vd/zRrpBBvuOxbNSAw4MXubtYIaV5Q/afVx+6TWrsA9Dn9BbyWJ9j lmg== X-Received: from ejek27.prod.google.com ([2002:a17:906:2a5b:b0:b7a:21aa:899e]) (user=elver job=prod-delivery.src-stubby-dispatcher) by 2002:a17:907:3f21:b0:b87:25a7:3ea0 with SMTP id a640c23a62f3a-b87968f6e82mr875438166b.25.1768815662390; Mon, 19 Jan 2026 01:41:02 -0800 (PST) Date: Mon, 19 Jan 2026 10:05:56 +0100 In-Reply-To: <20260119094029.1344361-1-elver@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260119094029.1344361-1-elver@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260119094029.1344361-7-elver@google.com> Subject: [PATCH tip/locking/core 6/6] compiler-context-analysis: Remove __assume_ctx_lock from initializers From: Marco Elver To: elver@google.com, Peter Zijlstra , Ingo Molnar Cc: Thomas Gleixner , Will Deacon , Boqun Feng , Waiman Long , Christoph Hellwig , Steven Rostedt , Bart Van Assche , kasan-dev@googlegroups.com, llvm@lists.linux.dev, linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove __assume_ctx_lock() from lock initializers. Implicitly asserting an active context during initialization caused false-positive double-lock errors when acquiring a lock immediately after i= ts initialization. Moving forward, guarded member initialization must either: 1. Use guard(type_init)(&lock) or scoped_guard(type_init, ...). 2. Use context_unsafe() for simple initialization. Link: https://lore.kernel.org/all/57062131-e79e-42c2-aa0b-8f931cb8cac2@acm.= org/ Reported-by: Bart Van Assche Signed-off-by: Marco Elver --- include/linux/local_lock_internal.h | 3 --- include/linux/mutex.h | 1 - include/linux/rwlock.h | 3 +-- include/linux/rwlock_rt.h | 1 - include/linux/rwsem.h | 2 -- include/linux/seqlock.h | 1 - include/linux/spinlock.h | 5 +---- include/linux/spinlock_rt.h | 1 - include/linux/ww_mutex.h | 1 - lib/test_context-analysis.c | 6 ------ 10 files changed, 2 insertions(+), 22 deletions(-) diff --git a/include/linux/local_lock_internal.h b/include/linux/local_lock= _internal.h index 4521c40895f8..ebfcdf517224 100644 --- a/include/linux/local_lock_internal.h +++ b/include/linux/local_lock_internal.h @@ -87,13 +87,11 @@ do { \ 0, LD_WAIT_CONFIG, LD_WAIT_INV, \ LD_LOCK_PERCPU); \ local_lock_debug_init(lock); \ - __assume_ctx_lock(lock); \ } while (0) =20 #define __local_trylock_init(lock) \ do { \ __local_lock_init((local_lock_t *)lock); \ - __assume_ctx_lock(lock); \ } while (0) =20 #define __spinlock_nested_bh_init(lock) \ @@ -105,7 +103,6 @@ do { \ 0, LD_WAIT_CONFIG, LD_WAIT_INV, \ LD_LOCK_NORMAL); \ local_lock_debug_init(lock); \ - __assume_ctx_lock(lock); \ } while (0) =20 #define __local_lock_acquire(lock) \ diff --git a/include/linux/mutex.h b/include/linux/mutex.h index 6b12009351d2..ecaa0440f6ec 100644 --- a/include/linux/mutex.h +++ b/include/linux/mutex.h @@ -62,7 +62,6 @@ do { \ static struct lock_class_key __key; \ \ __mutex_init((mutex), #mutex, &__key); \ - __assume_ctx_lock(mutex); \ } while (0) =20 /** diff --git a/include/linux/rwlock.h b/include/linux/rwlock.h index 65a5b55e1bcd..3390d21c95dd 100644 --- a/include/linux/rwlock.h +++ b/include/linux/rwlock.h @@ -22,11 +22,10 @@ do { \ static struct lock_class_key __key; \ \ __rwlock_init((lock), #lock, &__key); \ - __assume_ctx_lock(lock); \ } while (0) #else # define rwlock_init(lock) \ - do { *(lock) =3D __RW_LOCK_UNLOCKED(lock); __assume_ctx_lock(lock); } whi= le (0) + do { *(lock) =3D __RW_LOCK_UNLOCKED(lock); } while (0) #endif =20 #ifdef CONFIG_DEBUG_SPINLOCK diff --git a/include/linux/rwlock_rt.h b/include/linux/rwlock_rt.h index 37b387dcab21..5353abbfdc0b 100644 --- a/include/linux/rwlock_rt.h +++ b/include/linux/rwlock_rt.h @@ -22,7 +22,6 @@ do { \ \ init_rwbase_rt(&(rwl)->rwbase); \ __rt_rwlock_init(rwl, #rwl, &__key); \ - __assume_ctx_lock(rwl); \ } while (0) =20 extern void rt_read_lock(rwlock_t *rwlock) __acquires_shared(rwlock); diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h index ea1bbdb57a47..9bf1d93d3d7b 100644 --- a/include/linux/rwsem.h +++ b/include/linux/rwsem.h @@ -121,7 +121,6 @@ do { \ static struct lock_class_key __key; \ \ __init_rwsem((sem), #sem, &__key); \ - __assume_ctx_lock(sem); \ } while (0) =20 /* @@ -175,7 +174,6 @@ do { \ static struct lock_class_key __key; \ \ __init_rwsem((sem), #sem, &__key); \ - __assume_ctx_lock(sem); \ } while (0) =20 static __always_inline int rwsem_is_locked(const struct rw_semaphore *sem) diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index 22216df47b0f..c0c6235dff59 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h @@ -817,7 +817,6 @@ static __always_inline void write_seqcount_latch_end(se= qcount_latch_t *s) do { \ spin_lock_init(&(sl)->lock); \ seqcount_spinlock_init(&(sl)->seqcount, &(sl)->lock); \ - __assume_ctx_lock(sl); \ } while (0) =20 /** diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index 7b11991c742a..e1e2f144af9b 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h @@ -106,12 +106,11 @@ do { \ static struct lock_class_key __key; \ \ __raw_spin_lock_init((lock), #lock, &__key, LD_WAIT_SPIN); \ - __assume_ctx_lock(lock); \ } while (0) =20 #else # define raw_spin_lock_init(lock) \ - do { *(lock) =3D __RAW_SPIN_LOCK_UNLOCKED(lock); __assume_ctx_lock(lock);= } while (0) + do { *(lock) =3D __RAW_SPIN_LOCK_UNLOCKED(lock); } while (0) #endif =20 #define raw_spin_is_locked(lock) arch_spin_is_locked(&(lock)->raw_lock) @@ -324,7 +323,6 @@ do { \ \ __raw_spin_lock_init(spinlock_check(lock), \ #lock, &__key, LD_WAIT_CONFIG); \ - __assume_ctx_lock(lock); \ } while (0) =20 #else @@ -333,7 +331,6 @@ do { \ do { \ spinlock_check(_lock); \ *(_lock) =3D __SPIN_LOCK_UNLOCKED(_lock); \ - __assume_ctx_lock(_lock); \ } while (0) =20 #endif diff --git a/include/linux/spinlock_rt.h b/include/linux/spinlock_rt.h index 0a585768358f..373618a4243c 100644 --- a/include/linux/spinlock_rt.h +++ b/include/linux/spinlock_rt.h @@ -20,7 +20,6 @@ static inline void __rt_spin_lock_init(spinlock_t *lock, = const char *name, do { \ rt_mutex_base_init(&(slock)->lock); \ __rt_spin_lock_init(slock, name, key, percpu); \ - __assume_ctx_lock(slock); \ } while (0) =20 #define _spin_lock_init(slock, percpu) \ diff --git a/include/linux/ww_mutex.h b/include/linux/ww_mutex.h index 58e959ee10e9..c47d4b9b88b3 100644 --- a/include/linux/ww_mutex.h +++ b/include/linux/ww_mutex.h @@ -107,7 +107,6 @@ context_lock_struct(ww_acquire_ctx) { */ static inline void ww_mutex_init(struct ww_mutex *lock, struct ww_class *ww_class) - __assumes_ctx_lock(lock) { ww_mutex_base_init(&lock->base, ww_class->mutex_name, &ww_class->mutex_ke= y); lock->ctx =3D NULL; diff --git a/lib/test_context-analysis.c b/lib/test_context-analysis.c index 0f05943d957f..140efa8a9763 100644 --- a/lib/test_context-analysis.c +++ b/lib/test_context-analysis.c @@ -542,12 +542,6 @@ struct test_ww_mutex_data { int counter __guarded_by(&mtx); }; =20 -static void __used test_ww_mutex_init(struct test_ww_mutex_data *d) -{ - ww_mutex_init(&d->mtx, &ww_class); - d->counter =3D 0; -} - static void __used test_ww_mutex_lock_noctx(struct test_ww_mutex_data *d) { if (!ww_mutex_lock(&d->mtx, NULL)) { --=20 2.52.0.457.g6b5491de43-goog