All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] docs: lockdep-design: correct the notation for writer
@ 2021-05-21  6:29 Xiongwei Song
  2021-05-21  8:55 ` Boqun Feng
  2021-05-21 15:17 ` Waiman Long
  0 siblings, 2 replies; 9+ messages in thread
From: Xiongwei Song @ 2021-05-21  6:29 UTC (permalink / raw)
  To: peterz, mingo, will, longman, boqun.feng, corbet
  Cc: linux-kernel, linux-doc, Xiongwei Song

From: Xiongwei Song <sxwjean@gmail.com>

The block condition matrix is using 'E' as the writer noation here, so it
would be better to use 'E' as the reminder rather than 'W'.

Signed-off-by: Xiongwei Song <sxwjean@gmail.com>
---
 Documentation/locking/lockdep-design.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/locking/lockdep-design.rst b/Documentation/locking/lockdep-design.rst
index 9f3cfca..c3b923a 100644
--- a/Documentation/locking/lockdep-design.rst
+++ b/Documentation/locking/lockdep-design.rst
@@ -462,7 +462,7 @@ Block condition matrix, Y means the row blocks the column, and N means otherwise
 	| R | Y | Y | N |
 	+---+---+---+---+
 
-	(W: writers, r: non-recursive readers, R: recursive readers)
+	(E: writers, r: non-recursive readers, R: recursive readers)
 
 
 acquired recursively. Unlike non-recursive read locks, recursive read locks
-- 
2.7.4


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

* Re: [PATCH] docs: lockdep-design: correct the notation for writer
  2021-05-21  6:29 [PATCH] docs: lockdep-design: correct the notation for writer Xiongwei Song
@ 2021-05-21  8:55 ` Boqun Feng
  2021-05-21 11:05   ` Peter Zijlstra
  2021-05-21 15:17 ` Waiman Long
  1 sibling, 1 reply; 9+ messages in thread
From: Boqun Feng @ 2021-05-21  8:55 UTC (permalink / raw)
  To: Xiongwei Song
  Cc: peterz, mingo, will, longman, corbet, linux-kernel, linux-doc,
	Xiongwei Song

On Fri, May 21, 2021 at 02:29:54PM +0800, Xiongwei Song wrote:
> From: Xiongwei Song <sxwjean@gmail.com>
> 
> The block condition matrix is using 'E' as the writer noation here, so it
> would be better to use 'E' as the reminder rather than 'W'.
> 

Good catch!

> Signed-off-by: Xiongwei Song <sxwjean@gmail.com>

Reviewed-by: Boqun Feng <boqun.feng@gmail.com>

Regards,
Boqun

> ---
>  Documentation/locking/lockdep-design.rst | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Documentation/locking/lockdep-design.rst b/Documentation/locking/lockdep-design.rst
> index 9f3cfca..c3b923a 100644
> --- a/Documentation/locking/lockdep-design.rst
> +++ b/Documentation/locking/lockdep-design.rst
> @@ -462,7 +462,7 @@ Block condition matrix, Y means the row blocks the column, and N means otherwise
>  	| R | Y | Y | N |
>  	+---+---+---+---+
>  
> -	(W: writers, r: non-recursive readers, R: recursive readers)
> +	(E: writers, r: non-recursive readers, R: recursive readers)
>  
>  
>  acquired recursively. Unlike non-recursive read locks, recursive read locks
> -- 
> 2.7.4
> 

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

* Re: [PATCH] docs: lockdep-design: correct the notation for writer
  2021-05-21  8:55 ` Boqun Feng
