Skip to contentSkip to conversation

srcu: Fix a misspelling in note

PATCH In review Pingfan Liu 4 participants 8 messages Nov 16, 2022 – Nov 17, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 srcu: Fix a misspelling in note

Cc Lai Jiangshan <[email protected]>
Cc "Paul E. McKenney" <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Josh Triplett <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Mathieu Desnoyers <[email protected]>

To: [email protected]

---
 include/linux/srcutree.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/srcutree.h +1 -1
index e3014319d1ad..f52820e88018 100644
@@ -48,7 +48,7 @@ struct srcu_data {
 struct srcu_node {
 	spinlock_t __private lock;
 	unsigned long srcu_have_cbs[4];		/* GP seq for children having CBs, but only */
-						/*  if greater than ->srcu_gq_seq. */
+						/*  if greater than ->srcu_gp_seq. */
 	unsigned long srcu_data_have_cbs[4];	/* Which srcu_data structs have CBs for given GP? */
 	unsigned long srcu_gp_seq_needed_exp;	/* Furthest future exp GP. */
 	struct srcu_node *srcu_parent;		/* Next up in tree. */
Signature · 1 line
2.31.1
#1 lore raw

PATCH 2/2 srcu: Fix the comparision in srcu_invl_snp_seq()

A seq contains two fields: counter and state.

SRCU_SNP_INIT_SEQ is used as invalid initial value for srcu_node GP sequence numbers. Hence srcu_invl_snp_seq() should compare both fields of a seq.

Cc Lai Jiangshan <[email protected]>
Cc "Paul E. McKenney" <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Josh Triplett <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Mathieu Desnoyers <[email protected]>

To: [email protected]

---
 kernel/rcu/srcutree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/srcutree.c +1 -1
index 1c304fec89c0..725c82bb0a6a 100644
@@ -154,7 +154,7 @@ static void init_srcu_struct_data(struct srcu_struct *ssp)
  */
 static inline bool srcu_invl_snp_seq(unsigned long s)
 {
-	return rcu_seq_state(s) == SRCU_SNP_INIT_SEQ;
+	return s == SRCU_SNP_INIT_SEQ;
 }
 
 /*
Signature · 1 line
2.31.1
Reviewed-by on v1 1/2
#5 lore raw
In reply to Pingfan Liu

Hi,

Quoted 8 lines · Pingfan Liu
Cc Lai Jiangshan <[email protected]>
Cc "Paul E. McKenney" <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Josh Triplett <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Mathieu Desnoyers <[email protected]>

To: [email protected]

LGTM.

-Mukesh

Quoted 17 lines
---
  include/linux/srcutree.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/srcutree.h +1 -1
index e3014319d1ad..f52820e88018 100644
@@ -48,7 +48,7 @@ struct srcu_data {
  struct srcu_node {
  	spinlock_t __private lock;
  	unsigned long srcu_have_cbs[4];		/* GP seq for children having CBs, but only */
-						/*  if greater than ->srcu_gq_seq. */
+						/*  if greater than ->srcu_gp_seq. */
  	unsigned long srcu_data_have_cbs[4];	/* Which srcu_data structs have CBs for given GP? */
  	unsigned long srcu_gp_seq_needed_exp;	/* Furthest future exp GP. */
  	struct srcu_node *srcu_parent;		/* Next up in tree. */
maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] srcu: Fix the comparision in srcu_invl_snp_seq()

In reply to Pingfan Liu
Quoted 23 lines · Pingfan Liu

A seq contains two fields: counter and state.

SRCU_SNP_INIT_SEQ is used as invalid initial value for srcu_node GP sequence numbers. Hence srcu_invl_snp_seq() should compare both fields of a seq.

Cc Lai Jiangshan <[email protected]>
Cc "Paul E. McKenney" <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Josh Triplett <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Mathieu Desnoyers <[email protected]>

To: [email protected]

---
 kernel/rcu/srcutree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/srcutree.c +0 -0
index 1c304fec89c0..725c82bb0a6a 100644

kernel/rcu/srcutree.c static void init_srcu_struct_data(struct srcu_struct *ssp) · line 157

Quoted 5 lines
kernel/rcu/srcutree.c +1 -1
@@ -154,7 +154,7 @@ static void init_srcu_struct_data(struct srcu_struct *ssp)
  */
 static inline bool srcu_invl_snp_seq(unsigned long s)
 {
-	return rcu_seq_state(s) == SRCU_SNP_INIT_SEQ;
+	return s == SRCU_SNP_INIT_SEQ;

Doesn't hurt and makes it less confusing as it doesn't suggest anymore there _might_ be a gp number behind.

Quoted 6 lines
kernel/rcu/srcutree.c +0 -0
 }
 
 /*
Signature · 1 line
2.31.1
maintainer Reviewed-by on v1 1/2
#6 lore raw
In reply to Pingfan Liu
Quoted 17 lines · Pingfan Liu
Cc Lai Jiangshan <[email protected]>
Cc "Paul E. McKenney" <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Josh Triplett <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Mathieu Desnoyers <[email protected]>

To: [email protected]

---
 include/linux/srcutree.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/srcutree.h +0 -0
index e3014319d1ad..f52820e88018 100644

include/linux/srcutree.h struct srcu_data { · line 51

Quoted 5 lines
include/linux/srcutree.h +1 -1
@@ -48,7 +48,7 @@ struct srcu_data {
 struct srcu_node {
 	spinlock_t __private lock;
 	unsigned long srcu_have_cbs[4];		/* GP seq for children having CBs, but only */
-						/*  if greater than ->srcu_gq_seq. */
+						/*  if greater than ->srcu_gp_seq. */

Sharp eye ;-)

