Skip to contentSkip to conversation

formal/spinhint: Clarify the proof

PATCH In review Alan Huang 3 participants 9 messages May 14, 2023 – May 27, 2023

lore
Share & tools
lore

Alan Huang

author
#0 lore raw

PATCH 1/1 formal/spinhint: Clarify the proof

The third step and the fourth step seem to have no causal relationship between them. Therefore, this patch explains under what circumstances both counters will be at least 1.

---
 formal/spinhint.tex | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
formal/spinhint.tex +3 -2
index 16764aef..dd2e88cc 100644
@@ -1103,8 +1103,9 @@ follows:
 	execution.
 \item	The counter corresponding to this reader will have been
 	at least 1 during this time interval.
-\item	The \co{synchronize_qrcu()} code forces at least one
-	of the counters to be at least 1 at all times.
+\item	If the counter corresponding to this reader is 1, then
+	the other counter is at least 1 because of the completion of
+	counter flip.
 \item	Therefore, at any given point in time, either one of the
 	counters will be at least 2, or both of the counters will
 	be at least one.
Signature · 1 line
2.34.1
#1 lore raw

Hi Alan,

Quoted 1 line · Alan Huang

The third step and the fourth step seem to have no causal relationship between them.

Why do you expect causal relationship between the two?

Quoted 13 lines

Therefore, this patch explains under what circumstances both counters will be at least 1.

---
 formal/spinhint.tex | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
formal/spinhint.tex +0 -0
index 16764aef..dd2e88cc 100644
@@ -1103,8 +1103,9 @@ follows:
 	execution.

formal/spinhint.tex follows: · line 1111

Quoted 10 lines
formal/spinhint.tex +3 -2
 \item	The counter corresponding to this reader will have been
 	at least 1 during this time interval.
-\item	The \co{synchronize_qrcu()} code forces at least one
-	of the counters to be at least 1 at all times.
+\item	If the counter corresponding to this reader is 1, then
+	the other counter is at least 1 because of the completion of
+	counter flip.
 \item	Therefore, at any given point in time, either one of the
 	counters will be at least 2, or both of the counters will
 	be at least one.

"Therefore" on item 4 looks to me assumes all of items 1, 2, and 3.

What am I missing?

Thanks, Akira

author
#2 lore raw

Hi Akira,

Quoted 26 lines

2023年5月16日 下午6:07,Akira Yokosawa <[email protected]> 写道:

Hi Alan,

Quoted 1 line · Alan Huang

The third step and the fourth step seem to have no causal relationship between them.

Why do you expect causal relationship between the two?

Quoted 17 lines

Therefore, this patch explains under what circumstances both counters will be at least 1.

---
formal/spinhint.tex | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)
formal/spinhint.tex +0 -0
index 16764aef..dd2e88cc 100644
@@ -1103,8 +1103,9 @@ follows:
 	execution.

\item The counter corresponding to this reader will have been
at least 1 during this time interval.
-\item The \co{synchronize_qrcu()} code forces at least one

formal/spinhint.tex +0 -1
-	of the counters to be at least 1 at all times.
Quoted 8 lines
Quoted 6 lines

+\item If the counter corresponding to this reader is 1, then

formal/spinhint.tex +2 -0
+	the other counter is at least 1 because of the completion of
+	counter flip.

\item Therefore, at any given point in time, either one of the
counters will be at least 2, or both of the counters will be at least one.

"Therefore" on item 4 looks to me assumes all of items 1, 2, and 3.

Yeah, that’s right. My commit message is misleading.

This patch makes item 3 more specific.

Thanks,
Alan

Quoted 4 lines

What am I missing?

Thanks, Akira

#3 lore raw

Hi Alan,

Quoted 37 lines · Alan Huang

Hi Akira,

Quoted 26 lines

2023年5月16日 下午6:07,Akira Yokosawa <[email protected]> 写道:

Hi Alan,

Quoted 1 line · Alan Huang

The third step and the fourth step seem to have no causal relationship between them.

Why do you expect causal relationship between the two?

Quoted 17 lines

Therefore, this patch explains under what circumstances both counters will be at least 1.

