linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RT] locking/rtmutex: do lockdep before actual locking in rt_spin_lock()
@ 2017-10-11 16:16 Sebastian Andrzej Siewior
  2017-10-11 16:20 ` Peter Zijlstra
  2017-10-11 16:48 ` Steven Rostedt
  0 siblings, 2 replies; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2017-10-11 16:16 UTC (permalink / raw)
  To: linux-rt-users; +Cc: linux-kernel, tglx, Peter Zijlstra, Steven Rostedt

rt_spin_lock() should first do the lock annotation via lockdep and then
do the actual locking. That way we learn about the deadlock from lockdep
before it happens.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 kernel/locking/rtmutex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 79f49d73e4d0..639cfdaae72f 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -1153,8 +1153,8 @@ void __sched rt_spin_lock_slowunlock(struct rt_mutex *lock)
 void __lockfunc rt_spin_lock(spinlock_t *lock)
 {
 	migrate_disable();
-	rt_spin_lock_fastlock(&lock->lock, rt_spin_lock_slowlock);
 	spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
+	rt_spin_lock_fastlock(&lock->lock, rt_spin_lock_slowlock);
 }
 EXPORT_SYMBOL(rt_spin_lock);
 
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH RT] locking/rtmutex: do lockdep before actual locking in rt_spin_lock()
  2017-10-11 16:16 [PATCH RT] locking/rtmutex: do lockdep before actual locking in rt_spin_lock() Sebastian Andrzej Siewior
@ 2017-10-11 16:20 ` Peter Zijlstra
  2017-10-11 16:48 ` Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2017-10-11 16:20 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-rt-users, linux-kernel, tglx, Steven Rostedt

On Wed, Oct 11, 2017 at 06:16:46PM +0200, Sebastian Andrzej Siewior wrote:
> rt_spin_lock() should first do the lock annotation via lockdep and then
> do the actual locking. That way we learn about the deadlock from lockdep
> before it happens.

Yep, that's the right order.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH RT] locking/rtmutex: do lockdep before actual locking in rt_spin_lock()
  2017-10-11 16:16 [PATCH RT] locking/rtmutex: do lockdep before actual locking in rt_spin_lock() Sebastian Andrzej Siewior
  2017-10-11 16:20 ` Peter Zijlstra
@ 2017-10-11 16:48 ` Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2017-10-11 16:48 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-rt-users, linux-kernel, tglx, Peter Zijlstra

On Wed, 11 Oct 2017 18:16:46 +0200
Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:

> rt_spin_lock() should first do the lock annotation via lockdep and then
> do the actual locking. That way we learn about the deadlock from lockdep
> before it happens.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  kernel/locking/rtmutex.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
> index 79f49d73e4d0..639cfdaae72f 100644
> --- a/kernel/locking/rtmutex.c
> +++ b/kernel/locking/rtmutex.c
> @@ -1153,8 +1153,8 @@ void __sched rt_spin_lock_slowunlock(struct rt_mutex *lock)
>  void __lockfunc rt_spin_lock(spinlock_t *lock)
>  {
>  	migrate_disable();
> -	rt_spin_lock_fastlock(&lock->lock, rt_spin_lock_slowlock);
>  	spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
> +	rt_spin_lock_fastlock(&lock->lock, rt_spin_lock_slowlock);
>  }
>  EXPORT_SYMBOL(rt_spin_lock);
>  

Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

-- Steve

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-10-11 16:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-11 16:16 [PATCH RT] locking/rtmutex: do lockdep before actual locking in rt_spin_lock() Sebastian Andrzej Siewior
2017-10-11 16:20 ` Peter Zijlstra
2017-10-11 16:48 ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).