From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 B02CA2C181 for ; Sun, 23 Nov 2025 00:50:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763859011; cv=none; b=S8U/Bju3gTjzzGncNMN1izjYLWwuzvYlBy9jEZTCQnzXV7/TV7wIW7OTr8c5RjJ7i3Z0Eike3guYKQT3qfWSCFZ4PIwO1NcTjgApr5oiKIOEezSygnGefmb66XkiRPfgb98FD+TjaHPAMuI82PCC+eUllsjx56DF4gwE1klEQiw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763859011; c=relaxed/simple; bh=5Ak56U/W12KLe8t0XM+P57Ty4rSUk5uO1O6NwpIDJp0=; h=From:Message-ID:Date:MIME-Version:Subject:To:Cc:References: In-Reply-To:Content-Type; b=t5EjfS1JYAymXshecr3173y/zw3vZlJP3oEJ+XtWjlnXP3389iao2zUPahNFiZql16C8SmPf+kz84ROh3Pi3Ug9chEbc3grtHQx+ko6SZ4EAcPTkKU6UkKmeYzv7fUxQcZE3wT2Ye5HsxfA0d3ydi6g70G4chdYevvN0GGvFS8U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=JEI8iW30; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=Iz5Ng3WA; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JEI8iW30"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="Iz5Ng3WA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763859008; h=from:from: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=1VsleZbl4kap2AIyOOAu7UweZ8JL1Y3owLUudYj/vWk=; b=JEI8iW30EW9+ZFXJ7/mKfhXVzr1s//Z4BY4+MN2RK0M8sK7c6YJf2XUSy9xHkxEIomImlq TC1kWUHk0h5MdcET/Te9ly+m7BlD42uegHhvhvylr3aB5hIHpHh5M6yHFTfeVZvFdPeyzm JfGtZTG7+KZOzouc9gZ2eaL904xHfO0= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-527-w12aF-gFPf2ag7f_rkCCqQ-1; Sat, 22 Nov 2025 19:50:06 -0500 X-MC-Unique: w12aF-gFPf2ag7f_rkCCqQ-1 X-Mimecast-MFC-AGG-ID: w12aF-gFPf2ag7f_rkCCqQ_1763859006 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-4ee27e24711so75115731cf.1 for ; Sat, 22 Nov 2025 16:50:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1763859006; x=1764463806; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:user-agent:mime-version:date:message-id:from:from:to :cc:subject:date:message-id:reply-to; bh=1VsleZbl4kap2AIyOOAu7UweZ8JL1Y3owLUudYj/vWk=; b=Iz5Ng3WAQwiyNsQo8asBkCGO4KoLxatcxfCp/roqodPw/Gp5NQZ/jWsXiMaXD3wIQ6 maXuwF+xAvtERsYDrP01Intej/SLLJZfmQPJSr9m6IucJqw7S1qeoxa2PIxyG8rtHKwe NR1lvD23WuH+duwLm0ZiDz0Va5AhFkR+09qQg2Wf/pQ6zO1TVD05xoxPRLsosZ58J9hk bfpRhD1mva0PvBsYMj//xx3KkWvjozmoN/ZaS+FDu1zWONxA2PYRE8Bn0Fk90Z5XXeIY 5PRN3JST/Gi+rKWJuCXNfXoHDa+y5g0ipDQalqS+d31SO+Ec8aTKxmYFfeF0XvCJ88ax 6EkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763859006; x=1764463806; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:user-agent:mime-version:date:message-id:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1VsleZbl4kap2AIyOOAu7UweZ8JL1Y3owLUudYj/vWk=; b=fiulHtHMjUPXPAoA8cNp8gVaZp7mWYMoyrjY/P/vExjsTzgwQ62GLen8+GcT9f/7e8 mBNfn6cpMqJHpCddaywFhUnushl17/LOay2t0X1hRiHJ9XI/00pcYZexG1TGfedfdnCZ kL92dFC/lFgNfQzb2v85lajyTHEMaZfTS1+wA4KivRUeDJvxQbUfGEPgJz9HrT7uQIAd 1E+ZLZbj+fT0BunsLgpgKKKuqEVkZqV07zdV4jEjOhuajabUfwQG7tI8Bb4g56QR/Zyi euganB7vC3elk08q/CAphbT9pzK8NVCo0MBYH+t3H7DdMxrJBcIALHFqzfjesrrT9wSg /ihA== X-Forwarded-Encrypted: i=1; AJvYcCUCa3l3ZWiBHFzhQNTm1szZobocL19rTCGCPfYMsdGA89LOIC37++6HsPbuknt19hV4XhYDONIktdvZ7zQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yx2fjcd0CoivaQPPQMmnAtyZ2s0EGOyWsFwldAse5SOu/rur4yp OT0sTRgvNMjBYQM8mCsVOWi4o8T3+f0wEWG7hdUi+SHCHlug19typMVevUPxBEeO4SaliLMoKs9 ieXN0NoWbkjcQBKv0OiD8mdFrsxGkP67LpW8kXLSKKFB/MtiKQyuGzGJaW/v/pFqKtg== X-Gm-Gg: ASbGncskwTCvAnt7LBA4rjlgkluBhwDv+J7KseET9EaZhSMAiW/kWr6upky9eUXrnKK cELfU/bdVEcchRTQ79X9W4bC/OfNXlTMEUs+CbrmOcuAmJFsZf+RvWmlg3BlfUnCeL73nxXh39C UDNH+nxFCHcoL7NVEubaD7tC3U9MgdeVSE5uyHjySZk2NFbV8bCEPdRP7vrIwgRtHYPr31VusuG t4RweqBJunjRYu+vGUG6cw/oPRkeX0ITduFNOFzgG/jFYX/PnFkjnEMrjT6yUGfBaFupFduNhHR 8OUOagvQ6AdOhCXwn1V0L7fhwin75EXOkSXvNPIrxKt694CR/0Q20Royd8ejP2GWFiBV2DXJEbv 8DIhkjeG0PsX8paETTNMpq+rsDaitQMz3m0iaJjolXD6t/HaxX+ih0bTS X-Received: by 2002:ac8:7f8e:0:b0:4ee:13a1:93bb with SMTP id d75a77b69052e-4ee58aadbc3mr101619221cf.25.1763859006301; Sat, 22 Nov 2025 16:50:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IF81MVycptLQspq8BNB9tQoyOBFYqZ7QSfYTpXeLPOdkHm+mzeU2HZgn9In8pS37ZaHU7d7JQ== X-Received: by 2002:ac8:7f8e:0:b0:4ee:13a1:93bb with SMTP id d75a77b69052e-4ee58aadbc3mr101619051cf.25.1763859005833; Sat, 22 Nov 2025 16:50:05 -0800 (PST) Received: from ?IPV6:2601:188:c102:b180:1f8b:71d0:77b1:1f6e? ([2601:188:c102:b180:1f8b:71d0:77b1:1f6e]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8846e575439sm69378166d6.47.2025.11.22.16.50.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 22 Nov 2025 16:50:05 -0800 (PST) From: Waiman Long X-Google-Original-From: Waiman Long Message-ID: Date: Sat, 22 Nov 2025 19:50:03 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: linux-next: boot warning from the final tree To: Boqun Feng , Nathan Chancellor Cc: Stephen Rothwell , Sebastian Andrzej Siewior , Andrew Morton , Linux Kernel Mailing List , Linux Next Mailing List , Waiman Long , Peter Zijlstra , Ingo Molnar , Will Deacon References: <20251117202214.4f710f02@canb.auug.org.au> <20251121215819.GA1374726@ax162> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/21/25 5:33 PM, Boqun Feng wrote: > Subject: [PATCH] locking/mutex: Initialize mutex::magic even when LOCKDEP=n > > When DEBUG_MUTEXES=y and LOCKDEP=n, mutex_lock() still checks on > ->magic, hence debug_mutex_init() should be called in > mutex_init_generic() as well. While we are at it, decouple LOCKDEP > logic from debug_mutex_init(), because in this way debug_mutex_init() > only needs one parameter, and we now have mutex_init_lockep() for > LOCKDEP=y scenarios. > > Reported-by: Stephen Rothwell > Closes: https://lore.kernel.org/lkml/20251117202214.4f710f02@canb.auug.org.au/ > Reported-by: Nathan Chancellor > Closes: https://lore.kernel.org/lkml/20251121215819.GA1374726@ax162/ > Fixes: 3572e2edc7b6 ("locking/mutex: Redo __mutex_init()") > Signed-off-by: Boqun Feng > --- > kernel/locking/mutex-debug.c | 10 +--------- > kernel/locking/mutex.c | 8 +++++++- > kernel/locking/mutex.h | 5 ++--- > 3 files changed, 10 insertions(+), 13 deletions(-) > > diff --git a/kernel/locking/mutex-debug.c b/kernel/locking/mutex-debug.c > index 949103fd8e9b..2c6b02d4699b 100644 > --- a/kernel/locking/mutex-debug.c > +++ b/kernel/locking/mutex-debug.c > @@ -78,16 +78,8 @@ void debug_mutex_unlock(struct mutex *lock) > } > } > > -void debug_mutex_init(struct mutex *lock, const char *name, > - struct lock_class_key *key) > +void debug_mutex_init(struct mutex *lock) > { > -#ifdef CONFIG_DEBUG_LOCK_ALLOC > - /* > - * Make sure we are not reinitializing a held lock: > - */ > - debug_check_no_locks_freed((void *)lock, sizeof(*lock)); > - lockdep_init_map_wait(&lock->dep_map, name, key, 0, LD_WAIT_SLEEP); > -#endif > lock->magic = lock; > } > > diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c > index f3bb352a368d..2a1d165b3167 100644 > --- a/kernel/locking/mutex.c > +++ b/kernel/locking/mutex.c > @@ -51,6 +51,7 @@ static void __mutex_init_generic(struct mutex *lock) > #ifdef CONFIG_MUTEX_SPIN_ON_OWNER > osq_lock_init(&lock->osq); > #endif > + debug_mutex_init(lock); > } > > static inline struct task_struct *__owner_task(unsigned long owner) > @@ -173,7 +174,12 @@ static __always_inline bool __mutex_unlock_fast(struct mutex *lock) > void mutex_init_lockep(struct mutex *lock, const char *name, struct lock_class_key *key) > { > __mutex_init_generic(lock); > - debug_mutex_init(lock, name, key); > + > + /* > + * Make sure we are not reinitializing a held lock: > + */ > + debug_check_no_locks_freed((void *)lock, sizeof(*lock)); > + lockdep_init_map_wait(&lock->dep_map, name, key, 0, LD_WAIT_SLEEP); > } > EXPORT_SYMBOL(mutex_init_lockep); > #endif /* !CONFIG_DEBUG_LOCK_ALLOC */ > diff --git a/kernel/locking/mutex.h b/kernel/locking/mutex.h > index 2e8080a9bee3..9ad4da8cea00 100644 > --- a/kernel/locking/mutex.h > +++ b/kernel/locking/mutex.h > @@ -59,8 +59,7 @@ extern void debug_mutex_add_waiter(struct mutex *lock, > extern void debug_mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter, > struct task_struct *task); > extern void debug_mutex_unlock(struct mutex *lock); > -extern void debug_mutex_init(struct mutex *lock, const char *name, > - struct lock_class_key *key); > +extern void debug_mutex_init(struct mutex *lock); > #else /* CONFIG_DEBUG_MUTEXES */ > # define debug_mutex_lock_common(lock, waiter) do { } while (0) > # define debug_mutex_wake_waiter(lock, waiter) do { } while (0) > @@ -68,6 +67,6 @@ extern void debug_mutex_init(struct mutex *lock, const char *name, > # define debug_mutex_add_waiter(lock, waiter, ti) do { } while (0) > # define debug_mutex_remove_waiter(lock, waiter, ti) do { } while (0) > # define debug_mutex_unlock(lock) do { } while (0) > -# define debug_mutex_init(lock, name, key) do { } while (0) > +# define debug_mutex_init(lock) do { } while (0) > #endif /* !CONFIG_DEBUG_MUTEXES */ > #endif /* CONFIG_PREEMPT_RT */ Reviewed-by: Waiman Long