Documentation: kernel-locking: mutex_trylock cannot be used in interrupt context
authorStefan Richter <[email protected]>
Thu, 19 Aug 2010 21:13:43 +0000 (14:13 -0700)
committerLinus Torvalds <[email protected]>
Fri, 20 Aug 2010 16:34:56 +0000 (09:34 -0700)
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: Stefan Richter <[email protected]>
Acked-by: Rusty Russell <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Randy Dunlap <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Documentation/DocBook/kernel-locking.tmpl

index 084f6ad7b7a0a4729b85aea3cc5c3e6eb6557689..0b1a3f97f285361a4075c8e267d42b2053747d9a 100644 (file)
@@ -1922,9 +1922,12 @@ machines due to caching.
       <function>mutex_lock()</function>
       </para>
       <para>
-       There is a <function>mutex_trylock()</function> which can be
-       used inside interrupt context, as it will not sleep.
+       There is a <function>mutex_trylock()</function> which does not
+       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.
+       It cannot be used in interrupt context either since a mutex
+       must be released by the same task that acquired it.
       </para>
      </listitem>
     </itemizedlist>