Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp7063056imm; Sun, 20 May 2018 17:46:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqKM5NrfS12ZGaht/MwltO0VBB6h6VVxFdnP3RJf514Z2dBzQ6ZyNLsply8I7+b4WTFZrpb X-Received: by 2002:a62:e53:: with SMTP id w80-v6mr18247169pfi.236.1526863572001; Sun, 20 May 2018 17:46:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526863571; cv=none; d=google.com; s=arc-20160816; b=FW9EXKeb0Cx8SQ8ZtCZX8X0cARQXXpVpvO0n490pjVUKana/TaVjyl8FuCSlGWI19q am97zXy1NnvH4ILw1CI6kbBWXt192fJ7dzgqdbZHq8jMUFI77he/CJDpPQa+apWObvhz P3vEI8eysMQqzQ8OkMjsWLOk/8eoVRV8WHtndDikKFsMIsQ7YC7Wx+/T0Bwy9iFsgC63 k5+Zr+mB+QvnMkZSPU9qvsKy77uuloNMDOjJU3l6cIkcps8TiUVL2CDFPfoXpmJxho86 QOMLLYBKdIuGIh2InHQWA5fxJOxZbLRJ/pNcN02kQXC3W0I1pJJyQ5dK3yqv5eKet/E+ 3+4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Ce5PT0g+JMvGTFIWlT/dmEQ7tjabxUF+nmm1Wg27pC4=; b=PrGexrY9uy5O45osZQNueA8wjuG6DRZrh0OBNVYfxgKz6zQp5f8+hzxWDvFUE/fsof 2Z4C4Pc5ALqqrELFK4iSd1vnW17aCXZkyyhaHE86WdOYpTvW80uFyKykTTXoW57n+oQP HDbXXaYyEXdKWvt0PktWiVtGfMXb+Js0fGW5G33vNnMZrUx8LtUQQGhje46xEWbtSnE1 NteMxwxPnF/erh2UyrzKLWl3C9WBGCOOxzo6L7APoh8Tpnm7tepWgPSSDaKyjt2EUFkv IE/sOrciN5EK4AV5YtigNaQErKCQQlT5N4fw9zknPGgIPLUSSPFxAPAop+1fnsSaE5YU 4dOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=NeBi1Qiw; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p7-v6si9979362pgd.96.2018.05.20.17.45.57; Sun, 20 May 2018 17:46:11 -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=@google.com header.s=20161025 header.b=NeBi1Qiw; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751686AbeEUAns (ORCPT + 99 others); Sun, 20 May 2018 20:43:48 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:44426 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751637AbeEUAno (ORCPT ); Sun, 20 May 2018 20:43:44 -0400 Received: by mail-pg0-f68.google.com with SMTP id c22-v6so4924133pgn.11 for ; Sun, 20 May 2018 17:43:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Ce5PT0g+JMvGTFIWlT/dmEQ7tjabxUF+nmm1Wg27pC4=; b=NeBi1QiwzklGGyJh+gNGf9xya1zVvkl2tTAHH3clW8rbVbCXqrX4uubqBtO+TuA9CB 8jWRg0CT2y7ja+hROWlDexnzG9jCAupleaCkUQMsbPjvipECwZ1MQ43btnnK3o2x78UX 3ZNSI+1m9zyH2OiCWm5TnOgdk2ZW/MZqBJ65Ejzo6gLkAEk2uB42JW+BV4p2sOOEC6YX 85tg9Se8774ivuEoCfANpygMOID1jmUK79dm8QS9ZgPcVJqOOz7jGkWpuojjh8igycDf F0lUfraJxBRxg/n7YKeIBZoLaehbYDkB6U/YGuL+1jex7Lkxn1PaoXkkSzcJYm2/XBlR iRgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Ce5PT0g+JMvGTFIWlT/dmEQ7tjabxUF+nmm1Wg27pC4=; b=pOqAZm3qSbkId3QJ7+Z6WQTX7TN+F/nXKGxk6YSv8pQ82MJzGEcZP+ZOnlhOHR+eE+ /MsCJqqfTlEUzaCi/JVvOGM5iZljvAdtMc57uPa3L5cgScr6SQkER8Z1uBO++0nSoX+0 5lSVBWp6izj8vKUzAphh1zadB4UGZeoHEWiZhl4iRvpLAGqhCsjm/+ObYYChq5pSgaa8 IlhcKc98X38SJeMM2bteXsJHFEZz687pQcIXg/gX4582kKlJyVEkOmlxdLI5b5/4+eOF wOg85I5mKDhyTmrLqKQS8Jh4dyj1WYLS47LQUSydjIi7ohIo+OMumIWJqNrfNIu+i0Cm G+xw== X-Gm-Message-State: ALKqPwcB6jQEPKtQqsCddjkdNzW3ZOykGH8rjoV4NOQOdNmeyNa88jgJ VgbO3ZJJ0aBVfSoqoUTsgjT9iHIKCCM= X-Received: by 2002:a65:62c3:: with SMTP id m3-v6mr13879566pgv.385.1526863423406; Sun, 20 May 2018 17:43:43 -0700 (PDT) Received: from joelaf.mtv.corp.google.com ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id f4-v6sm18267432pgo.77.2018.05.20.17.43.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 May 2018 17:43:42 -0700 (PDT) From: Joel Fernandes X-Google-Original-From: Joel Fernandes To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , Steven Rostedt , Peter Zilstra , Ingo Molnar , Boqun Feng , Paul McKenney , byungchul.park@lge.com, kernel-team@android.com, Josh Triplett , Mathieu Desnoyers , Lai Jiangshan Subject: [PATCH v2] rcu: Speed up calling of RCU tasks callbacks Date: Sun, 20 May 2018 17:43:24 -0700 Message-Id: <20180521004324.68371-1-joel@joelfernandes.org> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Joel Fernandes (Google)" RCU tasks callbacks can take atleast 1 second before the callbacks are executed. This happens even if the hold-out tasks enter their quiescent states quickly. I noticed this when I was testing trampoline callback execution. To test the trampoline freeing, I wrote a simple script: cd /sys/kernel/debug/tracing/ echo '__schedule_bug:traceon' > set_ftrace_filter; echo '!__schedule_bug:traceon' > set_ftrace_filter; In the background I had simple bash while loop: while [ 1 ]; do x=1; done & Total time of completion of above commands in seconds: With this patch: real 0m0.179s user 0m0.000s sys 0m0.054s Without this patch: real 0m1.098s user 0m0.000s sys 0m0.053s That's a great than 6X speed up in performance. In order to accomplish this, I am waiting for HZ/10 time before entering the hold-out checking loop. The loop still preserves its checking of held tasks every 1 second as before, incase this first test doesn't succeed. Cc: Steven Rostedt Cc: Peter Zilstra Cc: Ingo Molnar Cc: Boqun Feng Cc: Paul McKenney Cc: byungchul.park@lge.com Cc: kernel-team@android.com Signed-off-by: Joel Fernandes (Google) --- Changes since v1->v2: - Changed total wait time to HZ/10 instead of 2 jiffies - Updated the commands to reproduce issue kernel/rcu/update.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c index 5783bdf86e5a..a28698e44b08 100644 --- a/kernel/rcu/update.c +++ b/kernel/rcu/update.c @@ -743,6 +743,12 @@ static int __noreturn rcu_tasks_kthread(void *arg) */ synchronize_srcu(&tasks_rcu_exit_srcu); + /* + * Wait a little bit incase held tasks are released + * during their next timer ticks. + */ + schedule_timeout_interruptible(HZ/10); + /* * Each pass through the following loop scans the list * of holdout tasks, removing any that are no longer @@ -755,7 +761,6 @@ static int __noreturn rcu_tasks_kthread(void *arg) int rtst; struct task_struct *t1; - schedule_timeout_interruptible(HZ); rtst = READ_ONCE(rcu_task_stall_timeout); needreport = rtst > 0 && time_after(jiffies, lastreport + rtst); @@ -768,6 +773,11 @@ static int __noreturn rcu_tasks_kthread(void *arg) check_holdout_task(t, needreport, &firstreport); cond_resched(); } + + if (list_empty(&rcu_tasks_holdouts)) + break; + + schedule_timeout_interruptible(HZ); } /* -- 2.17.0.441.gb46fe60e1d-goog