Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Documentation: preempt-locking: Use better example

The existing wording implies that the use of spin_unlock whilst irqs are
disabled might trigger a reschedule. However the preemptible() test in
preempt_schedule will prevent a reschedule if irqs are disabled.

Lets improve the clarity of this wording to change the example from
spin_unlock to cond_resched() and cond_resched_lock() as these are
functions that will trigger a reschedule if the preempt count is 0 without
testing that irqs are disabled.

Also remove the 'Last Updated' line as this is not up to date and better
tracked via GIT.

Signed-off-by: Andrew Murray <andrew.murray@arm.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Andrew Murray and committed by
Jonathan Corbet
44280690 0c6c987f

+6 -6
+6 -6
Documentation/preempt-locking.txt
··· 3 3 =========================================================================== 4 4 5 5 :Author: Robert Love <rml@tech9.net> 6 - :Last Updated: 28 Aug 2002 7 6 8 7 9 8 Introduction ··· 91 92 in those cases. 92 93 93 94 But keep in mind that 'irqs disabled' is a fundamentally unsafe way of 94 - disabling preemption - any spin_unlock() decreasing the preemption count 95 - to 0 might trigger a reschedule. A simple printk() might trigger a reschedule. 96 - So use this implicit preemption-disabling property only if you know that the 97 - affected codepath does not do any of this. Best policy is to use this only for 98 - small, atomic code that you wrote and which calls no complex functions. 95 + disabling preemption - any cond_resched() or cond_resched_lock() might trigger 96 + a reschedule if the preempt count is 0. A simple printk() might trigger a 97 + reschedule. So use this implicit preemption-disabling property only if you 98 + know that the affected codepath does not do any of this. Best policy is to use 99 + this only for small, atomic code that you wrote and which calls no complex 100 + functions. 99 101 100 102 Example:: 101 103