---
formal/spinhint.tex | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)
formal/spinhint.tex +0 -0
index 16764aef..dd2e88cc 100644
@@ -1103,8 +1103,9 @@ follows:
 	execution.

\item The counter corresponding to this reader will have been
at least 1 during this time interval.
-\item The \co{synchronize_qrcu()} code forces at least one

formal/spinhint.tex +0 -1
-	of the counters to be at least 1 at all times.
Quoted 8 lines
Quoted 6 lines

+\item If the counter corresponding to this reader is 1, then

formal/spinhint.tex +2 -0
+	the other counter is at least 1 because of the completion of
+	counter flip.

\item Therefore, at any given point in time, either one of the
counters will be at least 2, or both of the counters will be at least one.

"Therefore" on item 4 looks to me assumes all of items 1, 2, and 3.

Quoted 3 lines

Yeah, that’s right. My commit message is misleading.

This patch makes item 3 more specific.

I might be too nit-picky, but you are changing the simple statement of observation:

The synchronize_qrcu() code forces at least one of the counters to be at least 1 at all times.

to a complex sentence of:

If the counter corresponding to this reader is 1, then the other counter is at least 1 because of the completion of counter flip.

Your wording describes something different from the original one, doesn't it?

Can you elaborate what you find hard to follow in this _informal_ proof?

Thanks, Akira

Quoted 9 lines

Thanks,
Alan

Quoted 4 lines

What am I missing?

Thanks, Akira

author
#4 lore raw

Hi Akira,

Quoted 58 lines

2023年5月17日 下午10:55,Akira Yokosawa <[email protected]> 写道:

Hi Alan,

Quoted 37 lines · Alan Huang

Hi Akira,

Quoted 26 lines

2023年5月16日 下午6:07,Akira Yokosawa <[email protected]> 写道:

Hi Alan,

Quoted 1 line · Alan Huang

The third step and the fourth step seem to have no causal relationship between them.

Why do you expect causal relationship between the two?

Quoted 17 lines

Therefore, this patch explains under what circumstances both counters will be at least 1.

---
formal/spinhint.tex | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)
formal/spinhint.tex +0 -0
index 16764aef..dd2e88cc 100644
@@ -1103,8 +1103,9 @@ follows:
 	execution.

\item The counter corresponding to this reader will have been
at least 1 during this time interval.
-\item The \co{synchronize_qrcu()} code forces at least one

formal/spinhint.tex +0 -1
-	of the counters to be at least 1 at all times.
Quoted 8 lines
Quoted 6 lines

+\item If the counter corresponding to this reader is 1, then

formal/spinhint.tex +2 -0
+	the other counter is at least 1 because of the completion of
+	counter flip.

\item Therefore, at any given point in time, either one of the
counters will be at least 2, or both of the counters will be at least one.

"Therefore" on item 4 looks to me assumes all of items 1, 2, and 3.

Quoted 3 lines

Yeah, that’s right. My commit message is misleading.

This patch makes item 3 more specific.

I might be too nit-picky, but you are changing the simple statement of observation:

The synchronize_qrcu() code forces at least one of the counters to be at least 1 at all times.

to a complex sentence of:

If the counter corresponding to this reader is 1, then the other counter is at least 1 because of the completion of counter flip.

Quoted 5 lines

Your wording describes something different from the original one, doesn't it?

Can you elaborate what you find hard to follow in this _informal_ proof?

Item 4 says:

Therefore, at any given point in time, either one of the counters will be at least 2, or both of the counters will be at least one.

“at least 2” is obvious, but it took me some time to figure this out:

"or both of the counters will be at least one”

The original item 3 is not very helpful to me.

But others may prefer the original one :)

Thanks,
Alan

Quoted 10 lines

Thanks, Akira

Quoted 8 lines

Thanks,
Alan

Quoted 4 lines

What am I missing?

Thanks, Akira

#5 lore raw
Quoted 72 lines · Alan Huang

Hi Akira,

Quoted 58 lines

2023年5月17日 下午10:55,Akira Yokosawa <[email protected]> 写道:

Hi Alan,

Quoted 37 lines · Alan Huang

Hi Akira,