@ 2021-05-21 11:05   ` Peter Zijlstra
  0 siblings, 0 replies; 9+ messages in thread
From: Peter Zijlstra @ 2021-05-21 11:05 UTC (permalink / raw)
  To: Boqun Feng
  Cc: Xiongwei Song, mingo, will, longman, corbet, linux-kernel,
	linux-doc, Xiongwei Song

On Fri, May 21, 2021 at 04:55:05PM +0800, Boqun Feng wrote:
> On Fri, May 21, 2021 at 02:29:54PM +0800, Xiongwei Song wrote:
> > From: Xiongwei Song <sxwjean@gmail.com>
> > 
> > The block condition matrix is using 'E' as the writer noation here, so it
> > would be better to use 'E' as the reminder rather than 'W'.
> > 
> 
> Good catch!
> 
> > Signed-off-by: Xiongwei Song <sxwjean@gmail.com>
> 
> Reviewed-by: Boqun Feng <boqun.feng@gmail.com>

Thanks!

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

* Re: [PATCH] docs: lockdep-design: correct the notation for writer
  2021-05-21  6:29 [PATCH] docs: lockdep-design: correct the notation for writer Xiongwei Song
  2021-05-21  8:55 ` Boqun Feng
@ 2021-05-21 15:17 ` Waiman Long
  2021-05-24  4:24   ` Xiongwei Song
  1 sibling, 1 reply; 9+ messages in thread
From: Waiman Long @ 2021-05-21 15:17 UTC (permalink / raw)
  To: Xiongwei Song, peterz, mingo, will, boqun.feng, corbet
  Cc: linux-kernel, linux-doc, Xiongwei Song

On 5/21/21 2:29 AM, Xiongwei Song wrote:
> From: Xiongwei Song <sxwjean@gmail.com>
>
> The block condition matrix is using 'E' as the writer noation here, so it
> would be better to use 'E' as the reminder rather than 'W'.
>
> Signed-off-by: Xiongwei Song <sxwjean@gmail.com>
> ---
>   Documentation/locking/lockdep-design.rst | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Documentation/locking/lockdep-design.rst b/Documentation/locking/lockdep-design.rst
> index 9f3cfca..c3b923a 100644
> --- a/Documentation/locking/lockdep-design.rst
> +++ b/Documentation/locking/lockdep-design.rst
> @@ -462,7 +462,7 @@ Block condition matrix, Y means the row blocks the column, and N means otherwise
>   	| R | Y | Y | N |
>   	+---+---+---+---+
>   
> -	(W: writers, r: non-recursive readers, R: recursive readers)
> +	(E: writers, r: non-recursive readers, R: recursive readers)
>   
>   
>   acquired recursively. Unlike non-recursive read locks, recursive read locks

I would say it should be the other way around. Both W and E refer to the 
same type of lockers. W emphasizes writer aspect of it and E for 
exclusive. I think we should change the block condition matrix to use W 
instead of E.

Cheers,
Longman


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

* Re: [PATCH] docs: lockdep-design: correct the notation for writer
  2021-05-21 15:17 ` Waiman Long
@ 2021-05-24  4:24   ` Xiongwei Song
  2021-05-24 10:32     ` Boqun Feng
  0 siblings, 1 reply; 9+ messages in thread
From: Xiongwei Song @ 2021-05-24  4:24 UTC (permalink / raw)
  To: Waiman Long
  Cc: Xiongwei Song, peterz, mingo, will, boqun.feng, corbet,
	Linux Kernel Mailing List, linux-doc

On Fri, May 21, 2021 at 11:17 PM Waiman Long <llong@redhat.com> wrote:
>
> On 5/21/21 2:29 AM, Xiongwei Song wrote:
> > From: Xiongwei Song <sxwjean@gmail.com>
> >
> > The block condition matrix is using 'E' as the writer noation here, so it
> > would be better to use 'E' as the reminder rather than 'W'.
> >
> > Signed-off-by: Xiongwei Song <sxwjean@gmail.com>
> > ---
> >   Documentation/locking/lockdep-design.rst | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/Documentation/locking/lockdep-design.rst b/Documentation/locking/lockdep-design.rst
> > index 9f3cfca..c3b923a 100644
> > --- a/Documentation/locking/lockdep-design.rst
> > +++ b/Documentation/locking/lockdep-design.rst
> > @@ -462,7 +462,7 @@ Block condition matrix, Y means the row blocks the column, and N means otherwise
> >       | R | Y | Y | N |
> >       +---+---+---+---+
> >
> > -     (W: writers, r: non-recursive readers, R: recursive readers)
> > +     (E: writers, r: non-recursive readers, R: recursive readers)
> >
> >
> >   acquired recursively. Unlike non-recursive read locks, recursive read locks
>
> I would say it should be the other way around. Both W and E refer to the
> same type of lockers. W emphasizes writer aspect of it and E for
> exclusive. I think we should change the block condition matrix to use W
> instead of E.

The doc uses 'E'  to describe dependency egdes too. Should we change them
to 'W'? Personally,  both 'W' and 'E' are fine.

Thanks,
Xiongwei
>
> Cheers,
> Longman
>

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

* Re: [PATCH] docs: lockdep-design: correct the notation for writer
  2021-05-24  4:24   ` Xiongwei Song
