lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 14 May 2020 01:03:31 +0200
From:   Frederic Weisbecker <frederic@...nel.org>
To:     "Paul E. McKenney" <paulmck@...nel.org>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
        Lai Jiangshan <jiangshanlai@...il.com>,
        Joel Fernandes <joel@...lfernandes.org>,
        Josh Triplett <josh@...htriplett.org>
Subject: Re: [PATCH 04/10] rcu: Implement rcu_segcblist_is_offloaded() config
 dependent

On Wed, May 13, 2020 at 11:20:29AM -0700, Paul E. McKenney wrote:
> On Wed, May 13, 2020 at 06:47:08PM +0200, Frederic Weisbecker wrote:
> > This simplify the usage of this API and avoid checking the kernel
> > config from the callers.
> > 
> > Signed-off-by: Frederic Weisbecker <frederic@...nel.org>
> > Cc: Paul E. McKenney <paulmck@...nel.org>
> > Cc: Josh Triplett <josh@...htriplett.org>
> > Cc: Steven Rostedt <rostedt@...dmis.org>
> > Cc: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
> > Cc: Lai Jiangshan <jiangshanlai@...il.com>
> > Cc: Joel Fernandes <joel@...lfernandes.org>
> > ---
> >  include/linux/rcu_segcblist.h |  2 ++
> >  kernel/rcu/rcu_segcblist.c    |  2 ++
> >  kernel/rcu/rcu_segcblist.h    |  6 ++++++
> >  kernel/rcu/tree.c             | 21 +++++++--------------
> >  4 files changed, 17 insertions(+), 14 deletions(-)
> > 
> > diff --git a/include/linux/rcu_segcblist.h b/include/linux/rcu_segcblist.h
> > index b36afe7b22c9..0ced0a0ecbcf 100644
> > --- a/include/linux/rcu_segcblist.h
> > +++ b/include/linux/rcu_segcblist.h
> > @@ -73,7 +73,9 @@ struct rcu_segcblist {
> >  	long len;
> >  #endif
> >  	u8 enabled;
> > +#ifdef CONFIG_RCU_NOCB_CPU
> >  	u8 offloaded;
> > +#endif
> 
> Given that this is only one byte and that removing it won't actually
> save any memory on most architectures, why not just leave it and
> adjust as shown below?

Right, the point was to make it private to that config and trigger
a build error otherwise. But if we have an off case that's fine.

> 
> >  };
> >  
> >  #define RCU_SEGCBLIST_INITIALIZER(n) \
> > diff --git a/kernel/rcu/rcu_segcblist.c b/kernel/rcu/rcu_segcblist.c
> > index 9a0f66133b4b..d8ea2bef5574 100644
> > --- a/kernel/rcu/rcu_segcblist.c
> > +++ b/kernel/rcu/rcu_segcblist.c
> > @@ -166,6 +166,7 @@ void rcu_segcblist_disable(struct rcu_segcblist *rsclp)
> >  	rsclp->enabled = 0;
> >  }
> >  
> > +#ifdef CONFIG_RCU_NOCB_CPU
> >  /*
> >   * Mark the specified rcu_segcblist structure as offloaded.  This
> >   * structure must be empty.
> > @@ -174,6 +175,7 @@ void rcu_segcblist_offload(struct rcu_segcblist *rsclp)
> >  {
> >  	rsclp->offloaded = 1;
> >  }
> > +#endif
> 
> Leave this unconditional, as it is nowhere near a fastpath.

The point was to not raise false hopes to those who want to
offload when it's not supported.

Let's perhaps have at least a WARN_ON_ONCE(1) if it is called
when !CONFIG_RCU_NOCB_CPU ?

> 
> >  /*
> >   * Does the specified rcu_segcblist structure contain callbacks that
> > diff --git a/kernel/rcu/rcu_segcblist.h b/kernel/rcu/rcu_segcblist.h
> > index 5c293afc07b8..4c1503a82492 100644
> > --- a/kernel/rcu/rcu_segcblist.h
> > +++ b/kernel/rcu/rcu_segcblist.h
> > @@ -62,7 +62,11 @@ static inline bool rcu_segcblist_is_enabled(struct rcu_segcblist *rsclp)
> >  /* Is the specified rcu_segcblist offloaded?  */
> >  static inline bool rcu_segcblist_is_offloaded(struct rcu_segcblist *rsclp)
> >  {
> > +#ifdef CONFIG_RCU_NOCB_CPU
> >  	return rsclp->offloaded;
> > +#else
> > +	return false;
> > +#endif
> >  }
> 
> Then this can just be:
> 
> 	return IS_ENABLED(CONFIG_RCU_NOCB_CPU) && rsclp->offloaded;

Ok.

> > @@ -1401,8 +1401,7 @@ static bool __note_gp_changes(struct rcu_node *rnp, struct rcu_data *rdp)
> >  {
> >  	bool ret = false;
> >  	bool need_qs;
> > -	const bool offloaded = IS_ENABLED(CONFIG_RCU_NOCB_CPU) &&
> > -			       rcu_segcblist_is_offloaded(&rdp->cblist);
> > +	const bool offloaded = rcu_segcblist_is_offloaded(&rdp->cblist);
> 
> The adjustment to rcu_segcblist_is_offloaded() allows this (welcome!)
> simplification to remain.

Ok thanks!

> > @@ -3243,8 +3237,7 @@ static int rcu_pending(int user)
> >  
> >  	/* Has RCU gone idle with this CPU needing another grace period? */
> >  	if (!gp_in_progress && rcu_segcblist_is_enabled(&rdp->cblist) &&
> > -	    (!IS_ENABLED(CONFIG_RCU_NOCB_CPU) ||
> > -	     !rcu_segcblist_is_offloaded(&rdp->cblist)) &&
> > +	    !rcu_segcblist_is_offloaded(&rdp->cblist) &&
> 
> Ditto.
> 
> As in "Why didn't I do it that way to start with???"  ;-)

You say that to someone who's too lazy to script short commands typed
100 times a day ;-)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