From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 62B5045D91C; Tue, 15 Sep 2026 08:23:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789460604; cv=none; b=gM2CuRcLL+lZnAQwXG0X3v8HFsgQoBXDzRL2crerV9MfoMQFeJ9AvwpKXGab5JvsL1eILL1IrkatgKrRi4t/QIfINqaKBfzG9/GI5AZOI2k/lSEuA5ZYSeTV/RSQZfL3nXVIlJYNxwMNr5BaKUwz7feqIKLdLbvPWR52AYRtsZA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789460604; c=relaxed/simple; bh=Q6hjAE+9q8egGVVb02CPWb1wLjOusvGxKkXCzWLChHg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kCzpDxx8cXiQnx8vYFQFzW5b4fcdNVscnHBsUfKYs5EjS4p15M0rVszAu9qHnXhJ/t494tehcec0rcZfuVbLOzurCXdljD6a3gwMO9zV2O31MN4S6vvYNRNFHm3j2nzSuxtELkWOoYg6d9GZTjn2Hjs6JdZ04q+xC5ZY3jBXqDs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=pass smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=ipzJcm8I; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=pass 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="ipzJcm8I" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=GLQ264WxN6wDQzABD1f2vOcHnnY8r7L3wdbiMWb63xA=; b=ipzJcm8I1ST/GUt421dYmJnfyI vMJ7fwLPm50oqJU0jqpXgWe24q407KlTdH7SXHQr7TDXrJ0cM1tEYBnW9xuMF681fSZbRWEhC0xLD 6pneXq40+9I4oviAF01pBkAh9+iexFHZvr8Q0AJ9eQUZ1IpxpzGhf4HDVrlwFQYzTx+rlpPRZqXIS bi5aWaDAYx9YdPtSyaz9+cEy9G45/haDccskEkn/nT4u1JIUGIvbu/z3wOp8oYMS5UFYrgQZ3LkKc D4oDDw5Avnj0AUqbEB+wgK/erFclXrfrCAUd2232oXhxiftApCzjDlcWbdLgQanaRy0SwbWde3WVp 73UWs78A==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.99.2 #2 (Red Hat Linux)) id 1x6ORS-00000006QWi-1bHr; Tue, 15 Sep 2026 08:23:04 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id F1FDF3012C6; Tue, 15 Sep 2026 10:23:00 +0200 (CEST) Date: Tue, 15 Sep 2026 10:23:00 +0200 From: Peter Zijlstra To: Yury Norov Cc: Andrew Morton , "Jason A. Donenfeld" , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthew Wilcox , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Dennis Zhou , Tejun Heo , Christoph Lameter , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Uladzislau Rezki , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Onur =?iso-8859-1?Q?=D6zkan?= , Kees Cook , Joel Granados , Anna-Maria Behnsen , Thomas Gleixner , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , Mike Rapoport , "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , Pedro Falcato , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , Sebastian Andrzej Siewior , Clark Williams , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, rcu@vger.kernel.org, virtualization@lists.linux.dev, linux-rt-devel@lists.linux.dev, llvm@lists.linux.dev, Yury Norov Subject: Re: [PATCH 01/17] locking/mutex: assert static storage for DEFINE_MUTEX() Message-ID: <20260915082300.GV4121339@noisy.programming.kicks-ass.net> References: <20260915030336.1192299-1-ynorov@nvidia.com> <20260915030336.1192299-2-ynorov@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@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: <20260915030336.1192299-2-ynorov@nvidia.com> On Mon, Sep 14, 2026 at 11:03:19PM -0400, Yury Norov wrote: > DEFINE_MUTEX() uses a static lock initializer whose lockdep class key > requires a persistent object address. Reject automatic local declarations > with ASSERT_STATIC_STORAGE(), in both the regular and PREEMPT_RT variants. > Align the VMA and memblock tools stubs with the kernel declaration. > > The two automatic mutexes in the WireGuard allowedips selftests already > call mutex_init(). Replace their redundant static initializers with plain > struct mutex declarations. > > Assisted-by: OpenAI Codex > Signed-off-by: Yury Norov > --- > drivers/net/wireguard/selftest/allowedips.c | 4 ++-- > include/linux/mutex.h | 7 +++++-- > tools/testing/memblock/linux/mutex.h | 8 ++++++-- > tools/testing/vma/include/dup.h | 5 ++++- > 4 files changed, 17 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/wireguard/selftest/allowedips.c b/drivers/net/wireguard/selftest/allowedips.c > index 3e857e6fb627..ecb2908228e7 100644 > --- a/drivers/net/wireguard/selftest/allowedips.c > +++ b/drivers/net/wireguard/selftest/allowedips.c > @@ -257,7 +257,7 @@ static __init bool randomized_test(void) > u8 ip[16], mutate_mask[16], mutated[16]; > struct wg_peer **peers, *peer; > struct horrible_allowedips h; > - DEFINE_MUTEX(mutex); > + struct mutex mutex; > struct allowedips t; > bool ret = false; > > @@ -499,7 +499,7 @@ bool __init wg_allowedips_selftest(void) > struct allowedips_node *iter_node; > bool success = false; > struct allowedips t; > - DEFINE_MUTEX(mutex); > + struct mutex mutex; > struct in6_addr ip; > size_t i = 0, count = 0; > __be64 part; This should probably be a separate patch. > diff --git a/include/linux/mutex.h b/include/linux/mutex.h > index 734048c02f4f..2f2d95f3097c 100644 > --- a/include/linux/mutex.h > +++ b/include/linux/mutex.h > @@ -11,6 +11,7 @@ > #ifndef __LINUX_MUTEX_H > #define __LINUX_MUTEX_H > > +#include > #include > #include > #include > @@ -84,7 +85,8 @@ do { \ > __DEP_MAP_MUTEX_INITIALIZER(lockname) } > > #define DEFINE_MUTEX(mutexname) \ > - struct mutex mutexname = __MUTEX_INITIALIZER(mutexname) > + struct mutex mutexname = __MUTEX_INITIALIZER(mutexname); \ > + ASSERT_STATIC_STORAGE(mutexname) My tree no has ASSERT_STATIC_STORAGE. Please repost when that lands?