Quoted 26 lines

2023年5月16日 下午6:07,Akira Yokosawa <[email protected]> 写道:

Hi Alan,

Quoted 1 line · Alan Huang

The third step and the fourth step seem to have no causal relationship between them.

Why do you expect causal relationship between the two?

Quoted 17 lines

Therefore, this patch explains under what circumstances both counters will be at least 1.

---
formal/spinhint.tex | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)
formal/spinhint.tex +0 -0
index 16764aef..dd2e88cc 100644
@@ -1103,8 +1103,9 @@ follows:
 	execution.

\item The counter corresponding to this reader will have been
at least 1 during this time interval.
-\item The \co{synchronize_qrcu()} code forces at least one

formal/spinhint.tex +0 -1
-	of the counters to be at least 1 at all times.
Quoted 8 lines
Quoted 6 lines

+\item If the counter corresponding to this reader is 1, then

formal/spinhint.tex +2 -0
+	the other counter is at least 1 because of the completion of
+	counter flip.

\item Therefore, at any given point in time, either one of the
counters will be at least 2, or both of the counters will be at least one.

"Therefore" on item 4 looks to me assumes all of items 1, 2, and 3.

Quoted 3 lines

Yeah, that’s right. My commit message is misleading.

This patch makes item 3 more specific.

I might be too nit-picky, but you are changing the simple statement of observation:

The synchronize_qrcu() code forces at least one of the counters to be at least 1 at all times.

to a complex sentence of:

If the counter corresponding to this reader is 1, then the other counter is at least 1 because of the completion of counter flip.

Quoted 5 lines

Your wording describes something different from the original one, doesn't it?

Can you elaborate what you find hard to follow in this _informal_ proof?

Item 4 says:

Therefore, at any given point in time, either one of the counters will be at least 2, or both of the counters will be at least one.

Quoted 7 lines

“at least 2” is obvious, but it took me some time to figure this out:

"or both of the counters will be at least one”

The original item 3 is not very helpful to me.

But others may prefer the original one :)

I will take a closer look before the end of the weekend. Sorry to be slow, but a Linux-kernel RCU issue has me by the ankle.

Thanx, Paul

#6 lore raw
In reply to Alan Huang
Quoted 13 lines · Alan Huang

The third step and the fourth step seem to have no causal relationship between them. Therefore, this patch explains under what circumstances both counters will be at least 1.

---
 formal/spinhint.tex | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
formal/spinhint.tex +0 -0
index 16764aef..dd2e88cc 100644

formal/spinhint.tex follows: · line 1107

Quoted 5 lines
formal/spinhint.tex +0 -2
@@ -1103,8 +1103,9 @@ follows:
 	execution.
 \item	The counter corresponding to this reader will have been
 	at least 1 during this time interval.
-\item	The \co{synchronize_qrcu()} code forces at least one
-	of the counters to be at least 1 at all times.

So this part is true and fundamental to understanding the code. You can see this on lines 31-33 of Listing 12.14 ("QRCU Updater Process"). This code increments the next counter before decrementing the previous counter. I therefore don't see how we can reasonably delete this item.

formal/spinhint.tex follows: · line 1108

Quoted 3 lines
formal/spinhint.tex +3 -0
+\item	If the counter corresponding to this reader is 1, then
+	the other counter is at least 1 because of the completion of
+	counter flip.

However, we could potentially add this as an intermediate consequence of items 2 and 3. Maybe something like this?

\item The above two items imply that if the counter corresponding
to this reader is exactly one, then the other counter must be greater than or equal to one. Similarly, if the other counter is equal to zero, then the counter corresponding to the reader must be greater than or equal to two.

formal/spinhint.tex follows: · line 1111

Quoted 3 lines
formal/spinhint.tex +0 -0
 \item	Therefore, at any given point in time, either one of the
 	counters will be at least 2, or both of the counters will
 	be at least one.

Would that help, or am I missing your point?

Thanx, Paul

author
#7 lore raw
Quoted 12 lines

2023年5月21日 18:20,Paul E. McKenney <[email protected]> 写道:

Quoted 8 lines · Alan Huang

