* [PATCH]locking:mutex Print warning if trylock in irq context
@ 2017-12-22 20:45 gaurav jindal
2017-12-22 20:51 ` Peter Zijlstra
0 siblings, 1 reply; 3+ messages in thread
From: gaurav jindal @ 2017-12-22 20:45 UTC (permalink / raw)
To: peterz, mingo; +Cc: linux-kernel
Since mutex_trylock must not be called from interrupt context, a robustness
can be added to this function by throwing a warning if it is called in
interrupt context.
It would help to make debugging easier in case of undesired calling of this
function.
Signed-off-by: gaurav jindal<gauravjindal1104@gmail.com>
---
diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
index 858a075..fe1cace 100644
--- a/kernel/locking/mutex.c
+++ b/kernel/locking/mutex.c
@@ -1176,7 +1176,10 @@ void __sched mutex_lock_io(struct mutex *lock)
*/
int __sched mutex_trylock(struct mutex *lock)
{
- bool locked = __mutex_trylock(lock);
+ bool locked;
+
+ WARN_ONCE(in_irq(), "%s wrongly called in irq context", __func__);
+ locked = __mutex_trylock(lock);
if (locked)
mutex_acquire(&lock->dep_map, 0, 1, _RET_IP_);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH]locking:mutex Print warning if trylock in irq context
2017-12-22 20:45 [PATCH]locking:mutex Print warning if trylock in irq context gaurav jindal
@ 2017-12-22 20:51 ` Peter Zijlstra
2017-12-22 21:08 ` gaurav jindal
0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2017-12-22 20:51 UTC (permalink / raw)
To: gaurav jindal; +Cc: mingo, linux-kernel
On Sat, Dec 23, 2017 at 02:15:19AM +0530, gaurav jindal wrote:
> Since mutex_trylock must not be called from interrupt context, a robustness
> can be added to this function by throwing a warning if it is called in
> interrupt context.
> It would help to make debugging easier in case of undesired calling of this
> function.
Or you run with lockdep enabled and not make this thing slower for
everybody.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH]locking:mutex Print warning if trylock in irq context
2017-12-22 20:51 ` Peter Zijlstra
@ 2017-12-22 21:08 ` gaurav jindal
0 siblings, 0 replies; 3+ messages in thread
From: gaurav jindal @ 2017-12-22 21:08 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: mingo, linux-kernel
On Fri, Dec 22, 2017 at 09:51:09PM +0100, Peter Zijlstra wrote:
> On Sat, Dec 23, 2017 at 02:15:19AM +0530, gaurav jindal wrote:
> > Since mutex_trylock must not be called from interrupt context, a robustness
> > can be added to this function by throwing a warning if it is called in
> > interrupt context.
> > It would help to make debugging easier in case of undesired calling of this
> > function.
>
> Or you run with lockdep enabled and not make this thing slower for
> everybody.
Got the point. thanks for making it clear and consideration.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-22 21:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-22 20:45 [PATCH]locking:mutex Print warning if trylock in irq context gaurav jindal
2017-12-22 20:51 ` Peter Zijlstra
2017-12-22 21:08 ` gaurav jindal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®