From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757872AbdDRRud (ORCPT ); Tue, 18 Apr 2017 13:50:33 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:32977 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753042AbdDRRua (ORCPT ); Tue, 18 Apr 2017 13:50:30 -0400 Date: Tue, 18 Apr 2017 10:50:25 -0700 From: "Paul E. McKenney" To: Marc Zyngier Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC srcu] Expedite srcu_schedule_cbs_snp() callback invocation Reply-To: paulmck@linux.vnet.ibm.com References: <20170418173347.GA9240@linux.vnet.ibm.com> <5b683054-084a-fae7-0bc6-8db28f0860c3@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5b683054-084a-fae7-0bc6-8db28f0860c3@arm.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 17041817-2213-0000-0000-00000196463E X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006936; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000208; SDB=6.00849229; UDB=6.00419313; IPR=6.00627869; BA=6.00005298; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015086; XFM=3.00000013; UTC=2017-04-18 17:50:27 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17041817-2214-0000-0000-000055956274 Message-Id: <20170418175025.GX3956@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-04-18_15:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1704180140 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 18, 2017 at 06:43:05PM +0100, Marc Zyngier wrote: > On 18/04/17 18:33, Paul E. McKenney wrote: > > Although Tree SRCU does reduce delays when there is at least one > > synchronize_srcu_expedited() invocation pending, srcu_schedule_cbs_snp() > > still waits for SRCU_INTERVAL before invoking callbacks. Since > > synchronize_srcu_expedited() now posts a callback and waits for > > that callback to do a wakeup, this destroys the expedited nature of > > synchronize_srcu_expedited(). > > > > This commit therefore invokes callbacks immediately at the end of the > > grace period when there is at least one synchronize_srcu_expedited() > > invocation pending. > > > > Reported-by: Marc Zyngier > > Signed-off-by: Paul E. McKenney > > > > diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c > > index 1e54f91c2ff7..744ffdb79d23 100644 > > --- a/kernel/rcu/srcutree.c > > +++ b/kernel/rcu/srcutree.c > > @@ -447,7 +447,8 @@ static void srcu_schedule_cbs_snp(struct srcu_struct *sp, struct srcu_node *snp) > > int cpu; > > > > for (cpu = snp->grplo; cpu <= snp->grphi; cpu++) > > - srcu_schedule_cbs_sdp(per_cpu_ptr(sp->sda, cpu), SRCU_INTERVAL); > > + srcu_schedule_cbs_sdp(per_cpu_ptr(sp->sda, cpu), > > + atomic_read(&sp->srcu_exp_cnt) ? 0 : SRCU_INTERVAL); > > } > > > > /* > > This fixes the issue I was observing, where UEFI in a KVM guest would > take a x8 slowdown while it messes with some NOR flash emulation on > arm64 (don't ask, this is horrible...). Anyway: > > Tested-by: Marc Zyngier > > Thanks again Paul! Thank you for your bug-finding and testing efforts! I will be pushing this into the upcoming merge window. Thanx, Paul ------------------------------------------------------------------------ commit 6eec94fe40e294b04d32c8ef552e28fa6159bdad Author: Paul E. McKenney Date: Tue Apr 18 10:28:31 2017 -0700 srcu: Expedite srcu_schedule_cbs_snp() callback invocation Although Tree SRCU does reduce delays when there is at least one synchronize_srcu_expedited() invocation pending, srcu_schedule_cbs_snp() still waits for SRCU_INTERVAL before invoking callbacks. Since synchronize_srcu_expedited() now posts a callback and waits for that callback to do a wakeup, this destroys the expedited nature of synchronize_srcu_expedited(). This destruction became apparent to Marc Zyngier in the guise of a guest-OS bootup slowdown from five seconds to no fewer than forty seconds. This commit therefore invokes callbacks immediately at the end of the grace period when there is at least one synchronize_srcu_expedited() invocation pending. This brought Marc's guest-OS bootup times back into the realm of reason. Reported-by: Marc Zyngier Signed-off-by: Paul E. McKenney Tested-by: Marc Zyngier diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index 1e54f91c2ff7..744ffdb79d23 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -447,7 +447,8 @@ static void srcu_schedule_cbs_snp(struct srcu_struct *sp, struct srcu_node *snp) int cpu; for (cpu = snp->grplo; cpu <= snp->grphi; cpu++) - srcu_schedule_cbs_sdp(per_cpu_ptr(sp->sda, cpu), SRCU_INTERVAL); + srcu_schedule_cbs_sdp(per_cpu_ptr(sp->sda, cpu), + atomic_read(&sp->srcu_exp_cnt) ? 0 : SRCU_INTERVAL); } /*