@ 2021-05-24 10:32     ` Boqun Feng
  2021-05-24 13:17       ` Xiongwei Song
  2021-05-24 13:42       ` Waiman Long
  0 siblings, 2 replies; 9+ messages in thread
From: Boqun Feng @ 2021-05-24 10:32 UTC (permalink / raw)
  To: Xiongwei Song
  Cc: Waiman Long, Xiongwei Song, peterz, mingo, will, corbet,
	Linux Kernel Mailing List, linux-doc

On Mon, May 24, 2021 at 12:24:00PM +0800, Xiongwei Song wrote:
> On Fri, May 21, 2021 at 11:17 PM Waiman Long <llong@redhat.com> wrote:
> >
> > On 5/21/21 2:29 AM, Xiongwei Song wrote:
> > > From: Xiongwei Song <sxwjean@gmail.com>
> > >
> > > The block condition matrix is using 'E' as the writer noation here, so it
> > > would be better to use 'E' as the reminder rather than 'W'.
> > >
> > > Signed-off-by: Xiongwei Song <sxwjean@gmail.com>
> > > ---
> > >   Documentation/locking/lockdep-design.rst | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/Documentation/locking/lockdep-design.rst b/Documentation/locking/lockdep-design.rst
> > > index 9f3cfca..c3b923a 100644
> > > --- a/Documentation/locking/lockdep-design.rst
> > > +++ b/Documentation/locking/lockdep-design.rst
> > > @@ -462,7 +462,7 @@ Block condition matrix, Y means the row blocks the column, and N means otherwise
> > >       | R | Y | Y | N |
> > >       +---+---+---+---+
> > >
> > > -     (W: writers, r: non-recursive readers, R: recursive readers)
> > > +     (E: writers, r: non-recursive readers, R: recursive readers)
> > >
> > >
> > >   acquired recursively. Unlike non-recursive read locks, recursive read locks
> >
> > I would say it should be the other way around. Both W and E refer to the
> > same type of lockers. W emphasizes writer aspect of it and E for
> > exclusive. I think we should change the block condition matrix to use W
> > instead of E.
> 
> The doc uses 'E'  to describe dependency egdes too. Should we change them
> to 'W'? Personally,  both 'W' and 'E' are fine.
> 

I also think Waiman's suggestion is solid, there are two ways to
classify locks:

1.	W (Writers), R (Recursive Readers), r (Non-recursive Readers)

2.	E (Exclusive locks), S (Shared locks), R (Recursive Readers),
	N (Non-recursive locks)

And the relations between them are as follow:

	E = W
	R = R
	N = W \/ r
	S = R \/ r 

, where "\/" is the set union.

The story is that I used the way #1 at first, and later on realized way
#2 is better for BFS implementation, also for reasoning, so here came
this leftover..

If you are interested, go ahead sending a patch fixing this, otherwise,
I will fix this.

Regards,
Boqun

> Thanks,
> Xiongwei
> >
> > Cheers,
> > Longman
> >

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

* Re: [PATCH] docs: lockdep-design: correct the notation for writer
  2021-05-24 10:32     ` Boqun Feng
