Skip to content

Commit 36a76ce

Browse files
author
Maxim Levitsky
committed
rtmutex_api: provide correct extern functions
JIRA: https://issues.redhat.com/browse/RHEL-74410 commit 438e228 Author: Paolo Bonzini <pbonzini@redhat.com> Date: Fri May 30 03:45:13 2025 -0400 rtmutex_api: provide correct extern functions Commit fb49f07 ("locking/mutex: implement mutex_lock_killable_nest_lock") changed the set of functions that mutex.c defines when CONFIG_DEBUG_LOCK_ALLOC is set. - it removed the "extern" declaration of mutex_lock_killable_nested from include/linux/mutex.h, and replaced it with a macro since it could be treated as a special case of _mutex_lock_killable. It also removed a definition of the function in kernel/locking/mutex.c. - likewise, it replaced mutex_trylock() with the more generic mutex_trylock_nest_lock() and replaced mutex_trylock() with a macro. However, it left the old definitions in place in kernel/locking/rtmutex_api.c, which causes failures when building with CONFIG_RT_MUTEXES=y. Bring over the changes. Fixes: fb49f07 ("locking/mutex: implement mutex_lock_killable_nest_lock") Reported-by: Randy Dunlap <rdunlap@infradead.org> Tested-by: Randy Dunlap <rdunlap@infradead.org> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
1 parent 84c5935 commit 36a76ce

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

kernel/locking/rtmutex_api.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -538,12 +538,12 @@ int __sched mutex_lock_interruptible_nested(struct mutex *lock,
538538
}
539539
EXPORT_SYMBOL_GPL(mutex_lock_interruptible_nested);
540540

541-
int __sched mutex_lock_killable_nested(struct mutex *lock,
542-
unsigned int subclass)
541+
int __sched _mutex_lock_killable(struct mutex *lock, unsigned int subclass,
542+
struct lockdep_map *nest_lock)
543543
{
544-
return __mutex_lock_common(lock, TASK_KILLABLE, subclass, NULL, _RET_IP_);
544+
return __mutex_lock_common(lock, TASK_KILLABLE, subclass, nest_lock, _RET_IP_);
545545
}
546-
EXPORT_SYMBOL_GPL(mutex_lock_killable_nested);
546+
EXPORT_SYMBOL_GPL(_mutex_lock_killable);
547547

548548
void __sched mutex_lock_io_nested(struct mutex *lock, unsigned int subclass)
549549
{
@@ -557,6 +557,21 @@ void __sched mutex_lock_io_nested(struct mutex *lock, unsigned int subclass)
557557
}
558558
EXPORT_SYMBOL_GPL(mutex_lock_io_nested);
559559

560+
int __sched _mutex_trylock_nest_lock(struct mutex *lock,
561+
struct lockdep_map *nest_lock)
562+
{
563+
int ret;
564+
565+
if (IS_ENABLED(CONFIG_DEBUG_RT_MUTEXES) && WARN_ON_ONCE(!in_task()))
566+
return 0;
567+
568+
ret = __rt_mutex_trylock(&lock->rtmutex);
569+
if (ret)
570+
mutex_acquire_nest(&lock->dep_map, 0, 1, nest_lock, _RET_IP_);
571+
572+
return ret;
573+
}
574+
EXPORT_SYMBOL_GPL(_mutex_trylock_nest_lock);
560575
#else /* CONFIG_DEBUG_LOCK_ALLOC */
561576

562577
void __sched mutex_lock(struct mutex *lock)
@@ -585,22 +600,16 @@ void __sched mutex_lock_io(struct mutex *lock)
585600
io_schedule_finish(token);
586601
}
587602
EXPORT_SYMBOL(mutex_lock_io);
588-
#endif /* !CONFIG_DEBUG_LOCK_ALLOC */
589603

590604
int __sched mutex_trylock(struct mutex *lock)
591605
{
592-
int ret;
593-
594606
if (IS_ENABLED(CONFIG_DEBUG_RT_MUTEXES) && WARN_ON_ONCE(!in_task()))
595607
return 0;
596608

597-
ret = __rt_mutex_trylock(&lock->rtmutex);
598-
if (ret)
599-
mutex_acquire(&lock->dep_map, 0, 1, _RET_IP_);
600-
601-
return ret;
609+
return __rt_mutex_trylock(&lock->rtmutex);
602610
}
603611
EXPORT_SYMBOL(mutex_trylock);
612+
#endif /* !CONFIG_DEBUG_LOCK_ALLOC */
604613

605614
void __sched mutex_unlock(struct mutex *lock)
606615
{

0 commit comments

Comments
 (0)