From: gaurav jindal <gauravjindal1104@gmail.com>
To: peterz@infradead.org, mingo@redhat.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH]locking:mutex Print warning if trylock in irq context
Date: Sat, 23 Dec 2017 02:15:19 +0530 [thread overview]
Message-ID: <20171222204519.GA12047@gaurav.jindal> (raw)
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_);
next reply other threads:[~2017-12-22 20:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-22 20:45 gaurav jindal [this message]
2017-12-22 20:51 ` Peter Zijlstra
2017-12-22 21:08 ` gaurav jindal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171222204519.GA12047@gaurav.jindal \
--to=gauravjindal1104@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®