Skip to contentSkip to conversation

rcu: trivial adjust for comments

PATCH Applied Wei Yang 3 participants 8 messages Jun 12, 2020 RCU

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

cover rcu: trivial adjust for comments

During code reading, I found there are several mismatch between comments and code implementation.

Adjust the comment for better understanding.

Wei Yang (4):
rcu: gp_max is protected by root rcu_node's lock
rcu: grplo/grphi just records CPU number
rcu: grpnum just records group number
rcu: use gp_seq instead of rcu_gp_seq for consistency

 kernel/rcu/tree.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
Signature · 1 line
2.20.1 (Apple Git-117)
author
#1 lore raw

PATCH 1/4 rcu: gp_max is protected by root rcu_node's lock

gp_max is protected by root rcu_node's lock, let's move the definition to the place where comments indicate.

---
 kernel/rcu/tree.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/tree.h +2 -2
index 43991a40b084..ed9b534ad870 100644
@@ -301,6 +301,8 @@ struct rcu_state {
 	u8	boost ____cacheline_internodealigned_in_smp;
 						/* Subject to priority boost. */
 	unsigned long gp_seq;			/* Grace-period sequence #. */
+	unsigned long gp_max;			/* Maximum GP duration in */
+						/*  jiffies. */
 	struct task_struct *gp_kthread;		/* Task for grace periods. */
 	struct swait_queue_head gp_wq;		/* Where GP task waits. */
 	short gp_flags;				/* Commands for GP task. */
@@ -346,8 +348,6 @@ struct rcu_state {
 						/*  a reluctant CPU. */
 	unsigned long n_force_qs_gpstart;	/* Snapshot of n_force_qs at */
 						/*  GP start. */
-	unsigned long gp_max;			/* Maximum GP duration in */
-						/*  jiffies. */
 	const char *name;			/* Name of structure. */
 	char abbr;				/* Abbreviated name. */
 
Signature · 1 line
2.20.1 (Apple Git-117)
author
#2 lore raw

PATCH 2/4 rcu: grplo/grphi just records CPU number

In reply to Wei Yang

We store lowest and highest CPU number belongs to a rcu_node, which is not the group number.

---
 kernel/rcu/tree.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/tree.h +2 -2
index ed9b534ad870..ce9ab7371706 100644
@@ -73,8 +73,8 @@ struct rcu_node {
 	unsigned long ffmask;	/* Fully functional CPUs. */
 	unsigned long grpmask;	/* Mask to apply to parent qsmask. */
 				/*  Only one bit will be set in this mask. */
-	int	grplo;		/* lowest-numbered CPU or group here. */
-	int	grphi;		/* highest-numbered CPU or group here. */
+	int	grplo;		/* lowest-numbered CPU here. */
+	int	grphi;		/* highest-numbered CPU here. */
 	u8	grpnum;		/* CPU/group number for next level up. */
 	u8	level;		/* root is at level 0. */
 	bool	wait_blkd_tasks;/* Necessary to wait for blocked tasks to */
Signature · 1 line
2.20.1 (Apple Git-117)
author
#3 lore raw

PATCH 3/4 rcu: grpnum just records group number

In reply to Wei Yang

grpnum in rcu_node means the position in its parent, which is not the CPU number even in last level.

---
 kernel/rcu/tree.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree.h +1 -1
index ce9ab7371706..512829eed545 100644
@@ -75,7 +75,7 @@ struct rcu_node {
 				/*  Only one bit will be set in this mask. */
 	int	grplo;		/* lowest-numbered CPU here. */
 	int	grphi;		/* highest-numbered CPU here. */
-	u8	grpnum;		/* CPU/group number for next level up. */
+	u8	grpnum;		/* group number for next level up. */
 	u8	level;		/* root is at level 0. */
 	bool	wait_blkd_tasks;/* Necessary to wait for blocked tasks to */
 				/*  exit RCU read-side critical sections */
Signature · 1 line
2.20.1 (Apple Git-117)
author
#4 lore raw

PATCH 4/4 rcu: use gp_seq instead of rcu_gp_seq for consistency

In reply to Wei Yang

Commit de30ad512a66 ("rcu: Introduce grace-period sequence numbers") introduce gp_seq in rcu_state/rcu_node/rcu_data. And this field in last two structure track the one in first.

While the comment use rcu_gp_seq which is a little misleading for audience. Let's use the exact name gp_seq for consistency.

---
 kernel/rcu/tree.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/tree.h +2 -2
index 512829eed545..3356842bc185 100644
@@ -41,7 +41,7 @@ struct rcu_node {
 	raw_spinlock_t __private lock;	/* Root rcu_node's lock protects */
 					/*  some rcu_state fields as well as */
 					/*  following. */
-	unsigned long gp_seq;	/* Track rsp->rcu_gp_seq. */
+	unsigned long gp_seq;	/* Track rsp->gp_seq. */
 	unsigned long gp_seq_needed; /* Track furthest future GP request. */
 	unsigned long completedqs; /* All QSes done for this node. */
 	unsigned long qsmask;	/* CPUs or groups that need to switch in */
@@ -149,7 +149,7 @@ union rcu_noqs {
 /* Per-CPU data for read-copy update. */
 struct rcu_data {
 	/* 1) quiescent-state and grace-period handling : */
-	unsigned long	gp_seq;		/* Track rsp->rcu_gp_seq counter. */
+	unsigned long	gp_seq;		/* Track rsp->gp_seq. */
 	unsigned long	gp_seq_needed;	/* Track furthest future GP request. */
 	union rcu_noqs	cpu_no_qs;	/* No QSes yet for this CPU. */
 	bool		core_needs_qs;	/* Core waits for quiesc state. */
Signature · 1 line
2.20.1 (Apple Git-117)
maintainer Applied
#5 lore raw

Re: [PATCH 4/4] rcu: use gp_seq instead of rcu_gp_seq for consistency

Quoted 8 lines · Wei Yang

Commit de30ad512a66 ("rcu: Introduce grace-period sequence numbers") introduce gp_seq in rcu_state/rcu_node/rcu_data. And this field in last two structure track the one in first.

While the comment use rcu_gp_seq which is a little misleading for audience. Let's use the exact name gp_seq for consistency.

I applied and pushed the others -- good eyes, and thank you!

This one does not apply. Could you please forward-port it to the "dev" branch of -rcu?

git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git

Thanx, Paul

Quoted 29 lines
---
 kernel/rcu/tree.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/tree.h +2 -2
index 512829eed545..3356842bc185 100644
@@ -41,7 +41,7 @@ struct rcu_node {
 	raw_spinlock_t __private lock;	/* Root rcu_node's lock protects */
 					/*  some rcu_state fields as well as */
 					/*  following. */
-	unsigned long gp_seq;	/* Track rsp->rcu_gp_seq. */
+	unsigned long gp_seq;	/* Track rsp->gp_seq. */
 	unsigned long gp_seq_needed; /* Track furthest future GP request. */
 	unsigned long completedqs; /* All QSes done for this node. */
 	unsigned long qsmask;	/* CPUs or groups that need to switch in */
@@ -149,7 +149,7 @@ union rcu_noqs {
 /* Per-CPU data for read-copy update. */
 struct rcu_data {
 	/* 1) quiescent-state and grace-period handling : */
-	unsigned long	gp_seq;		/* Track rsp->rcu_gp_seq counter. */
+	unsigned long	gp_seq;		/* Track rsp->gp_seq. */
 	unsigned long	gp_seq_needed;	/* Track furthest future GP request. */
 	union rcu_noqs	cpu_no_qs;	/* No QSes yet for this CPU. */
 	bool		core_needs_qs;	/* Core waits for quiesc state. */
Signature · 1 line
2.20.1 (Apple Git-117)
#6 lore raw

Re: [PATCH 4/4] rcu: use gp_seq instead of rcu_gp_seq for consistency

Quoted 8 lines · Paul E. McKenney
Quoted 7 lines · Wei Yang

Commit de30ad512a66 ("rcu: Introduce grace-period sequence numbers") introduce gp_seq in rcu_state/rcu_node/rcu_data. And this field in last two structure track the one in first.

While the comment use rcu_gp_seq which is a little misleading for audience. Let's use the exact name gp_seq for consistency.

Quoted 7 lines
Quoted 1 line

I applied and pushed the others -- good eyes, and thank you!

This one does not apply. Could you please forward-port it to the "dev" branch of -rcu?

The reason is someone has already fixed this :-)

Quoted 33 lines

git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git

Thanx, Paul

Quoted 29 lines
---
 kernel/rcu/tree.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/tree.h +2 -2
index 512829eed545..3356842bc185 100644
@@ -41,7 +41,7 @@ struct rcu_node {
 	raw_spinlock_t __private lock;	/* Root rcu_node's lock protects */
 					/*  some rcu_state fields as well as */
 					/*  following. */
-	unsigned long gp_seq;	/* Track rsp->rcu_gp_seq. */
+	unsigned long gp_seq;	/* Track rsp->gp_seq. */
 	unsigned long gp_seq_needed; /* Track furthest future GP request. */
 	unsigned long completedqs; /* All QSes done for this node. */
 	unsigned long qsmask;	/* CPUs or groups that need to switch in */
@@ -149,7 +149,7 @@ union rcu_noqs {
 /* Per-CPU data for read-copy update. */
 struct rcu_data {
 	/* 1) quiescent-state and grace-period handling : */
-	unsigned long	gp_seq;		/* Track rsp->rcu_gp_seq counter. */
+	unsigned long	gp_seq;		/* Track rsp->gp_seq. */
 	unsigned long	gp_seq_needed;	/* Track furthest future GP request. */
 	union rcu_noqs	cpu_no_qs;	/* No QSes yet for this CPU. */
 	bool		core_needs_qs;	/* Core waits for quiesc state. */
Signature · 1 line
2.20.1 (Apple Git-117)
Signature · 2 lines
Wei Yang
Help you, Help me
maintainer
#7 lore raw

Re: [PATCH 4/4] rcu: use gp_seq instead of rcu_gp_seq for consistency

Quoted 9 lines · Wei Yang
Quoted 8 lines · Paul E. McKenney
Quoted 7 lines · Wei Yang

Commit de30ad512a66 ("rcu: Introduce grace-period sequence numbers") introduce gp_seq in rcu_state/rcu_node/rcu_data. And this field in last two structure track the one in first.

While the comment use rcu_gp_seq which is a little misleading for audience. Let's use the exact name gp_seq for consistency.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I applied and pushed the others -- good eyes, and thank you!

This one does not apply. Could you please forward-port it to the "dev" branch of -rcu?

The reason is someone has already fixed this :-)

That would explain it! ;-)

Thanx, Paul

Quoted 37 lines
Quoted 33 lines

git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git

Thanx, Paul

Quoted 29 lines
---
 kernel/rcu/tree.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/tree.h +2 -2
index 512829eed545..3356842bc185 100644
@@ -41,7 +41,7 @@ struct rcu_node {
 	raw_spinlock_t __private lock;	/* Root rcu_node's lock protects */
 					/*  some rcu_state fields as well as */
 					/*  following. */
-	unsigned long gp_seq;	/* Track rsp->rcu_gp_seq. */
+	unsigned long gp_seq;	/* Track rsp->gp_seq. */
 	unsigned long gp_seq_needed; /* Track furthest future GP request. */
 	unsigned long completedqs; /* All QSes done for this node. */
 	unsigned long qsmask;	/* CPUs or groups that need to switch in */
@@ -149,7 +149,7 @@ union rcu_noqs {
 /* Per-CPU data for read-copy update. */
 struct rcu_data {
 	/* 1) quiescent-state and grace-period handling : */
-	unsigned long	gp_seq;		/* Track rsp->rcu_gp_seq counter. */
+	unsigned long	gp_seq;		/* Track rsp->gp_seq. */
 	unsigned long	gp_seq_needed;	/* Track furthest future GP request. */
 	union rcu_noqs	cpu_no_qs;	/* No QSes yet for this CPU. */
 	bool		core_needs_qs;	/* Core waits for quiesc state. */
Signature · 1 line
2.20.1 (Apple Git-117)
Signature · 2 lines
Wei Yang
Help you, Help me