@ 2021-05-24 13:17       ` Xiongwei Song
  2021-05-24 13:42       ` Waiman Long
  1 sibling, 0 replies; 9+ messages in thread
From: Xiongwei Song @ 2021-05-24 13:17 UTC (permalink / raw)
  To: Boqun Feng
  Cc: Waiman Long, Xiongwei Song, peterz, mingo, will, corbet,
	Linux Kernel Mailing List, linux-doc

On Mon, May 24, 2021 at 6:33 PM Boqun Feng <boqun.feng@gmail.com> wrote:
>
> On Mon, May 24, 2021 at 12:24:00PM +0800, Xiongwei Song wrote:
> > On Fri, May 21, 2021 at 11:17 PM Waiman Long <llong@redhat.com> wrote:
> > >
> > > On 5/21/21 2:29 AM, Xiongwei Song wrote:
> > > > From: Xiongwei Song <sxwjean@gmail.com>
> > > >
> > > > The block condition matrix is using 'E' as the writer noation here, so it
> > > > would be better to use 'E' as the reminder rather than 'W'.
> > > >
> > > > Signed-off-by: Xiongwei Song <sxwjean@gmail.com>
> > > > ---
> > > >   Documentation/locking/lockdep-design.rst | 2 +-
> > > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/Documentation/locking/lockdep-design.rst b/Documentation/locking/lockdep-design.rst
> > > > index 9f3cfca..c3b923a 100644
> > > > --- a/Documentation/locking/lockdep-design.rst
> > > > +++ b/Documentation/locking/lockdep-design.rst
> > > > @@ -462,7 +462,7 @@ Block condition matrix, Y means the row blocks the column, and N means otherwise
> > > >       | R | Y | Y | N |
> > > >       +---+---+---+---+
> > > >
> > > > -     (W: writers, r: non-recursive readers, R: recursive readers)
> > > > +     (E: writers, r: non-recursive readers, R: recursive readers)
> > > >
> > > >
> > > >   acquired recursively. Unlike non-recursive read locks, recursive read locks
> > >
> > > I would say it should be the other way around. Both W and E refer to the
> > > same type of lockers. W emphasizes writer aspect of it and E for
> > > exclusive. I think we should change the block condition matrix to use W
> > > instead of E.
> >
> > The doc uses 'E'  to describe dependency egdes too. Should we change them
> > to 'W'? Personally,  both 'W' and 'E' are fine.
> >
>
> I also think Waiman's suggestion is solid, there are two ways to
> classify locks:
>
> 1.      W (Writers), R (Recursive Readers), r (Non-recursive Readers)
>
> 2.      E (Exclusive locks), S (Shared locks), R (Recursive Readers),
>         N (Non-recursive locks)
>
> And the relations between them are as follow:
>
>         E = W
>         R = R
>         N = W \/ r
>         S = R \/ r
>
> , where "\/" is the set union.
>
> The story is that I used the way #1 at first, and later on realized way
> #2 is better for BFS implementation, also for reasoning, so here came
> this leftover..

Thanks for the explanation.

>
> If you are interested, go ahead sending a patch fixing this, otherwise,
> I will fix this.

Ok.  Let me fix.

Thanks,
Xiongwei
>
> Regards,
> Boqun
>
> > Thanks,
> > Xiongwei
> > >
> > > Cheers,
> > > Longman
> > >

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

* Re: [PATCH] docs: lockdep-design: correct the notation for writer
  2021-05-24 10:32     ` Boqun Feng
  2021-05-24 13:17       ` Xiongwei Song
@ 2021-05-24 13:42       ` Waiman Long
  2021-05-24 14:52         ` Boqun Feng
  1 sibling, 1 reply; 9+ messages in thread
From: Waiman Long @ 2021-05-24 13:42 UTC (permalink / raw)
  To: Boqun Feng, Xiongwei Song
  Cc: Waiman Long, Xiongwei Song, peterz, mingo, will, corbet,
	Linux Kernel Mailing List, linux-doc

