diff mbox series

[1/3] srcu: Eliminate the requirement of SRCU_SIZE_WAIT_CALL

Message ID 20221128082816.28518-2-kernelfans@gmail.com (mailing list archive)
State New, archived
Headers show
Series srcu: shrink the num of srcu_size_state | expand

Commit Message

Pingfan Liu Nov. 28, 2022, 8:28 a.m. UTC
The state SRCU_SIZE_WAIT_CALL is only used in srcu_gp_start_if_needed().
And it is not needed. Because counter_wrap_check has guarantee that both
srcu_gp_seq_needed and srcu_gp_seq_needed_exp are not far behind
srcu_gp_seq and no false alarm will be raised by the statement in
srcu_gp_start_if_needed()

  ULONG_CMP_LT(sdp->srcu_gp_seq_needed, s)

As a result, once if SRCU_SIZE_WAIT_BARRIER is seen, the tree snp can be
used immediately, not need to wait for another srcu_gp_end() to update
the srcu_gp_seq_needed and srcu_gp_seq_needed_exp to avoid false alarm.

Signed-off-by: Pingfan Liu <kernelfans@gmail.com>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: "Paul E. McKenney" <paulmck@kernel.org>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: "Zhang, Qiang1" <qiang1.zhang@intel.com>
To: rcu@vger.kernel.org
---
 kernel/rcu/srcutree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Zqiang Nov. 28, 2022, 8:40 a.m. UTC | #1