Quoted 6 lines
include/linux/srcutree.h +0 -0
 	unsigned long srcu_data_have_cbs[4];	/* Which srcu_data structs have CBs for given GP? */
 	unsigned long srcu_gp_seq_needed_exp;	/* Furthest future exp GP. */
 	struct srcu_node *srcu_parent;		/* Next up in tree. */
Signature · 1 line
2.31.1
maintainer
#7 lore raw
Quoted 26 lines · Frederic Weisbecker
Quoted 17 lines · Pingfan Liu
Cc Lai Jiangshan <[email protected]>
Cc "Paul E. McKenney" <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Josh Triplett <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Mathieu Desnoyers <[email protected]>

To: [email protected]

---
 include/linux/srcutree.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/srcutree.h +0 -0
index e3014319d1ad..f52820e88018 100644

include/linux/srcutree.h struct srcu_data { · line 51

Quoted 5 lines
include/linux/srcutree.h +1 -1
@@ -48,7 +48,7 @@ struct srcu_data {
 struct srcu_node {
 	spinlock_t __private lock;
 	unsigned long srcu_have_cbs[4];		/* GP seq for children having CBs, but only */
-						/*  if greater than ->srcu_gq_seq. */
+						/*  if greater than ->srcu_gp_seq. */

Sharp eye ;-)

Quoted 1 line

Applied with both Reviewed-by tags, thank you all!

Thanx, Paul

Quoted 6 lines
Quoted 6 lines
include/linux/srcutree.h +0 -0
 	unsigned long srcu_data_have_cbs[4];	/* Which srcu_data structs have CBs for given GP? */
 	unsigned long srcu_gp_seq_needed_exp;	/* Furthest future exp GP. */
 	struct srcu_node *srcu_parent;		/* Next up in tree. */
Signature · 1 line
2.31.1
maintainer Reviewed-by Frederic Weisbecker
#3 lore raw

Re: [PATCH 2/2] srcu: Fix the comparision in srcu_invl_snp_seq()

In reply to Frederic Weisbecker
Quoted 33 lines · Frederic Weisbecker
Quoted 23 lines · Pingfan Liu

A seq contains two fields: counter and state.

SRCU_SNP_INIT_SEQ is used as invalid initial value for srcu_node GP sequence numbers. Hence srcu_invl_snp_seq() should compare both fields of a seq.

Cc Lai Jiangshan <[email protected]>
Cc "Paul E. McKenney" <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Josh Triplett <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Mathieu Desnoyers <[email protected]>

To: [email protected]

---
 kernel/rcu/srcutree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/srcutree.c +0 -0
index 1c304fec89c0..725c82bb0a6a 100644

kernel/rcu/srcutree.c static void init_srcu_struct_data(struct srcu_struct *ssp) · line 157

Quoted 5 lines
kernel/rcu/srcutree.c +1 -1
@@ -154,7 +154,7 @@ static void init_srcu_struct_data(struct srcu_struct *ssp)
  */
 static inline bool srcu_invl_snp_seq(unsigned long s)
 {
-	return rcu_seq_state(s) == SRCU_SNP_INIT_SEQ;
+	return s == SRCU_SNP_INIT_SEQ;

Doesn't hurt and makes it less confusing as it doesn't suggest anymore there _might_ be a gp number behind.

Quoted 1 line

Good catch, thank you both!

My first reaction was that this patch was wrong, so I recorded the results of my investigation in the commit log. Please check below in case I messed something up.

Thanx, Paul

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

commit 08d9c4f609afaf5c3032320d50f2bae4acdca314

Author: Pingfan Liu <[email protected]>
Date:   Wed Nov 16 09:52:44 2022 +0800

srcu: Fix the comparision in srcu_invl_snp_seq()

A grace-period sequence number contains two fields: counter and state. SRCU_SNP_INIT_SEQ provides a guaranteed invalid value for grace-period sequence numbers in newly allocated srcu_node structures' ->srcu_have_cbs[] and ->srcu_gp_seq_needed_exp fields. The point of the comparison in srcu_invl_snp_seq() is not to detect invalid grace-period sequence numbers in general, but rather to detect a newly allocated srcu_node structure whose ->srcu_have_cbs[] and ->srcu_gp_seq_needed_exp fields need to be brought into line with the srcu_struct structure's ->srcu_gp_seq field.

This commit therefore causes srcu_invl_snp_seq() to compare both fields of the specified grace-period sequence number.

Cc Lai Jiangshan <[email protected]>
Cc "Paul E. McKenney" <[email protected]>
Cc Josh Triplett <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Mathieu Desnoyers <[email protected]>
kernel/rcu/srcutree.c +1 -1
index 16953784a0bdf..6af0312005801 100644
@@ -154,7 +154,7 @@ static void init_srcu_struct_data(struct srcu_struct *ssp)
  */
 static inline bool srcu_invl_snp_seq(unsigned long s)
 {
-	return rcu_seq_state(s) == SRCU_SNP_INIT_SEQ;
+	return s == SRCU_SNP_INIT_SEQ;
 }
 
 /*
#4 lore raw

Re: [PATCH 2/2] srcu: Fix the comparision in srcu_invl_snp_seq()

Quoted 35 lines · Paul E. McKenney
Quoted 33 lines · Frederic Weisbecker
Quoted 23 lines · Pingfan Liu

A seq contains two fields: counter and state.

SRCU_SNP_INIT_SEQ is used as invalid initial value for srcu_node GP sequence numbers. Hence srcu_invl_snp_seq() should compare both fields of a seq.

Cc Lai Jiangshan <[email protected]>
Cc "Paul E. McKenney" <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Josh Triplett <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Mathieu Desnoyers <[email protected]>

To: [email protected]

---
 kernel/rcu/srcutree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/srcutree.c +0 -0
index 1c304fec89c0..725c82bb0a6a 100644

kernel/rcu/srcutree.c static void init_srcu_struct_data(struct srcu_struct *ssp) · line 157

Quoted 5 lines
kernel/rcu/srcutree.c +1 -1
@@ -154,7 +154,7 @@ static void init_srcu_struct_data(struct srcu_struct *ssp)
  */
 static inline bool srcu_invl_snp_seq(unsigned long s)
 {
-   return rcu_seq_state(s) == SRCU_SNP_INIT_SEQ;
+   return s == SRCU_SNP_INIT_SEQ;

Doesn't hurt and makes it less confusing as it doesn't suggest anymore there _might_ be a gp number behind.

Quoted 8 lines
Quoted 1 line

Good catch, thank you both!

My first reaction was that this patch was wrong, so I recorded the results of my investigation in the commit log. Please check below in case I messed something up.

It looks more clear now. Thanks for improving the log.

Thanks,

Pingfan

Quoted 46 lines

Thanx, Paul

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

commit 08d9c4f609afaf5c3032320d50f2bae4acdca314

Author: Pingfan Liu <[email protected]>
Date:   Wed Nov 16 09:52:44 2022 +0800

srcu: Fix the comparision in srcu_invl_snp_seq()

A grace-period sequence number contains two fields: counter and state. SRCU_SNP_INIT_SEQ provides a guaranteed invalid value for grace-period sequence numbers in newly allocated srcu_node structures' ->srcu_have_cbs[] and ->srcu_gp_seq_needed_exp fields. The point of the comparison in srcu_invl_snp_seq() is not to detect invalid grace-period sequence numbers in general, but rather to detect a newly allocated srcu_node structure whose ->srcu_have_cbs[] and ->srcu_gp_seq_needed_exp fields need to be brought into line with the srcu_struct structure's ->srcu_gp_seq field.

This commit therefore causes srcu_invl_snp_seq() to compare both fields of the specified grace-period sequence number.

Cc Lai Jiangshan <[email protected]>
Cc "Paul E. McKenney" <[email protected]>
Cc Josh Triplett <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Mathieu Desnoyers <[email protected]>
kernel/rcu/srcutree.c +1 -1
index 16953784a0bdf..6af0312005801 100644
@@ -154,7 +154,7 @@ static void init_srcu_struct_data(struct srcu_struct *ssp)
  */
 static inline bool srcu_invl_snp_seq(unsigned long s)
 {
-       return rcu_seq_state(s) == SRCU_SNP_INIT_SEQ;
+       return s == SRCU_SNP_INIT_SEQ;
 }
 
 /*