提交 1ee41680 编写于 作者: S Stefan Richter 提交者: Linus Torvalds

Documentation: kernel-locking: mutex_trylock cannot be used in interrupt context

Chapter 6 is right about mutex_trylock, but chapter 10 wasn't.  This error
was introduced during semaphore-to-mutex conversion of the Unreliable
guide.  :-)

If user context which performs mutex_lock() or mutex_trylock() is
preempted by interrupt context which performs mutex_trylock() on the same
mutex instance, a deadlock occurs.  This is because these functions do not
disable local IRQs when they operate on mutex->wait_lock.
Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
Acked-by: NRusty Russell <rusty@rustcorp.com.au>
Cc: Matthew Wilcox <matthew@wil.cx>
Cc: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 626115cd
...@@ -1922,9 +1922,12 @@ machines due to caching. ...@@ -1922,9 +1922,12 @@ machines due to caching.
<function>mutex_lock()</function> <function>mutex_lock()</function>
</para> </para>
<para> <para>
There is a <function>mutex_trylock()</function> which can be There is a <function>mutex_trylock()</function> which does not
used inside interrupt context, as it will not sleep. sleep. Still, it must not be used inside interrupt context since
its implementation is not safe for that.
<function>mutex_unlock()</function> will also never sleep. <function>mutex_unlock()</function> will also never sleep.
It cannot be used in interrupt context either since a mutex
must be released by the same task that acquired it.
</para> </para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册