Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755489AbdDRAar (ORCPT ); Mon, 17 Apr 2017 20:30:47 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:53507 "EHLO relay4-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752107AbdDRAao (ORCPT ); Mon, 17 Apr 2017 20:30:44 -0400 X-Originating-IP: 50.39.160.18 Date: Mon, 17 Apr 2017 17:30:33 -0700 From: Josh Triplett To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com, bobby.prani@gmail.com Subject: Re: [PATCH v2 tip/core/rcu 03/39] srcu: Consolidate batch checking into rcu_all_batches_empty() Message-ID: <20170418003032.s26wqp2huqe7twhk@x> References: <20170417234452.GB19013@linux.vnet.ibm.com> <1492472726-3841-3-git-send-email-paulmck@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1492472726-3841-3-git-send-email-paulmck@linux.vnet.ibm.com> User-Agent: NeoMutt/20170306 (1.8.0) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1993 Lines: 57 On Mon, Apr 17, 2017 at 04:44:50PM -0700, Paul E. McKenney wrote: > The srcu_reschedule() function invokes rcu_batch_empty() on each of > the four rcu_batch structures in the srcu_struct in question twice. > Given that this check will also be needed in cleanup_srcu_struct(), this > commit consolidates these four checks into a new rcu_all_batches_empty() > function. > > Signed-off-by: Paul E. McKenney Reviewed-by: Josh Triplett > kernel/rcu/srcu.c | 21 +++++++++++++-------- > 1 file changed, 13 insertions(+), 8 deletions(-) > > diff --git a/kernel/rcu/srcu.c b/kernel/rcu/srcu.c > index ef3bcfb15b39..ba41a5d04b49 100644 > --- a/kernel/rcu/srcu.c > +++ b/kernel/rcu/srcu.c > @@ -65,6 +65,17 @@ static inline bool rcu_batch_empty(struct rcu_batch *b) > } > > /* > + * Are all batches empty for the specified srcu_struct? > + */ > +static inline bool rcu_all_batches_empty(struct srcu_struct *sp) > +{ > + return rcu_batch_empty(&sp->batch_done) && > + rcu_batch_empty(&sp->batch_check1) && > + rcu_batch_empty(&sp->batch_check0) && > + rcu_batch_empty(&sp->batch_queue); > +} > + > +/* > * Remove the callback at the head of the specified rcu_batch structure > * and return a pointer to it, or return NULL if the structure is empty. > */ > @@ -619,15 +630,9 @@ static void srcu_reschedule(struct srcu_struct *sp) > { > bool pending = true; > > - if (rcu_batch_empty(&sp->batch_done) && > - rcu_batch_empty(&sp->batch_check1) && > - rcu_batch_empty(&sp->batch_check0) && > - rcu_batch_empty(&sp->batch_queue)) { > + if (rcu_all_batches_empty(sp)) { > spin_lock_irq(&sp->queue_lock); > - if (rcu_batch_empty(&sp->batch_done) && > - rcu_batch_empty(&sp->batch_check1) && > - rcu_batch_empty(&sp->batch_check0) && > - rcu_batch_empty(&sp->batch_queue)) { > + if (rcu_all_batches_empty(sp)) { > sp->running = false; > pending = false; > } > -- > 2.5.2 >