On 5/24/21 6:32 AM, Boqun Feng wrote:
> On Mon, May 24, 2021 at 12:24:00PM +0800, Xiongwei Song wrote:
>> On Fri, May 21, 2021 at 11:17 PM Waiman Long <llong@redhat.com> wrote:
>>> On 5/21/21 2:29 AM, Xiongwei Song wrote:
>>>> From: Xiongwei Song <sxwjean@gmail.com>
>>>>
>>>> The block condition matrix is using 'E' as the writer noation here, so it
>>>> would be better to use 'E' as the reminder rather than 'W'.
>>>>
>>>> Signed-off-by: Xiongwei Song <sxwjean@gmail.com>
>>>> ---
>>>>    Documentation/locking/lockdep-design.rst | 2 +-
>>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/Documentation/locking/lockdep-design.rst b/Documentation/locking/lockdep-design.rst
>>>> index 9f3cfca..c3b923a 100644
>>>> --- a/Documentation/locking/lockdep-design.rst
>>>> +++ b/Documentation/locking/lockdep-design.rst
>>>> @@ -462,7 +462,7 @@ Block condition matrix, Y means the row blocks the column, and N means otherwise
>>>>        | R | Y | Y | N |
>>>>        +---+---+---+---+
>>>>
>>>> -     (W: writers, r: non-recursive readers, R: recursive readers)
>>>> +     (E: writers, r: non-recursive readers, R: recursive readers)
>>>>
>>>>
>>>>    acquired recursively. Unlike non-recursive read locks, recursive read locks
>>> I would say it should be the other way around. Both W and E refer to the
>>> same type of lockers. W emphasizes writer aspect of it and E for
>>> exclusive. I think we should change the block condition matrix to use W
>>> instead of E.
>> The doc uses 'E'  to describe dependency egdes too. Should we change them
>> to 'W'? Personally,  both 'W' and 'E' are fine.
>>
> I also think Waiman's suggestion is solid, there are two ways to
> classify locks:
>
> 1.	W (Writers), R (Recursive Readers), r (Non-recursive Readers)
>
> 2.	E (Exclusive locks), S (Shared locks), R (Recursive Readers),
> 	N (Non-recursive locks)
>
> And the relations between them are as follow:
>
> 	E = W
> 	R = R
> 	N = W \/ r
> 	S = R \/ r
>
> , where "\/" is the set union.
>
> The story is that I used the way #1 at first, and later on realized way
> #2 is better for BFS implementation, also for reasoning, so here came
> this leftover..
>
My suggestion was based on the fact that it is harder to associate E 
with writer. So from a readability perspective, it is better to change 
the block condition matrix to use 'W' to make it more readable.

Cheers,
Longman


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

* Re: [PATCH] docs: lockdep-design: correct the notation for writer
  2021-05-24 13:42       ` Waiman Long
@ 2021-05-24 14:52         ` Boqun Feng
  0 siblings, 0 replies; 9+ messages in thread
From: Boqun Feng @ 2021-05-24 14:52 UTC (permalink / raw)
  To: Waiman Long
  Cc: Xiongwei Song, Xiongwei Song, peterz, mingo, will, corbet,
	Linux Kernel Mailing List, linux-doc

