Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760192Ab3ICSIA (ORCPT ); Tue, 3 Sep 2013 14:08:00 -0400 Received: from e35.co.us.ibm.com ([32.97.110.153]:43114 "EHLO e35.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754571Ab3ICSH7 (ORCPT ); Tue, 3 Sep 2013 14:07:59 -0400 Date: Tue, 3 Sep 2013 10:59:10 -0700 From: "Paul E. McKenney" To: Chen Gang Cc: Chen Gang F T , dipankar@in.ibm.com, "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] kernel/rcutree.c: deem to be lazy if there are no callbacks. Message-ID: <20130903175910.GX3871@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <5212E7BB.4020602@asianux.com> <20130820041832.GY29406@linux.vnet.ibm.com> <5212F3E5.7080700@asianux.com> <5212F467.8090407@asianux.com> <52145741.7000008@asianux.com> <20130821142301.GX29406@linux.vnet.ibm.com> <52157F21.5080200@asianux.com> <20130825191839.GA22515@linux.vnet.ibm.com> <521ABB9E.1050209@gmail.com> <5225766F.4000907@asianux.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5225766F.4000907@asianux.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13090318-4834-0000-0000-00000AB0B8DD Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2635 Lines: 76 On Tue, Sep 03, 2013 at 01:41:03PM +0800, Chen Gang wrote: > Hello Maintainers: > > Is this issue finished ? > > If need additional help from me (e.g. some test things, or others, if > you have no time, can let me try), please let me know, I should try. Ah, sorry, here is the patch. Thanx, Paul ------------------------------------------------------------------------ rcu: Micro-optimize rcu_cpu_has_callbacks() The for_each_rcu_flavor() loop unconditionally scans all flavors, even when the first flavor might have some non-lazy callbacks. Once the loop has seen a non-lazy callback, further passes through the loop cannot change the state. This is not a huge problem, given that there can be at most three RCU flavors (RCU-bh, RCU-preempt, and RCU-sched), but this code is on the path to idle, so speeding it up even a small amount would have some benefit. This commit therefore does two things: 1. Rearranges the order of the list of RCU flavors in order to place the most active flavor first in the list. The most active RCU flavor is RCU-preempt, or, if there is no RCU-preempt, RCU-sched. 2. Reworks the for_each_rcu_flavor() to exit early when the first non-lazy callback is seen, or, in the case where the caller does not care about non-lazy callbacks (RCU_FAST_NO_HZ=n), when the first callback is seen. Reported-by: Chen Gang Signed-off-by: Paul E. McKenney diff --git a/kernel/rcutree.c b/kernel/rcutree.c index b1b959d..38596be 100644 --- a/kernel/rcutree.c +++ b/kernel/rcutree.c @@ -2756,10 +2756,13 @@ static int rcu_cpu_has_callbacks(int cpu, bool *all_lazy) for_each_rcu_flavor(rsp) { rdp = per_cpu_ptr(rsp->rda, cpu); - if (rdp->qlen != rdp->qlen_lazy) + if (!rdp->nxtlist) + continue; + hc = true; + if (rdp->qlen != rdp->qlen_lazy || !all_lazy) { al = false; - if (rdp->nxtlist) - hc = true; + break; + } } if (all_lazy) *all_lazy = al; @@ -3326,8 +3329,8 @@ void __init rcu_init(void) rcu_bootup_announce(); rcu_init_geometry(); - rcu_init_one(&rcu_sched_state, &rcu_sched_data); rcu_init_one(&rcu_bh_state, &rcu_bh_data); + rcu_init_one(&rcu_sched_state, &rcu_sched_data); __rcu_init_preempt(); open_softirq(RCU_SOFTIRQ, rcu_process_callbacks); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/