Re: [PATCH v5 06/18] rcu: Introduce call_rcu_lazy() API implementation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Sep 21, 2022 at 11:52:45PM +0000, Joel Fernandes wrote:
[..]
> > > Anyway, for testing this should be good...
> > > 
> > > ---8<-----------------------
> > > 
> > > diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h
> > > index bd8f39ee2cd0..e3344c262672 100644
> > > --- a/kernel/rcu/tree_nocb.h
> > > +++ b/kernel/rcu/tree_nocb.h
> > > @@ -382,15 +382,19 @@ static bool rcu_nocb_flush_bypass(struct rcu_data *rdp, struct rcu_head *rhp,
> > >  				  unsigned long j, unsigned long flush_flags)
> > >  {
> > >  	bool ret;
> > > +	bool was_alldone;
> > >  
> > >  	if (!rcu_rdp_is_offloaded(rdp))
> > >  		return true;
> > >  	rcu_lockdep_assert_cblist_protected(rdp);
> > >  	rcu_nocb_bypass_lock(rdp);
> > > +	if (flush_flags & FLUSH_BP_WAKE)
> > > +		was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist);
> > > +
> > 
> > You can check that outside bypass lock (but you still need nocb_lock).
> > 
> > >  	ret = rcu_nocb_do_flush_bypass(rdp, rhp, j, flush_flags);
> > >  
> > > -	if (flush_flags & FLUSH_BP_WAKE)
> > > -		wake_nocb_gp(rdp, true);
> > > +	if (flush_flags & FLUSH_BP_WAKE && was_alldone)
> > > +		wake_nocb_gp(rdp, false);
> > 
> > That doesn't check if the bypass list was empty.
> 
> I am ending up with something like the below for v6, after discussing with
> Paul on IRC he pointed out we only need to do the rcu_barrier() related
> wakeup when all the CBs are lazy in the bypass list. Otherwise timer goes
> off. I think Frederic mentioned something similar above in different words.
> 
> I prefer to keep this logic in tree_nocb.h since rcu_barrier_entrain()
> shouldn't have to deal with nocb internals (in theory anyway).
> 
> Looks Ok?

And I did miss something so here is the updated version, testing it further
now, I think this is the last 'concern' I had before making the other API
changes we discussed so should hopefully be smooth sailing from here. Thank you!

---8<-----------------------

Subject: [PATCH for v6] fixup! rcu: Introduce call_rcu_lazy() API implementation

Signed-off-by: Joel Fernandes (Google) <joel@xxxxxxxxxxxxxxxxx>
---
 kernel/rcu/tree_nocb.h | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h
index c197534d0c99..472ceb8af6d3 100644
--- a/kernel/rcu/tree_nocb.h
+++ b/kernel/rcu/tree_nocb.h
@@ -375,18 +375,27 @@ static bool rcu_nocb_flush_bypass(struct rcu_data *rdp, struct rcu_head *rhp,
 				  unsigned long j, unsigned long flush_flags)
 {
 	bool ret;
-	bool was_alldone;
+	bool was_alldone = false;
+	bool bypass_all_lazy = false;
+	long bypass_ncbs;
 
 	if (!rcu_rdp_is_offloaded(rdp))
 		return true;
 	rcu_lockdep_assert_cblist_protected(rdp);
 	rcu_nocb_bypass_lock(rdp);
-	if (flush_flags & FLUSH_BP_WAKE)
+
+	if (flush_flags & FLUSH_BP_WAKE) {
 		was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist);
+		bypass_ncbs = rcu_cblist_n_cbs(&rdp->nocb_bypass);
+		bypass_all_lazy = bypass_ncbs && (bypass_ncbs == rdp->lazy_len);
+	}
 
 	ret = rcu_nocb_do_flush_bypass(rdp, rhp, j, flush_flags);
 
-	if (flush_flags & FLUSH_BP_WAKE && was_alldone)
+	// Wake up the nocb GP thread if needed. GP thread could be sleeping
+	// while waiting for lazy timer to expire (otherwise rcu_barrier may
+	// end up waiting for the duration of the lazy timer).
+	if (flush_flags & FLUSH_BP_WAKE && was_alldone && bypass_all_lazy)
 		wake_nocb_gp(rdp, false);
 
 	return ret;
-- 
2.37.3.998.g577e59143f-goog




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux