linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Documentation: preempt-locking: Use better example
@ 2018-10-08 13:15 Andrew Murray
  2018-10-12 17:36 ` Jonathan Corbet
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Murray @ 2018-10-08 13:15 UTC (permalink / raw)
  To: Robert Love, Jonathan Corbet; +Cc: kpreempt-tech, linux-doc, linux-kernel

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>
---
 Documentation/preempt-locking.txt | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/Documentation/preempt-locking.txt b/Documentation/preempt-locking.txt
index c945062..509f5a4 100644
--- a/Documentation/preempt-locking.txt
+++ b/Documentation/preempt-locking.txt
@@ -3,7 +3,6 @@ Proper Locking Under a Preemptible Kernel: Keeping Kernel Code Preempt-Safe
 ===========================================================================
 
 :Author: Robert Love <rml@tech9.net>
-:Last Updated: 28 Aug 2002
 
 
 Introduction
@@ -92,11 +91,12 @@ any locks or interrupts are disabled, since preemption is implicitly disabled
 in those cases.
 
 But keep in mind that 'irqs disabled' is a fundamentally unsafe way of
-disabling preemption - any spin_unlock() decreasing the preemption count
-to 0 might trigger a reschedule. A simple printk() might trigger a reschedule.
-So use this implicit preemption-disabling property only if you know that the
-affected codepath does not do any of this. Best policy is to use this only for
-small, atomic code that you wrote and which calls no complex functions.
+disabling preemption - any cond_resched() or cond_resched_lock() might trigger
+a reschedule if the preempt count is 0. A simple printk() might trigger a
+reschedule. So use this implicit preemption-disabling property only if you
+know that the affected codepath does not do any of this. Best policy is to use
+this only for small, atomic code that you wrote and which calls no complex
+functions.
 
 Example::
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Documentation: preempt-locking: Use better example
  2018-10-08 13:15 [PATCH] Documentation: preempt-locking: Use better example Andrew Murray
@ 2018-10-12 17:36 ` Jonathan Corbet
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Corbet @ 2018-10-12 17:36 UTC (permalink / raw)
  To: Andrew Murray; +Cc: Robert Love, kpreempt-tech, linux-doc, linux-kernel

On Mon,  8 Oct 2018 14:15:15 +0100
Andrew Murray <andrew.murray@arm.com> wrote:

> 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>

I've applied this, but that document is ... old.  It sure would be nice if
somebody found the energy to write a proper locking document for current
kernels...:)

Thanks,

jon

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-12 17:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-08 13:15 [PATCH] Documentation: preempt-locking: Use better example Andrew Murray
2018-10-12 17:36 ` Jonathan Corbet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).