Commit 1ee41680572971e34d90d5f584daf33195ec6dcb
Committed by
Linus Torvalds
1 parent
626115cda9
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: Stefan Richter <stefanr@s5r6.in-berlin.de> Acked-by: Rusty Russell <rusty@rustcorp.com.au> Cc: Matthew Wilcox <matthew@wil.cx> Cc: Randy Dunlap <rdunlap@xenotime.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 5 additions and 2 deletions Side-by-side Diff
Documentation/DocBook/kernel-locking.tmpl
... | ... | @@ -1922,9 +1922,12 @@ |
1922 | 1922 | <function>mutex_lock()</function> |
1923 | 1923 | </para> |
1924 | 1924 | <para> |
1925 | - There is a <function>mutex_trylock()</function> which can be | |
1926 | - used inside interrupt context, as it will not sleep. | |
1925 | + There is a <function>mutex_trylock()</function> which does not | |
1926 | + sleep. Still, it must not be used inside interrupt context since | |
1927 | + its implementation is not safe for that. | |
1927 | 1928 | <function>mutex_unlock()</function> will also never sleep. |
1929 | + It cannot be used in interrupt context either since a mutex | |
1930 | + must be released by the same task that acquired it. | |
1928 | 1931 | </para> |
1929 | 1932 | </listitem> |
1930 | 1933 | </itemizedlist> |