locking/mutex: Misc fixlets
cover locking/mutex: Misc fixlets
Found while eyeballing recent changes to mutex.c. The first two are fixes for 51d7a054521d ("locking/mutex: Redo __mutex_init() to reduce generated code size").
Thanks!
Davidlohr Bueso (3):
locking/mutex: Rename mutex_init_lockep() locking/mutex: Fix wrong comment for CONFIG_DEBUG_LOCK_ALLOC locking/mutex: Add killable flavor to guard definitions
include/linux/mutex.h | 9 ++++++--- kernel/locking/mutex.c | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-)
--
2.39.5
PATCH 1/3 locking/mutex: Rename mutex_init_lockep()
Typo, this wants to be _lockdep().
--- include/linux/mutex.h | 4 ++-- kernel/locking/mutex.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
include/linux/mutex.h +2 -2
@@ -87,12 +87,12 @@ do { \ struct mutex mutexname = __MUTEX_INITIALIZER(mutexname)#ifdef CONFIG_DEBUG_LOCK_ALLOC -void mutex_init_lockep (struct mutex *lock,const char *name,struct lock_class_key *key); +void mutex_init_lockdep (struct mutex *lock,const char *name,struct lock_class_key *key);static inline void __mutex_init (struct mutex *lock,const char *name,struct lock_class_key *key) { -mutex_init_lockep (lock, name, key); +mutex_init_lockdep (lock, name, key); }#else extern void mutex_init_generic (struct mutex *lock);
kernel/locking/mutex.c +2 -2
@@ -171,7 +171,7 @@ static __always_inline bool __mutex_unlock_fast(struct mutex *lock)#else /* !CONFIG_DEBUG_LOCK_ALLOC */ -void mutex_init_lockep (struct mutex *lock,const char *name,struct lock_class_key *key) +void mutex_init_lockdep (struct mutex *lock,const char *name,struct lock_class_key *key) {__mutex_init_generic (lock);
@@ -181,7 +181,7 @@ void mutex_init_lockep(struct mutex *lock, const char *name, struct lock_class_kdebug_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); +EXPORT_SYMBOL (mutex_init_lockdep);#endif /* !CONFIG_DEBUG_LOCK_ALLOC */ static inline void __mutex_set_flag (struct mutex *lock,unsigned long flag)
Signature · 1 line
2.39.5
Peter Zijlstra
maintainerRe: [PATCH 1/3] locking/mutex: Rename mutex_init_lockep()
Quoted 1 line · Davidlohr Bueso
Typo, this wants to be
_lockdep().
Lol... I *never* saw that until just now.
Reading is hard I suppose :-)
Re: [PATCH 1/3] locking/mutex: Rename mutex_init_lockep()
In reply to Davidlohr BuesoQuoted 42 lines · Davidlohr Bueso
Typo, this wants to be
_lockdep().Fixes 51d7a054521d ("locking/mutex: Redo __mutex_init() to reduce generated code size")Signed-off-by Davidlohr Bueso <[email protected]>--- include/linux/mutex.h | 4 ++-- kernel/locking/mutex.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)include/linux/mutex.h +2
-2@@ -87,12 +87,12 @@ do { \ struct mutex mutexname = __MUTEX_INITIALIZER(mutexname)#ifdef CONFIG_DEBUG_LOCK_ALLOC -void mutex_init_lockep (struct mutex *lock,const char *name,struct lock_class_key *key); +void mutex_init_lockdep (struct mutex *lock,const char *name,struct lock_class_key *key);static inline void __mutex_init (struct mutex *lock,const char *name,struct lock_class_key *key) { -mutex_init_lockep (lock, name, key); +mutex_init_lockdep (lock, name, key); }#else extern void mutex_init_generic (struct mutex *lock);kernel/locking/mutex.c +1
-1@@ -171,7 +171,7 @@ static __always_inline bool __mutex_unlock_fast(struct mutex *lock)#else /* !CONFIG_DEBUG_LOCK_ALLOC */ -void mutex_init_lockep (struct mutex *lock,const char *name,struct lock_class_key *key) +void mutex_init_lockdep (struct mutex *lock,const char *name,struct lock_class_key *key) {__mutex_init_generic (lock);
kernel/locking/mutex.c void mutex_init_lockep(struct mutex *lock, const char *name, struct lock_class_k · line 187
Quoted 8 lines
kernel/locking/mutex.c +1
-1@@ -181,7 +181,7 @@ void mutex_init_lockep(struct mutex *lock, const char *name, struct lock_class_kdebug_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); +EXPORT_SYMBOL (mutex_init_lockdep);#endif /* !CONFIG_DEBUG_LOCK_ALLOC */ static inline void __mutex_set_flag (struct mutex *lock,unsigned long flag)
Yes, this typo can be easy to miss.
[tip: locking/core] locking/mutex: Rename mutex_init_lockep()
In reply to Davidlohr BuesoThe following commit has been merged into the locking/core branch of tip:
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 8b65eb52d93e4e496bd26e6867152344554eb39e Gitweb: https://git.kernel.org/tip/8b65eb52d93e4e496bd26e6867152344554eb39e Author: Davidlohr Bueso <[email protected]> AuthorDate: Tue, 17 Feb 2026 11:15:10 -08:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Mon, 23 Feb 2026 11:19:15 +01:00
locking/mutex: Rename mutex_init_lockep()
Typo, this wants to be _lockdep().
--- include/linux/mutex.h | 4 ++-- kernel/locking/mutex.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
include/linux/mutex.h +2 -2
@@ -87,12 +87,12 @@ do { \ struct mutex mutexname = __MUTEX_INITIALIZER(mutexname)#ifdef CONFIG_DEBUG_LOCK_ALLOC -void mutex_init_lockep (struct mutex *lock,const char *name,struct lock_class_key *key); +void mutex_init_lockdep (struct mutex *lock,const char *name,struct lock_class_key *key);static inline void __mutex_init (struct mutex *lock,const char *name,struct lock_class_key *key) { -mutex_init_lockep (lock, name, key); +mutex_init_lockdep (lock, name, key); }#else extern void mutex_init_generic (struct mutex *lock);
kernel/locking/mutex.c +2 -2
@@ -171,7 +171,7 @@ static __always_inline bool __mutex_unlock_fast(struct mutex *lock)#else /* !CONFIG_DEBUG_LOCK_ALLOC */ -void mutex_init_lockep (struct mutex *lock,const char *name,struct lock_class_key *key) +void mutex_init_lockdep (struct mutex *lock,const char *name,struct lock_class_key *key) {__mutex_init_generic (lock);
@@ -181,7 +181,7 @@ void mutex_init_lockep(struct mutex *lock, const char *name, struct lock_class_kdebug_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); +EXPORT_SYMBOL (mutex_init_lockdep);#endif /* !CONFIG_DEBUG_LOCK_ALLOC */ static inline void __mutex_set_flag (struct mutex *lock,unsigned long flag)
PATCH 2/3 locking/mutex: Fix wrong comment for CONFIG_DEBUG_LOCK_ALLOC
In reply to Davidlohr Bueso... that endif block should be CONFIG_DEBUG_LOCK_ALLOC, not CONFIG_LOCKDEP.
--- include/linux/mutex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mutex.h +1 -1
@@ -146,7 +146,7 @@ static inline void __mutex_init(struct mutex *lock, const char *name, {mutex_rt_init_generic (lock); } -#endif /* !CONFIG_LOCKDEP */ +#endif /* !CONFIG_DEBUG_LOCK_ALLOC */ #endif /* CONFIG_PREEMPT_RT */ #ifdef CONFIG_DEBUG_MUTEXES
Signature · 1 line
2.39.5
Re: [PATCH 2/3] locking/mutex: Fix wrong comment for CONFIG_DEBUG_LOCK_ALLOC
Quoted 14 lines · Davidlohr Bueso
... that endif block should be
CONFIG_DEBUG_LOCK_ALLOC, notCONFIG_LOCKDEP.Fixes 51d7a054521d ("locking/mutex: Redo __mutex_init() to reduce generated code size")Signed-off-by Davidlohr Bueso <[email protected]>--- include/linux/mutex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/mutex.h +0
-0
include/linux/mutex.h static inline void __mutex_init(struct mutex *lock, const char *name, · line 152
Quoted 8 lines
include/linux/mutex.h +1
-1@@ -146,7 +146,7 @@ static inline void __mutex_init(struct mutex *lock, const char *name, {mutex_rt_init_generic (lock); } -#endif /* !CONFIG_LOCKDEP */ +#endif /* !CONFIG_DEBUG_LOCK_ALLOC */ #endif /* CONFIG_PREEMPT_RT */ #ifdef CONFIG_DEBUG_MUTEXES
[tip: locking/core] locking/mutex: Fix wrong comment for CONFIG_DEBUG_LOCK_ALLOC
In reply to Davidlohr BuesoThe following commit has been merged into the locking/core branch of tip:
The following commit has been merged into the locking/core branch of tip:
Commit-ID: babcde3be8c9148aa60a14b17831e8f249854963 Gitweb: https://git.kernel.org/tip/babcde3be8c9148aa60a14b17831e8f249854963 Author: Davidlohr Bueso <[email protected]> AuthorDate: Tue, 17 Feb 2026 11:15:11 -08:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Mon, 23 Feb 2026 11:19:16 +01:00
locking/mutex: Fix wrong comment for CONFIG_DEBUG_LOCK_ALLOC
... that endif block should be CONFIG_DEBUG_LOCK_ALLOC, not CONFIG_LOCKDEP.
--- include/linux/mutex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mutex.h +1 -1
@@ -146,7 +146,7 @@ static inline void __mutex_init(struct mutex *lock, const char *name, {mutex_rt_init_generic (lock); } -#endif /* !CONFIG_LOCKDEP */ +#endif /* !CONFIG_DEBUG_LOCK_ALLOC */ #endif /* CONFIG_PREEMPT_RT */ #ifdef CONFIG_DEBUG_MUTEXES
PATCH 3/3 locking/mutex: Add killable flavor to guard definitions
In reply to Davidlohr BuesoThe mutex guard family defines _try and _intr variants but is missing the killable one.
--- include/linux/mutex.h | 3 +++ 1 file changed, 3 insertions(+)
include/linux/mutex.h +3 -0
@@ -253,6 +253,7 @@ extern int atomic_dec_and_mutex_lock(atomic_t *cnt, struct mutex *lock) __cond_a DEFINE_LOCK_GUARD_1(mutex, struct mutex, mutex_lock(_T->lock), mutex_unlock(_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 == 0) +DEFINE_LOCK_GUARD_1_COND(mutex, _kill, mutex_lock_killable(_T->lock), _RET == 0) DEFINE_LOCK_GUARD_1(mutex_init, struct mutex, mutex_init(_T->lock), /* */) DECLARE_LOCK_GUARD_1_ATTRS(mutex, __acquires(_T), __releases(*(struct 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_intr, _T) +DECLARE_LOCK_GUARD_1_ATTRS(mutex_kill, __acquires(_T), __releases(*(struct mutex **)_T)) +#define class_mutex_kill_constructor (_T) WITH_LOCK_GUARD_1_ATTRS(mutex_kill, _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_init, _T)
Signature · 1 line
2.39.5
[tip: locking/core] locking/mutex: Add killable flavor to guard definitions
The following commit has been merged into the locking/core branch of tip:
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 50214dc4382055352fb1d7b9779550dabf5059e5 Gitweb: https://git.kernel.org/tip/50214dc4382055352fb1d7b9779550dabf5059e5 Author: Davidlohr Bueso <[email protected]> AuthorDate: Tue, 17 Feb 2026 11:15:12 -08:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Mon, 23 Feb 2026 11:19:16 +01:00
locking/mutex: Add killable flavor to guard definitions
The mutex guard family defines _try and _intr variants but is missing the killable one.
--- include/linux/mutex.h | 3 +++ 1 file changed, 3 insertions(+)
include/linux/mutex.h +3 -0
@@ -253,6 +253,7 @@ extern int atomic_dec_and_mutex_lock(atomic_t *cnt, struct mutex *lock) __cond_a DEFINE_LOCK_GUARD_1(mutex, struct mutex, mutex_lock(_T->lock), mutex_unlock(_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 == 0) +DEFINE_LOCK_GUARD_1_COND(mutex, _kill, mutex_lock_killable(_T->lock), _RET == 0) DEFINE_LOCK_GUARD_1(mutex_init, struct mutex, mutex_init(_T->lock), /* */) DECLARE_LOCK_GUARD_1_ATTRS(mutex, __acquires(_T), __releases(*(struct 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_intr, _T) +DECLARE_LOCK_GUARD_1_ATTRS(mutex_kill, __acquires(_T), __releases(*(struct mutex **)_T)) +#define class_mutex_kill_constructor (_T) WITH_LOCK_GUARD_1_ATTRS(mutex_kill, _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_init, _T)