On Mon, May 24, 2021 at 09:42:20AM -0400, Waiman Long wrote:
> On 5/24/21 6:32 AM, Boqun Feng wrote:
> > On Mon, May 24, 2021 at 12:24:00PM +0800, Xiongwei Song wrote:
> > > On Fri, May 21, 2021 at 11:17 PM Waiman Long <llong@redhat.com> wrote:
> > > > On 5/21/21 2:29 AM, Xiongwei Song wrote:
> > > > > From: Xiongwei Song <sxwjean@gmail.com>
> > > > > 
> > > > > The block condition matrix is using 'E' as the writer noation here, so it
> > > > > would be better to use 'E' as the reminder rather than 'W'.
> > > > > 
> > > > > Signed-off-by: Xiongwei Song <sxwjean@gmail.com>
> > > > > ---
> > > > >    Documentation/locking/lockdep-design.rst | 2 +-
> > > > >    1 file changed, 1 insertion(+), 1 deletion(-)
> > > > > 
> > > > > diff --git a/Documentation/locking/lockdep-design.rst b/Documentation/locking/lockdep-design.rst
> > > > > index 9f3cfca..c3b923a 100644
> > > > > --- a/Documentation/locking/lockdep-design.rst
> > > > > +++ b/Documentation/locking/lockdep-design.rst
> > > > > @@ -462,7 +462,7 @@ Block condition matrix, Y means the row blocks the column, and N means otherwise
> > > > >        | R | Y | Y | N |
> > > > >        +---+---+---+---+
> > > > > 
> > > > > -     (W: writers, r: non-recursive readers, R: recursive readers)
> > > > > +     (E: writers, r: non-recursive readers, R: recursive readers)
> > > > > 
> > > > > 
> > > > >    acquired recursively. Unlike non-recursive read locks, recursive read locks
> > > > I would say it should be the other way around. Both W and E refer to the
> > > > same type of lockers. W emphasizes writer aspect of it and E for
> > > > exclusive. I think we should change the block condition matrix to use W
> > > > instead of E.
> > > The doc uses 'E'  to describe dependency egdes too. Should we change them
> > > to 'W'? Personally,  both 'W' and 'E' are fine.
> > > 
> > I also think Waiman's suggestion is solid, there are two ways to
> > classify locks:
> > 
> > 1.	W (Writers), R (Recursive Readers), r (Non-recursive Readers)
> > 
> > 2.	E (Exclusive locks), S (Shared locks), R (Recursive Readers),
> > 	N (Non-recursive locks)
> > 
> > And the relations between them are as follow:
> > 
> > 	E = W
> > 	R = R
> > 	N = W \/ r
> > 	S = R \/ r
> > 
> > , where "\/" is the set union.
> > 
> > The story is that I used the way #1 at first, and later on realized way
> > #2 is better for BFS implementation, also for reasoning, so here came
> > this leftover..
> > 
> My suggestion was based on the fact that it is harder to associate E with
> writer. So from a readability perspective, it is better to change the block
> condition matrix to use 'W' to make it more readable.
> 

Yes, I agree. It's probably due to the curse of knowledge, I cannot see
the difficultly of associating E with writer ;-) So thanks for pointing
out!

Actually there are two block condition matrices in my mind:

The block condition matrix describes the natural of block conditions of
write/read locks, this one provides better readability for lock users,
it can be used to answer questions like: which lock blocks another lock.

	|   | W | r | R |
	+---+---+---+---+
	| W | Y | Y | Y |
	+---|---+---+---+
	| r | Y | Y | N |
	+---+---+---+---+
	| R | Y | Y | N |

(answer whether row blocks column)

Based on this, we have a more abstract block condition matrix in
lockdep, it's used to reason about deadlock possibility and implement
the deadlock detection, it might not be the good one for normal lock
users to read.

	|   |  N  |  R  |
	+---+-----+-----+
	| E | Yes | Yes |
	+---+-----+-----+
	| S | Yes | No  |

(answer whether row blocks column)

FWIW, if we are going to put the second block condition matrix in the
doc, we'd better place it somewhere in the section "Dependency types and
strong dependency paths".

Just clarify a little while we are at it.

Regards,
Boqun

> Cheers,
> Longman
> 

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

end of thread, other threads:[~2021-05-24 15:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-21  6:29 [PATCH] docs: lockdep-design: correct the notation for writer Xiongwei Song
2021-05-21  8:55 ` Boqun Feng
2021-05-21 11:05   ` Peter Zijlstra
2021-05-21 15:17 ` Waiman Long
2021-05-24  4:24   ` Xiongwei Song
2021-05-24 10:32     ` Boqun Feng
2021-05-24 13:17       ` Xiongwei Song
2021-05-24 13:42       ` Waiman Long
2021-05-24 14:52         ` Boqun Feng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.