Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp9939imm; Fri, 25 May 2018 13:10:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrMsjFWHSnDJXJ7BYWwo/tqAk2OAD0P3wLMu2EHLjAmFcC8qOD+HFKuzRSIiRvvmx+rz2hU X-Received: by 2002:a62:4fd8:: with SMTP id f85-v6mr3964129pfj.77.1527279047714; Fri, 25 May 2018 13:10:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527279047; cv=none; d=google.com; s=arc-20160816; b=QNmeJNPMbt/EaD+AjdsoWAxVf6kO7WNd6sgrd+1Df1V6vhPHGraEDxSA+aYd4vqQrc pE41ak/VW1C8Ai7NO84K3BsDsBU2zF/j+HZ4Wh1izYe0YPcAf3fEe3PGYoSBlllH9qxJ oi1yYaoNVt1FRTTRhHf4Xt5yO+FblY1x6jE6/V5CpM9QGSaFHr5S2mNHAurV+VtqvyFJ CnNZsA/+2kxh5Ll7tiQrLk4LrHclxO3+Y6aHmNFD3L67NJRuaBqalS03SfYED6g76gAI e1NB/0XPZIEXuL7zBye4xYlNrJAJpGJtIGGCRX9wZG0/TiF9I3DZm1/9Trqf4tCg/xS5 oGeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date:arc-authentication-results; bh=hqUUETD2qJQ0Bya9Uv4elZL3lOU9T43gNqj6VtqD2L8=; b=OsYMpzriLIrxUy02fl9rLQshUePaeUVanGBYd+CWPivHOKw4q4BcZXbV/loTpmasES a1ARL/VdzyWBEF/k+GxF51X+xXeAQE3um/kXMicuIjYnhJf9bes2lzVnSIX8j+TFlwut P5XKs/2KN/nbfCjeTtyb/jTv6vYRBaK0c6JENeNsN+Nr/WeG9loshVjgizQp7tudhTSj 86LFlMoxJvXrMvDP2KiCuwiSVgy51Cfoy/WUkk3Eo4TEz/8J6vJNd2CTgYVMU2VUP3L3 CxKr15GlEu/W0ghHuC+JZTu3FTvvkZ3AiNRMAF6jUACCjbG9GbNazW/g9enB5RHXNhB0 CLyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5-v6si24632678plc.203.2018.05.25.13.10.18; Fri, 25 May 2018 13:10:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968127AbeEYUKI (ORCPT + 99 others); Fri, 25 May 2018 16:10:08 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55354 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S967879AbeEYUKH (ORCPT ); Fri, 25 May 2018 16:10:07 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4PK9mS5107899 for ; Fri, 25 May 2018 16:10:06 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0b-001b2d01.pphosted.com with ESMTP id 2j6n711g9x-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 25 May 2018 16:10:06 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 25 May 2018 16:10:05 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 25 May 2018 16:10:02 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4PKA1LG8716558 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 25 May 2018 20:10:01 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BDB98B2071; Fri, 25 May 2018 17:11:47 -0400 (EDT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9D42CB2066; Fri, 25 May 2018 17:11:47 -0400 (EDT) Received: from paulmck-ThinkPad-W541 (unknown [9.70.82.108]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 25 May 2018 17:11:47 -0400 (EDT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id 3E57316C3E74; Fri, 25 May 2018 13:11:41 -0700 (PDT) Date: Fri, 25 May 2018 13:11:41 -0700 From: "Paul E. McKenney" To: Steven Rostedt Cc: LKML , Joel Fernandes , Peter Zilstra , Ingo Molnar , Boqun Feng , byungchul.park@lge.com, kernel-team@android.com, Josh Triplett , Lai Jiangshan , Mathieu Desnoyers Subject: Re: [PATCH v4] rcu: Speed up calling of RCU tasks callbacks Reply-To: paulmck@linux.vnet.ibm.com References: <20180524184946.5fa82d19@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180524184946.5fa82d19@gandalf.local.home> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 18052520-0040-0000-0000-00000432CE98 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009083; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000262; SDB=6.01037591; UDB=6.00530820; IPR=6.00816719; MB=3.00021297; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-25 20:10:05 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18052520-0041-0000-0000-00000838EDC0 Message-Id: <20180525201141.GG3803@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-25_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805250208 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 24, 2018 at 06:49:46PM -0400, Steven Rostedt wrote: > > From: Steven Rostedt (VMware) > > Joel Fernandes found that the synchronize_rcu_tasks() was taking a > significant amount of time. He demonstrated it with the following test: > > # cd /sys/kernel/tracing > # while [ 1 ]; do x=1; done & > # echo '__schedule_bug:traceon' > set_ftrace_filter > # time echo '!__schedule_bug:traceon' > set_ftrace_filter; > > real 0m1.064s > user 0m0.000s > sys 0m0.004s > > Where it takes a little over a second to perform the synchronize, > because there's a loop that waits 1 second at a time for tasks to get > through their quiescent points when there's a task that must be waited > for. > > After discussion we came up with a simple way to wait for holdouts but > increase the time for each iteration of the loop but no more than a > full second. > > With the new patch we have: > > # time echo '!__schedule_bug:traceon' > set_ftrace_filter; > > real 0m0.131s > user 0m0.000s > sys 0m0.004s > > Which drops it down to 13% of what the original wait time was. > > Link: http://lkml.kernel.org/r/20180523063815.198302-2-joel@joelfernandes.org > Reported-by: Joel Fernandes (Google) > Suggested-by: Joel Fernandes (Google) > Signed-off-by: Steven Rostedt (VMware) I queued both commits, thank you all! Thanx, Paul > --- > diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c > index 68fa19a5e7bd..452e47841a86 100644 > --- a/kernel/rcu/update.c > +++ b/kernel/rcu/update.c > @@ -715,6 +715,7 @@ static int __noreturn rcu_tasks_kthread(void *arg) > struct rcu_head *list; > struct rcu_head *next; > LIST_HEAD(rcu_tasks_holdouts); > + int fract; > > /* Run on housekeeping CPUs by default. Sysadm can move if desired. */ > housekeeping_affine(current, HK_FLAG_RCU); > @@ -796,13 +797,25 @@ static int __noreturn rcu_tasks_kthread(void *arg) > * holdouts. When the list is empty, we are done. > */ > lastreport = jiffies; > - while (!list_empty(&rcu_tasks_holdouts)) { > + > + /* Start off with HZ/10 wait and slowly back off to 1 HZ wait*/ > + fract = 10; > + > + for (;;) { > bool firstreport; > bool needreport; > int rtst; > struct task_struct *t1; > > - schedule_timeout_interruptible(HZ); > + if (list_empty(&rcu_tasks_holdouts)) > + break; > + > + /* Slowly back off waiting for holdouts */ > + schedule_timeout_interruptible(HZ/fract); > + > + if (fract > 1) > + fract--; > + > rtst = READ_ONCE(rcu_task_stall_timeout); > needreport = rtst > 0 && > time_after(jiffies, lastreport + rtst); >