Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3290258imm; Tue, 17 Jul 2018 02:12:15 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeB6dl6UJ6UNuCZZYflqTdb5xGHEfyEOutqBcC/7VP2/iywUPPZ5KpQHsf5jwVEMET0j/C+ X-Received: by 2002:a17:902:123:: with SMTP id 32-v6mr798433plb.181.1531818735002; Tue, 17 Jul 2018 02:12:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531818734; cv=none; d=google.com; s=arc-20160816; b=EDZt+AddDxEh/ZKVNiichABduhW+aaVg4REx6SOYM7JS4ne5B8SMKSH3JghFj6L9hG FesuKT6eR8OxE4ed7EwrDi6EjhoPuzIq+GSY4cGdWA3TB+crGQIXrGK/1id3RFJb3756 8SAToj46G64rJ7ZB5SHy65ZZqfiqyjyLSUbn/YQfPp8Z1aTuqwNOel8TGHMM1FFsX0hg hXrmngvyRDKkS/TndVNwQhqh/GMTbF+4mZR3d40Dl7PrZO2wk0kv9HjPgOUm6YD7K1zr unxG/6N8amzchK2nvsUJAGrWteZZ9cvPGefadi5MNIq/KICHpdhVplCCmTz5553e6f/E Hkmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=4qv8vsDfwZGjcr0vNCJWyv+vYOFqWrZgFLJ4dijkUf8=; b=TxKPvPmP48o7WVXgY/7GGYuDue21Owsu9c4MBmKwawzR09tWScLxhY8EukOAuVAxhc F6v8ckEgWig+xM9Yr5UDEDFsa1lINwNBcfNLG/IfzdYaG9IHV+/4Vtg9AxwXigCl1v7Q nOgX8TkrmK4Zncf2Z57FCFQbTWA/sVTt3qGi3++sNmF7sQZZtdNqPl3X3FaAylcL/Dse EXdMvk/NyhCJzKbx8AJmpwqXIgszpsYHasqSEry4H6QvSFFHPeGB6RE4xCgyq3k/K+8w j7I/RsSDjcGTNCnnKGC35KleCatSfrffPkcO1ZzCNfHCdx8Alewjrr255OHjE8G/FssQ c4KA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 44-v6si421804plb.376.2018.07.17.02.11.59; Tue, 17 Jul 2018 02:12:14 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729640AbeGQJmz (ORCPT + 99 others); Tue, 17 Jul 2018 05:42:55 -0400 Received: from terminus.zytor.com ([198.137.202.136]:41725 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728089AbeGQJmz (ORCPT ); Tue, 17 Jul 2018 05:42:55 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w6H9BBaN1458641 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 17 Jul 2018 02:11:11 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w6H9BAA21458638; Tue, 17 Jul 2018 02:11:10 -0700 Date: Tue, 17 Jul 2018 02:11:10 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: "tip-bot for Steven Rostedt (VMware)" Message-ID: Cc: hpa@zytor.com, rostedt@goodmis.org, mingo@kernel.org, paulmck@linux.vnet.ibm.com, tglx@linutronix.de, joel@joelfernandes.org, linux-kernel@vger.kernel.org Reply-To: linux-kernel@vger.kernel.org, joel@joelfernandes.org, tglx@linutronix.de, paulmck@linux.vnet.ibm.com, mingo@kernel.org, rostedt@goodmis.org, hpa@zytor.com In-Reply-To: <20180523063815.198302-2-joel@joelfernandes.org> References: <20180523063815.198302-2-joel@joelfernandes.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:core/rcu] rcu: Speed up calling of RCU tasks callbacks Git-Commit-ID: c03be752d39dc64dcfda0ac8ce87fb10b1ee5621 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: c03be752d39dc64dcfda0ac8ce87fb10b1ee5621 Gitweb: https://git.kernel.org/tip/c03be752d39dc64dcfda0ac8ce87fb10b1ee5621 Author: Steven Rostedt (VMware) AuthorDate: Thu, 24 May 2018 18:49:46 -0400 Committer: Paul E. McKenney CommitDate: Thu, 12 Jul 2018 15:39:21 -0700 rcu: Speed up calling of RCU tasks callbacks 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) Signed-off-by: Paul E. McKenney --- kernel/rcu/update.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c index 5783bdf86e5a..4c7c49c106ee 100644 --- a/kernel/rcu/update.c +++ b/kernel/rcu/update.c @@ -668,6 +668,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); @@ -749,13 +750,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);