Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2952837imm; Thu, 24 May 2018 19:47:17 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpQQTgk/QK7US1UD2UbJs/BFHHb5MHmqaoF3Jrkw+lVA5diGCNNh72V8ztpRIG5alZZZ6eI X-Received: by 2002:a63:8048:: with SMTP id j69-v6mr459699pgd.429.1527216437895; Thu, 24 May 2018 19:47:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527216437; cv=none; d=google.com; s=arc-20160816; b=REQmnbqUr0FIr2SzFHFz60rwfqeaDYnZDyj8KFsfmE4M0f8xbkhmIbBezyc4s4gv3O BUwDRK+6XcRxzfi3IoCV9k0kVZGGjEkzZ5ZztTG6kpRdQXAM2SKxn1YMElF+64WLUXJI gnlj9GeEryvTNeeFkwoiz2e3t6BkKObMhOlwqBTqvIEJmlofd12oc8dbtgvu7ekLzBns bcn4vloxpzt/KfF5ZUS8webWD8xbd+GoBv9rghh0VwIWll9DVq1SSoOcJKQIR8Dpf//W eyhBvnZGcdXknsA+gmOv0uQze1qNSkqwMyB49sv71aOf+6I6zN7j+U6jPS5fUEZ9vL42 knuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:subject:cc:to:from:date:arc-authentication-results; bh=+/HSY5nfKK5S8FucwCtQ3kaQEXee3g1CGjcibYccZAQ=; b=gzB8g4+yQ4D12n4CtbCQ9ie5p7lTdILbAHKBOzUiBnx+LNZxSUKlbkPWQ6ngBzYkru U+QXosuKHbWBG37EkKyazxkHxnQE4a1fgsiD3hGNLlKh8M48N92Ulx+9s8FZY4PIPNMQ Slf5mAAAYFus/XR+NQz5pB2xxhQ0eFDtTZArFgrKR+VWg8mUGO9ajKQ8blEt5hNVfsis o0xhB9TLb7VJacik7K4zB+pRAkiq+Wgc68gO4hsFzhwqJcPohkky9vvoXgt+GwsRUCzu eLLiWocYHXDjtz4aNdRMbtMmZEzoy5A+oYvtpDohZds5oDahlWecbz9COTLT40E8Y7zT td7w== 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 n6-v6si22044831pfi.360.2018.05.24.19.47.03; Thu, 24 May 2018 19:47:17 -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 S935900AbeEXWtv (ORCPT + 99 others); Thu, 24 May 2018 18:49:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:36546 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935803AbeEXWtt (ORCPT ); Thu, 24 May 2018 18:49:49 -0400 Received: from gandalf.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 109732084D; Thu, 24 May 2018 22:49:47 +0000 (UTC) Date: Thu, 24 May 2018 18:49:46 -0400 From: Steven Rostedt To: LKML Cc: "Paul E. McKenney" , Joel Fernandes , Peter Zilstra , Ingo Molnar , Boqun Feng , byungchul.park@lge.com, kernel-team@android.com, Josh Triplett , Lai Jiangshan , Mathieu Desnoyers Subject: [PATCH v4] rcu: Speed up calling of RCU tasks callbacks Message-ID: <20180524184946.5fa82d19@gandalf.local.home> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) --- 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);