kernel/locking/mutex-debug.c | 10 +--------- kernel/locking/mutex.c | 8 +++++++- kernel/locking/mutex.h | 5 ++--- 3 files changed, 10 insertions(+), 13 deletions(-)
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 <sfr@canb.auug.org.au>
Closes: https://lore.kernel.org/lkml/20251117202214.4f710f02@canb.auug.org.au/
Reported-by: Nathan Chancellor <nathan@kernel.org>
Closes: https://lore.kernel.org/lkml/20251121215819.GA1374726@ax162/
Fixes: 3572e2edc7b6 ("locking/mutex: Redo __mutex_init()")
Reviewed-by: Waiman Long <longman@redhat.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
Peter,
Feel free to fold it into commit 3572e2edc7b6 ("locking/mutex: Redo
__mutex_init()"), just resend it properly so it won't fall off your
radar ;-)
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 */
--
2.50.1 (Apple Git-155)
On Tue, Nov 25, 2025 at 06:54:21AM -0800, Boqun Feng wrote:
> 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 <sfr@canb.auug.org.au>
> Closes: https://lore.kernel.org/lkml/20251117202214.4f710f02@canb.auug.org.au/
> Reported-by: Nathan Chancellor <nathan@kernel.org>
> Closes: https://lore.kernel.org/lkml/20251121215819.GA1374726@ax162/
> Fixes: 3572e2edc7b6 ("locking/mutex: Redo __mutex_init()")
> Reviewed-by: Waiman Long <longman@redhat.com>
> Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
> ---
> Peter,
>
> Feel free to fold it into commit 3572e2edc7b6 ("locking/mutex: Redo
> __mutex_init()"), just resend it properly so it won't fall off your
> radar ;-)
Clearly I've been suffering too much mail again :/ Let me go frob stuff.
Hi all,
On Tue, 25 Nov 2025 06:54:21 -0800 Boqun Feng <boqun.feng@gmail.com> wrote:
>
> 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 <sfr@canb.auug.org.au>
> Closes: https://lore.kernel.org/lkml/20251117202214.4f710f02@canb.auug.org.au/
> Reported-by: Nathan Chancellor <nathan@kernel.org>
> Closes: https://lore.kernel.org/lkml/20251121215819.GA1374726@ax162/
> Fixes: 3572e2edc7b6 ("locking/mutex: Redo __mutex_init()")
> Reviewed-by: Waiman Long <longman@redhat.com>
> Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
> ---
> Peter,
>
> Feel free to fold it into commit 3572e2edc7b6 ("locking/mutex: Redo
> __mutex_init()"), just resend it properly so it won't fall off your
> radar ;-)
>
> kernel/locking/mutex-debug.c | 10 +---------
> kernel/locking/mutex.c | 8 +++++++-
> kernel/locking/mutex.h | 5 ++---
> 3 files changed, 10 insertions(+), 13 deletions(-)
Any chance if this being applied? I am still seeing the boot warning.
--
Cheers,
Stephen Rothwell
On Fri, Nov 28, 2025 at 04:08:15PM +1100, Stephen Rothwell wrote:
> Hi all,
>
> On Tue, 25 Nov 2025 06:54:21 -0800 Boqun Feng <boqun.feng@gmail.com> wrote:
> >
> > 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 <sfr@canb.auug.org.au>
> > Closes: https://lore.kernel.org/lkml/20251117202214.4f710f02@canb.auug.org.au/
> > Reported-by: Nathan Chancellor <nathan@kernel.org>
> > Closes: https://lore.kernel.org/lkml/20251121215819.GA1374726@ax162/
> > Fixes: 3572e2edc7b6 ("locking/mutex: Redo __mutex_init()")
> > Reviewed-by: Waiman Long <longman@redhat.com>
> > Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
> > ---
> > Peter,
> >
> > Feel free to fold it into commit 3572e2edc7b6 ("locking/mutex: Redo
> > __mutex_init()"), just resend it properly so it won't fall off your
> > radar ;-)
> >
> > kernel/locking/mutex-debug.c | 10 +---------
> > kernel/locking/mutex.c | 8 +++++++-
> > kernel/locking/mutex.h | 5 ++---
> > 3 files changed, 10 insertions(+), 13 deletions(-)
>
> Any chance if this being applied? I am still seeing the boot warning.
Should be sorted now, sorry for the delay!
Hi Peter, On Fri, 28 Nov 2025 10:55:52 +0100 Peter Zijlstra <peterz@infradead.org> wrote: > > Should be sorted now, sorry for the delay! Excellent, thanks. -- Cheers, Stephen Rothwell
© 2016 - 2025 Red Hat, Inc.