Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2953202imm; Thu, 24 May 2018 19:47:50 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqDmLkKwz6kYbXPspHwrGuMOH+C1c3G8spxFWGcjWf7Rb+7e3NijQaVnV3mHFsZPRSeFuS4 X-Received: by 2002:a17:902:a703:: with SMTP id w3-v6mr632731plq.111.1527216470512; Thu, 24 May 2018 19:47:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527216470; cv=none; d=google.com; s=arc-20160816; b=oJYi0UYfcIFH1PaM+Yp6aDZ0EDGa6R4mESgYiL1g+gf3j7mg3CVH6XrOk7duIQN6iZ nfE+udVSl+QuusvC7CBUjl/AuNe/qyGYdQLR4GGY/TwUG9zyXE3y2ITcJIbrAsIwW81Z BfoXN1P2wuA8v70HCXmQU3ya50iGw4IzT6h9wzoujeF/f7ejwtjH1yQK7JUAcAVXlLu/ S651qfZ6OyNZXv6Clz1BAYhQWBUegXc/ql5CgztqiCioGjIpngbLdqt58CLb10piiZdc B6RKSTH6Dv3pM+HrMYLsYnHRx3B2+Sd601nGQcKbs2CPmNQA7rkONUHw3VOC0/zpn0ka FCIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=MDhEJUV6CAqaPBOFZr3DoiTlFcWxWosgBLcwI8mjnj8=; b=MEGmRGBHIv/XLVbZYIb88bhKLG5NFdZ6zJbr+d+NMfj7qi8bL4/uvJjcimEfqs+R0h +8OWHvB/60XuKx2feXMYJuc5sDvrzctwFbFyV5huI4okyW9GVbnd+hwW7hSmlAdnnzZM cOTode4ILak/q8cSeqRejzF50Qc73n8weGRNG/ndZA0paGkwzaDaRZK7jx4/aDFjQcV+ acPTpiVi3R51v2JCuWKBN+t3xyrKwJcZ7FjA7oTlZvmvVqDXcNQ+S0NYua1wjHzcvJTE gjj3Hm9VAfe5uLz6+T7J6jyIHUMP3jKLRWgpvYIdYx/2LN8AuYkALeUtfy2fnpUJiGBS YcFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=jTZ7IJ9R; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n10-v6si22090452pfe.70.2018.05.24.19.47.35; Thu, 24 May 2018 19:47:50 -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; dkim=pass header.i=@joelfernandes.org header.s=google header.b=jTZ7IJ9R; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965646AbeEXXTV (ORCPT + 99 others); Thu, 24 May 2018 19:19:21 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:35258 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964852AbeEXXTU (ORCPT ); Thu, 24 May 2018 19:19:20 -0400 Received: by mail-pf0-f194.google.com with SMTP id x9-v6so1621653pfm.2 for ; Thu, 24 May 2018 16:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=MDhEJUV6CAqaPBOFZr3DoiTlFcWxWosgBLcwI8mjnj8=; b=jTZ7IJ9RxTVwDzzyEPOidtEUmlcTVQ42ySqCr3ZYENUC3xGqZu13MSWX/zQgIa7KhA VJTmQl1+ONphXV0Ks3SXPyJCok4ODk3v124gOEl6V6OHk4DHTtm62ExnFtcwqqneNChD jX8wyXmMt6hT+NWdgnXMuEo6/eb7urPZsbKpg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=MDhEJUV6CAqaPBOFZr3DoiTlFcWxWosgBLcwI8mjnj8=; b=c1lQQlLsx0idgA8z50A0mtNvPG8Ai4zryn056QqYAnY/3PPDdjsz6QyWQ6EKwvOZXj 6tVUEpJsZTqGt+0dvR9moUgQiFwGlmAFJQ/ol+e3OxbjqdzLTIUddatP5Qj/W19TNpOV 2N7z7HHxgAiU+Uzrf+noAD1cikOehc+cwerV+J0Vz9HKvYZZgv2WDvj/ebztU/IXTqEu G0asNAgmJ2FskHAIO3ZRJAxnIzDb2OX/WpTruoB8fmM65aCTzom1whHs34EOZEmrtSPJ DBMJhrywYsB3QECdh8y/IzLhmzEjliKk6kDwKvlKmzdgjtO9hFFMdMuQcQg3pYAihyo8 SETw== X-Gm-Message-State: ALKqPwejkiVirUZHLfGjLPjzS6whpv3rU+3ReCYCXBaGs4txF+ICaYrQ AZNJow4XZrA440pb/zHNzlwQNA== X-Received: by 2002:a63:990a:: with SMTP id d10-v6mr20703pge.166.1527203959673; Thu, 24 May 2018 16:19:19 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id n67-v6sm57924376pfh.188.2018.05.24.16.19.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 May 2018 16:19:19 -0700 (PDT) Date: Thu, 24 May 2018 16:19:18 -0700 From: Joel Fernandes To: Steven Rostedt Cc: LKML , "Paul E. McKenney" , 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 Message-ID: <20180524231918.GA98334@joelaf.mtv.corp.google.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.9.2 (2017-12-15) 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. Should be 90% of original? > > 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) > --- > 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--; > + Other than minor change log change, looks good to me: Reviewed-by: Joel Fernandes (Google) thanks, - Joel