Received: by 10.192.165.148 with SMTP id m20csp800978imm; Thu, 10 May 2018 00:23:17 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpRLMsmK8dlOZIaxM+gA+mwyeOH5lJBuVZptzAl8A7Df+rGv+nnn/4ntlycrfU17eWM1u5a X-Received: by 2002:a17:902:8305:: with SMTP id bd5-v6mr288969plb.13.1525936997584; Thu, 10 May 2018 00:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525936997; cv=none; d=google.com; s=arc-20160816; b=UAliVSJeVlh0TO3Gu5UOzjXWq3D/JWnWIb8M9juBLVVHbBqvnnjcFZyxcSaR1/12ui r4JXFxDruVihmhJle15LFMWv/VnJ9W9L0iwSdBvosUp04JVzL7z5L11mBLQVFMj/kJ1A RDn8mgPZ0kJBHDY53lZ6HrU4/ijESt5DbZx4afxjKYViQ/YwdHyn5OgodnfPXO1I2Vr1 gfO6J+o9ii0v8wY4Xbve8O+GvkxXDG3+NzHmFvCPC/gIQUeMUdjg7e4to3KMGzWHt8uG pTQhUE8MOKfYLSFlrGzRexqwJEYO2N3m8EnvIsiTIwihipEnVcLn4K00BVBvCldu7sN1 Ii9w== 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=49KuwhdV50Ap/l68rWzfc+P2J1VKZRJnVnFrlTyS3LM=; b=M5DTiFzAu25TBM3+NQR8BVQXhQRJynLIqj4KPm1DjwmaWraQp9SWKs+TgQCedhKHDY ZxlpPAVhEIjAwTUc4PGBkWobB2PSWRPrYI9NRfIj5wSEOSMb/RCt2RbQfyS2oZ0ppGFY 2zh3DAw8p8qi+o/zm+eaXhiuEAORSclWRK+eAIM5FOe6/5gi0oKGg50zjdAes9j0I6Uj d/sjWOxIKp/vjhk7EWq0TLyUkQ1MdmPSyOazAoZ4KC39CD+jOhpBrP9hFBCXlWJhDY/9 e5mHLcujdPPRDbdmp5GyMXvGfEadBw8x4nMIAAbbwPna7W8GTA2iIrGn8jYERcyvssT4 8Dhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes-org.20150623.gappssmtp.com header.s=20150623 header.b=ObcUZi9I; 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 v16-v6si172565pfm.151.2018.05.10.00.23.02; Thu, 10 May 2018 00:23: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; dkim=pass header.i=@joelfernandes-org.20150623.gappssmtp.com header.s=20150623 header.b=ObcUZi9I; 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 S934278AbeEJHVg (ORCPT + 99 others); Thu, 10 May 2018 03:21:36 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:41529 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933887AbeEJHVf (ORCPT ); Thu, 10 May 2018 03:21:35 -0400 Received: by mail-pg0-f67.google.com with SMTP id m21-v6so565081pgv.8 for ; Thu, 10 May 2018 00:21:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=49KuwhdV50Ap/l68rWzfc+P2J1VKZRJnVnFrlTyS3LM=; b=ObcUZi9Im6SrkEOLSiCGb38BxHWi1UxgcVePQ9pipzB+N7yr+ymrHncvVMB4wnsrVJ hptCh/RP74AwaPz/tf9xn4vNKHDxYBPN66dzOZVAo99FIMK+oXJW7+QK6TG8Nl54jJfn YYZEfO3JVf3xE+qa6Rc0V4fKj9v1YBoiOsroHBAY1ddqqboSMQTe2LkfZPoCIXi9T1KY pzZEH3Vg9JonW+EyM71E8bxIhXLRRef0OxQGpxl2yKwZirqGu9NiuYnXd8MQrBdvzr1p YsHoShL3QLEZeSfC/AvqKyrfDfYkawKOUKuGH1ZWMyOasj8of6veawrpkcpImp5ax7zm C7dA== 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=49KuwhdV50Ap/l68rWzfc+P2J1VKZRJnVnFrlTyS3LM=; b=NGW/mK/uQcbk4k0OrLuYsrN81DoY2aCD7ndJBT+0fBeNIFBTHcB1QMK+2o5njssEBu qunYmGrrrrbBYLTItxUGwIdHPhjVYK6C2D6nHiAxQx9R0f8b6xFwH71YUbuYXzIyQtUf 4Sg9m2SID9BlgEs78u3uO9dml/P3E71ylhDFei295u1JXwAy8XQDs6YyG25tFZnXgazl 43/brmFkL4o+dndldUcdJ4OvJ8Fv0EsbgWcpQbyuVFhaIhbulEz8ZTP6ol9NCgiQgDHQ LpELc5aAa006ZzdgA6c/y0w9GW4NuGDk2BEkmifc8dljJ7z+HoYpVf0uRbYMztSpDzYD l68A== X-Gm-Message-State: ALKqPwety4QkxIyjQ1cGrQCayIMdmHt0CnyjxXb3aBvDmqfYw20IlFlY 0Pavm39Q0OAVNjCWsgtxLuoOuQ== X-Received: by 2002:a65:6645:: with SMTP id z5-v6mr227637pgv.43.1525936894492; Thu, 10 May 2018 00:21:34 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id p84-v6sm761207pfi.66.2018.05.10.00.21.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 May 2018 00:21:34 -0700 (PDT) Date: Thu, 10 May 2018 00:21:33 -0700 From: Joel Fernandes To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com, joel.opensrc@gmail.com, torvalds@linux-foundation.org, npiggin@gmail.com Subject: Re: [tip/core/rcu, 05/21] rcu: Make rcu_gp_cleanup() more accurately predict need for new GP Message-ID: <20180510072133.GA122810@joelaf.mtv.corp.google.com> References: <1524452624-27589-5-git-send-email-paulmck@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1524452624-27589-5-git-send-email-paulmck@linux.vnet.ibm.com> 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 Hi Paul, On Sun, Apr 22, 2018 at 08:03:28PM -0700, Paul E. McKenney wrote: > Currently, rcu_gp_cleanup() scans the rcu_node tree in order to reset > state to reflect the end of the grace period. It also checks to see > whether a new grace period is needed, but in a number of cases, rather > than directly cause the new grace period to be immediately started, it > instead leaves the grace-period-needed state where various fail-safes > can find it. This works fine, but results in higher contention on the > root rcu_node structure's ->lock, which is undesirable, and contention > on that lock has recently become noticeable. > > This commit therefore makes rcu_gp_cleanup() immediately start a new > grace period if there is any need for one. > > It is quite possible that it will later be necessary to throttle the > grace-period rate, but that can be dealt with when and if. > > Reported-by: Nicholas Piggin > Signed-off-by: Paul E. McKenney > --- > kernel/rcu/tree.c | 16 ++++++++++------ > kernel/rcu/tree.h | 1 - > kernel/rcu/tree_plugin.h | 17 ----------------- > 3 files changed, 10 insertions(+), 24 deletions(-) > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 497f139056c7..afc5e32f0da4 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -1763,14 +1763,14 @@ rcu_start_future_gp(struct rcu_node *rnp, struct rcu_data *rdp, > * Clean up any old requests for the just-ended grace period. Also return > * whether any additional grace periods have been requested. > */ > -static int rcu_future_gp_cleanup(struct rcu_state *rsp, struct rcu_node *rnp) > +static bool rcu_future_gp_cleanup(struct rcu_state *rsp, struct rcu_node *rnp) > { > int c = rnp->completed; > - int needmore; > + bool needmore; > struct rcu_data *rdp = this_cpu_ptr(rsp->rda); > > need_future_gp_element(rnp, c) = 0; > - needmore = need_future_gp_element(rnp, c + 1); > + needmore = need_any_future_gp(rnp); > trace_rcu_future_gp(rnp, rdp, c, > needmore ? TPS("CleanupMore") : TPS("Cleanup")); > return needmore; > @@ -2113,7 +2113,6 @@ static void rcu_gp_cleanup(struct rcu_state *rsp) > { > unsigned long gp_duration; > bool needgp = false; > - int nocb = 0; > struct rcu_data *rdp; > struct rcu_node *rnp = rcu_get_root(rsp); > struct swait_queue_head *sq; > @@ -2152,7 +2151,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp) > if (rnp == rdp->mynode) > needgp = __note_gp_changes(rsp, rnp, rdp) || needgp; > /* smp_mb() provided by prior unlock-lock pair. */ > - nocb += rcu_future_gp_cleanup(rsp, rnp); > + needgp = rcu_future_gp_cleanup(rsp, rnp) || needgp; > sq = rcu_nocb_gp_get(rnp); > raw_spin_unlock_irq_rcu_node(rnp); > rcu_nocb_gp_cleanup(sq); > @@ -2162,13 +2161,18 @@ static void rcu_gp_cleanup(struct rcu_state *rsp) > } > rnp = rcu_get_root(rsp); > raw_spin_lock_irq_rcu_node(rnp); /* Order GP before ->completed update. */ > - rcu_nocb_gp_set(rnp, nocb); > > /* Declare grace period done. */ > WRITE_ONCE(rsp->completed, rsp->gpnum); > trace_rcu_grace_period(rsp->name, rsp->completed, TPS("end")); > rsp->gp_state = RCU_GP_IDLE; > + /* Check for GP requests since above loop. */ > rdp = this_cpu_ptr(rsp->rda); > + if (need_any_future_gp(rnp)) { > + trace_rcu_future_gp(rnp, rdp, rsp->completed - 1, > + TPS("CleanupMore")); > + needgp = true; Patch makes sense to me. I didn't get the "rsp->completed - 1" bit in the call to trace_rcu_future_gp. The grace period that just completed is in rsp->completed. The future one should be completed + 1. What is meaning of the third argument 'c' to the trace event? Also in rcu_future_gp_cleanup, we call: trace_rcu_future_gp(rnp, rdp, c, needmore ? TPS("CleanupMore") : TPS("Cleanup")); For this case, in the final trace event record, rnp->completed and c will be the same, since c is set to rnp->completed before calling trace_rcu_future_gp. I was thinking they should be different, do you expect them to be the same? thanks! - Joel