2019-09-08 12:59:28

by Federico Vaga

[permalink] [raw]
Subject: [PATCH v3] doc:lock: remove reference to clever use of read-write lock

Remove the clever example about read-write lock because this type of
lock is not reccomended anymore (according to the very same document).
So there is no reason to teach cleaver things that people should not do.

Signed-off-by: Federico Vaga <[email protected]>
---
Documentation/locking/spinlocks.rst | 12 ------------
1 file changed, 12 deletions(-)

diff --git a/Documentation/locking/spinlocks.rst b/Documentation/locking/spinlocks.rst
index e93ec6645238..66e3792f8a36 100644
--- a/Documentation/locking/spinlocks.rst
+++ b/Documentation/locking/spinlocks.rst
@@ -139,18 +139,6 @@ on other CPU's, because an interrupt on another CPU doesn't interrupt the
CPU that holds the lock, so the lock-holder can continue and eventually
releases the lock).

-Note that you can be clever with read-write locks and interrupts. For
-example, if you know that the interrupt only ever gets a read-lock, then
-you can use a non-irq version of read locks everywhere - because they
-don't block on each other (and thus there is no dead-lock wrt interrupts.
-But when you do the write-lock, you have to use the irq-safe version.
-
-For an example of being clever with rw-locks, see the "waitqueue_lock"
-handling in kernel/sched/core.c - nothing ever _changes_ a wait-queue from
-within an interrupt, they only read the queue in order to know whom to
-wake up. So read-locks are safe (which is good: they are very common
-indeed), while write-locks need to protect themselves against interrupts.
-
Linus

----
--
2.21.0


2019-09-12 17:32:20

by Will Deacon

[permalink] [raw]
Subject: Re: [PATCH v3] doc:lock: remove reference to clever use of read-write lock

On Sun, Sep 08, 2019 at 08:29:01AM +0200, Federico Vaga wrote:
> Remove the clever example about read-write lock because this type of
> lock is not reccomended anymore (according to the very same document).

reccomended => recommended

> So there is no reason to teach cleaver things that people should not do.

cleaver => clever

> Signed-off-by: Federico Vaga <[email protected]>
> ---
> Documentation/locking/spinlocks.rst | 12 ------------
> 1 file changed, 12 deletions(-)
>
> diff --git a/Documentation/locking/spinlocks.rst b/Documentation/locking/spinlocks.rst
> index e93ec6645238..66e3792f8a36 100644
> --- a/Documentation/locking/spinlocks.rst
> +++ b/Documentation/locking/spinlocks.rst
> @@ -139,18 +139,6 @@ on other CPU's, because an interrupt on another CPU doesn't interrupt the
> CPU that holds the lock, so the lock-holder can continue and eventually
> releases the lock).
>
> -Note that you can be clever with read-write locks and interrupts. For
> -example, if you know that the interrupt only ever gets a read-lock, then
> -you can use a non-irq version of read locks everywhere - because they
> -don't block on each other (and thus there is no dead-lock wrt interrupts.
> -But when you do the write-lock, you have to use the irq-safe version.
> -
> -For an example of being clever with rw-locks, see the "waitqueue_lock"
> -handling in kernel/sched/core.c - nothing ever _changes_ a wait-queue from
> -within an interrupt, they only read the queue in order to know whom to
> -wake up. So read-locks are safe (which is good: they are very common
> -indeed), while write-locks need to protect themselves against interrupts.
> -

With the typos fixed in the commit message:

Acked-by: Will Deacon <[email protected]>

Will

2019-09-14 15:27:47

by Jonathan Corbet

[permalink] [raw]
Subject: Re: [PATCH v3] doc:lock: remove reference to clever use of read-write lock

On Thu, 12 Sep 2019 14:32:27 +0100
Will Deacon <[email protected]> wrote:

> > So there is no reason to teach cleaver things that people should not do.
>
> cleaver => clever

I dunno...personally I'm also opposed to teaching people tricks with
cleavers too, at least in the kernel-development context. Our flame wars
are bad enough as it is...:)

Applied with the typo tweaks, thanks.

jon