>The state SRCU_SIZE_WAIT_CALL is only used in srcu_gp_start_if_needed().
>And it is not needed. Because counter_wrap_check has guarantee that both
>srcu_gp_seq_needed and srcu_gp_seq_needed_exp are not far behind
>srcu_gp_seq and no false alarm will be raised by the statement in
>srcu_gp_start_if_needed()
>
>  ULONG_CMP_LT(sdp->srcu_gp_seq_needed, s)
>
>As a result, once if SRCU_SIZE_WAIT_BARRIER is seen, the tree snp can be
>used immediately, not need to wait for another srcu_gp_end() to update
>the srcu_gp_seq_needed and srcu_gp_seq_needed_exp to avoid false alarm.
>
>Signed-off-by: Pingfan Liu <kernelfans@gmail.com>
>Cc: Lai Jiangshan <jiangshanlai@gmail.com>
>Cc: "Paul E. McKenney" <paulmck@kernel.org>
>Cc: Frederic Weisbecker <frederic@kernel.org>
>Cc: Josh Triplett <josh@joshtriplett.org>
>Cc: Steven Rostedt <rostedt@goodmis.org>
>Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
>Cc: "Zhang, Qiang1" <qiang1.zhang@intel.com>
>To: rcu@vger.kernel.org
>---
> kernel/rcu/srcutree.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
>index 1c304fec89c0..fe0759d89c2d 100644
>--- a/kernel/rcu/srcutree.c
>+++ b/kernel/rcu/srcutree.c
>@@ -1092,7 +1092,7 @@ static unsigned long srcu_gp_start_if_needed(struct srcu_struct *ssp,
> 	check_init_srcu_struct(ssp);
> 	idx = srcu_read_lock(ssp);
> 	ss_state = smp_load_acquire(&ssp->srcu_size_state);
>-	if (ss_state < SRCU_SIZE_WAIT_CALL)
>+	if (ss_state < SRCU_SIZE_WAIT_BARRIER)
> 		sdp = per_cpu_ptr(ssp->sda, 0);

Hi Pingfan

should it be used get_boot_cpu_id() ?

Thanks
Zqiang

> 	else
> 		sdp = raw_cpu_ptr(ssp->sda);
>-- 
>2.31.1
>
Pingfan Liu Nov. 28, 2022, 2:01 p.m. UTC | #2
On Mon, Nov 28, 2022 at 08:40:22AM +0000, Zhang, Qiang1 wrote:
> >The state SRCU_SIZE_WAIT_CALL is only used in srcu_gp_start_if_needed().
> >And it is not needed. Because counter_wrap_check has guarantee that both
> >srcu_gp_seq_needed and srcu_gp_seq_needed_exp are not far behind
> >srcu_gp_seq and no false alarm will be raised by the statement in
> >srcu_gp_start_if_needed()
> >
> >  ULONG_CMP_LT(sdp->srcu_gp_seq_needed, s)
> >
> >As a result, once if SRCU_SIZE_WAIT_BARRIER is seen, the tree snp can be
> >used immediately, not need to wait for another srcu_gp_end() to update
> >the srcu_gp_seq_needed and srcu_gp_seq_needed_exp to avoid false alarm.
> >
> >Signed-off-by: Pingfan Liu <kernelfans@gmail.com>
> >Cc: Lai Jiangshan <jiangshanlai@gmail.com>
> >Cc: "Paul E. McKenney" <paulmck@kernel.org>
> >Cc: Frederic Weisbecker <frederic@kernel.org>
> >Cc: Josh Triplett <josh@joshtriplett.org>
> >Cc: Steven Rostedt <rostedt@goodmis.org>
> >Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> >Cc: "Zhang, Qiang1" <qiang1.zhang@intel.com>
> >To: rcu@vger.kernel.org
> >---
> > kernel/rcu/srcutree.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> >diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
> >index 1c304fec89c0..fe0759d89c2d 100644
> >--- a/kernel/rcu/srcutree.c
> >+++ b/kernel/rcu/srcutree.c
> >@@ -1092,7 +1092,7 @@ static unsigned long srcu_gp_start_if_needed(struct srcu_struct *ssp,
> > 	check_init_srcu_struct(ssp);
> > 	idx = srcu_read_lock(ssp);
> > 	ss_state = smp_load_acquire(&ssp->srcu_size_state);
> >-	if (ss_state < SRCU_SIZE_WAIT_CALL)
> >+	if (ss_state < SRCU_SIZE_WAIT_BARRIER)
> > 		sdp = per_cpu_ptr(ssp->sda, 0);
> 
> Hi Pingfan
> 
> should it be used get_boot_cpu_id() ?
> 

I am not sure which branch to work on.

Thanks,

	Pingfan

> Thanks
> Zqiang
> 
> > 	else
> > 		sdp = raw_cpu_ptr(ssp->sda);
> >-- 
> >2.31.1
> >
Paul E. McKenney Nov. 29, 2022, 12:41 a.m. UTC | #3
On Mon, Nov 28, 2022 at 10:01:08PM +0800, Pingfan Liu wrote:
> On Mon, Nov 28, 2022 at 08:40:22AM +0000, Zhang, Qiang1 wrote:
> > >The state SRCU_SIZE_WAIT_CALL is only used in srcu_gp_start_if_needed().
> > >And it is not needed. Because counter_wrap_check has guarantee that both
> > >srcu_gp_seq_needed and srcu_gp_seq_needed_exp are not far behind
> > >srcu_gp_seq and no false alarm will be raised by the statement in
> > >srcu_gp_start_if_needed()
> > >
> > >  ULONG_CMP_LT(sdp->srcu_gp_seq_needed, s)
> > >
> > >As a result, once if SRCU_SIZE_WAIT_BARRIER is seen, the tree snp can be
> > >used immediately, not need to wait for another srcu_gp_end() to update
> > >the srcu_gp_seq_needed and srcu_gp_seq_needed_exp to avoid false alarm.
> > >
> > >Signed-off-by: Pingfan Liu <kernelfans@gmail.com>
> > >Cc: Lai Jiangshan <jiangshanlai@gmail.com>
> > >Cc: "Paul E. McKenney" <paulmck@kernel.org>
> > >Cc: Frederic Weisbecker <frederic@kernel.org>
> > >Cc: Josh Triplett <josh@joshtriplett.org>
> > >Cc: Steven Rostedt <rostedt@goodmis.org>
> > >Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> > >Cc: "Zhang, Qiang1" <qiang1.zhang@intel.com>
> > >To: rcu@vger.kernel.org
> > >---
> > > kernel/rcu/srcutree.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > >diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
> > >index 1c304fec89c0..fe0759d89c2d 100644
> > >--- a/kernel/rcu/srcutree.c
> > >+++ b/kernel/rcu/srcutree.c
> > >@@ -1092,7 +1092,7 @@ static unsigned long srcu_gp_start_if_needed(struct srcu_struct *ssp,
> > > 	check_init_srcu_struct(ssp);
> > > 	idx = srcu_read_lock(ssp);
> > > 	ss_state = smp_load_acquire(&ssp->srcu_size_state);
> > >-	if (ss_state < SRCU_SIZE_WAIT_CALL)
> > >+	if (ss_state < SRCU_SIZE_WAIT_BARRIER)
> > > 		sdp = per_cpu_ptr(ssp->sda, 0);
> > 
> > Hi Pingfan
> > 
> > should it be used get_boot_cpu_id() ?
> 
> I am not sure which branch to work on.

For RCU patches, the "dev" branch of the -rcu tree.

For more information, please see:

https://mirrors.edge.kernel.org/pub/linux/kernel/people/paulmck/rcutodo.html

							Thanx, Paul

> Thanks,
> 
> 	Pingfan
> 
> > Thanks
> > Zqiang
> > 
> > > 	else
> > > 		sdp = raw_cpu_ptr(ssp->sda);
> > >-- 
> > >2.31.1
> > >
diff mbox series

Patch

diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index 1c304fec89c0..fe0759d89c2d 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -1092,7 +1092,7 @@  static unsigned long srcu_gp_start_if_needed(struct srcu_struct *ssp,
 	check_init_srcu_struct(ssp);
 	idx = srcu_read_lock(ssp);
 	ss_state = smp_load_acquire(&ssp->srcu_size_state);
-	if (ss_state < SRCU_SIZE_WAIT_CALL)
+	if (ss_state < SRCU_SIZE_WAIT_BARRIER)
 		sdp = per_cpu_ptr(ssp->sda, 0);
 	else
 		sdp = raw_cpu_ptr(ssp->sda);