Skip to content

Commit 438e228

Browse files
committed
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 <[email protected]> Tested-by: Randy Dunlap <[email protected]> Cc: Peter Zijlstra <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent e9ba21f commit 438e228

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
@@ -544,12 +544,12 @@ int __sched mutex_lock_interruptible_nested(struct mutex *lock,
544544
}
545545
EXPORT_SYMBOL_GPL(mutex_lock_interruptible_nested);
546546

547-
int __sched mutex_lock_killable_nested(struct mutex *lock,
548-
unsigned int subclass)
547+
int __sched _mutex_lock_killable(struct mutex *lock, unsigned int subclass,
548+
struct lockdep_map *nest_lock)
549549
{
550-
return __mutex_lock_common(lock, TASK_KILLABLE, subclass, NULL, _RET_IP_);
550+
return __mutex_lock_common(lock, TASK_KILLABLE, subclass, nest_lock, _RET_IP_);
551551
}
552-
EXPORT_SYMBOL_GPL(mutex_lock_killable_nested);
552+
EXPORT_SYMBOL_GPL(_mutex_lock_killable);
553553

554554
void __sched mutex_lock_io_nested(struct mutex *lock, unsigned int subclass)
555555
{
@@ -563,6 +563,21 @@ void __sched mutex_lock_io_nested(struct mutex *lock, unsigned int subclass)
563563
}
564564
EXPORT_SYMBOL_GPL(mutex_lock_io_nested);
565565

566+
int __sched _mutex_trylock_nest_lock(struct mutex *lock,
567+
struct lockdep_map *nest_lock)
568+
{
569+
int ret;
570+
571+
if (IS_ENABLED(CONFIG_DEBUG_RT_MUTEXES) && WARN_ON_ONCE(!in_task()))
572+
return 0;
573+
574+
ret = __rt_mutex_trylock(&lock->rtmutex);
575+
if (ret)
576+
mutex_acquire_nest(&lock->dep_map, 0, 1, nest_lock, _RET_IP_);
577+
578+
return ret;
579+
}
580+
EXPORT_SYMBOL_GPL(_mutex_trylock_nest_lock);
566581
#else /* CONFIG_DEBUG_LOCK_ALLOC */
567582

568583
void __sched mutex_lock(struct mutex *lock)
@@ -591,22 +606,16 @@ void __sched mutex_lock_io(struct mutex *lock)
591606
io_schedule_finish(token);
592607
}
593608
EXPORT_SYMBOL(mutex_lock_io);
594-
#endif /* !CONFIG_DEBUG_LOCK_ALLOC */
595609

596610
int __sched mutex_trylock(struct mutex *lock)
597611
{
598-
int ret;
599-
600612
if (IS_ENABLED(CONFIG_DEBUG_RT_MUTEXES) && WARN_ON_ONCE(!in_task()))
601613
return 0;
602614

603-
ret = __rt_mutex_trylock(&lock->rtmutex);
604-
if (ret)
605-
mutex_acquire(&lock->dep_map, 0, 1, _RET_IP_);
606-
607-
return ret;
615+
return __rt_mutex_trylock(&lock->rtmutex);
608616
}
609617
EXPORT_SYMBOL(mutex_trylock);
618+
#endif /* !CONFIG_DEBUG_LOCK_ALLOC */
610619

611620
void __sched mutex_unlock(struct mutex *lock)
612621
{

0 commit comments

Comments
 (0)