The third step and the fourth step seem to have no causal relationship between them. Therefore, this patch explains under what circumstances both counters will be at least 1.

---
formal/spinhint.tex | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 15 lines
Quoted 10 lines
formal/spinhint.tex +0 -0
index 16764aef..dd2e88cc 100644
@@ -1103,8 +1103,9 @@ follows:

execution.
\item The counter corresponding to this reader will have been at least 1 during this time interval.
-\item The \co{synchronize_qrcu()} code forces at least one
- of the counters to be at least 1 at all times.

So this part is true and fundamental to understanding the code. You can see this on lines 31-33 of Listing 12.14 ("QRCU Updater Process"). This code increments the next counter before decrementing the previous counter. I therefore don't see how we can reasonably delete this item.

Yes, this item is completely correct.

Quoted 5 lines
Quoted 4 lines

+\item If the counter corresponding to this reader is 1, then
+ the other counter is at least 1 because of the completion of
+ counter flip.

Quoted 8 lines

However, we could potentially add this as an intermediate consequence of items 2 and 3. Maybe something like this?

\item The above two items imply that if the counter corresponding to this reader is exactly one, then the other counter must be greater than or equal to one. Similarly, if the other counter is equal to zero, then the counter corresponding to the reader must be greater than or equal to two.

That will be very helpful, adding an item will be better than deleting one!

Thanks,
Alan

Quoted 8 lines
Quoted 4 lines

\item Therefore, at any given point in time, either one of the counters will be at least 2, or both of the counters will be at least one.

Would that help, or am I missing your point?

Thanx, Paul

#8 lore raw
Quoted 38 lines · Alan Huang
Quoted 12 lines

2023年5月21日 18:20,Paul E. McKenney <[email protected]> 写道:

Quoted 8 lines · Alan Huang

The third step and the fourth step seem to have no causal relationship between them. Therefore, this patch explains under what circumstances both counters will be at least 1.

---
formal/spinhint.tex | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 15 lines
Quoted 10 lines
formal/spinhint.tex +0 -0
index 16764aef..dd2e88cc 100644
@@ -1103,8 +1103,9 @@ follows:

execution.
\item The counter corresponding to this reader will have been at least 1 during this time interval.
-\item The \co{synchronize_qrcu()} code forces at least one
- of the counters to be at least 1 at all times.

So this part is true and fundamental to understanding the code. You can see this on lines 31-33 of Listing 12.14 ("QRCU Updater Process"). This code increments the next counter before decrementing the previous counter. I therefore don't see how we can reasonably delete this item.

Yes, this item is completely correct.

Quoted 8 lines
Quoted 4 lines

+\item If the counter corresponding to this reader is 1, then
+ the other counter is at least 1 because of the completion of
+ counter flip.

However, we could potentially add this as an intermediate consequence of items 2 and 3. Maybe something like this?

Quoted 7 lines
Quoted 5 lines

\item The above two items imply that if the counter corresponding to this reader is exactly one, then the other counter must be greater than or equal to one. Similarly, if the other counter is equal to zero, then the counter corresponding to the reader must be greater than or equal to two.

That will be very helpful, adding an item will be better than deleting one!

Very good, thank you! I have added the following, with your Reported-by.

Thanx, Paul

------------------------------------------------------------------------

commit cbef7a09aa845ca2eded65a124970c6508d4b2b2

Author: Paul E. McKenney <[email protected]>
Date:   Sat May 27 03:35:55 2023 -0700

spinhint: Add clarifying step to QRCU by-hand proof

formal/spinhint.tex +5 -0
index 16764aef..9e68198e 100644
@@ -1105,6 +1105,11 @@ follows:
 	at least 1 during this time interval.
 \item	The \co{synchronize_qrcu()} code forces at least one
 	of the counters to be at least 1 at all times.
+\item	The above two items imply that if the counter corresponding
+	to this reader is exactly one, then the other counter must be
+	greater than or equal to one.
+	Similarly, if the other counter is equal to zero, then the counter
+	corresponding to the reader must be greater than or equal to two.
 \item	Therefore, at any given point in time, either one of the
 	counters will be at least 2, or both of the counters will
 	be at least one.