Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5189308ybv; Mon, 17 Feb 2020 14:22:03 -0800 (PST) X-Google-Smtp-Source: APXvYqy3bNWa9zzHYqbdGu39//Hha2tZhN+Bv1fvrS2AAdSLGh9s1FbC4ltOyiJFmAHZu/iwAPnd X-Received: by 2002:a9d:6c8d:: with SMTP id c13mr13941875otr.277.1581978123245; Mon, 17 Feb 2020 14:22:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581978123; cv=none; d=google.com; s=arc-20160816; b=eDP3VsJTp5lWQvnvdjb1ROtWYXQ56AwYzQ9tF749Hb+ewJniHjweIe18e8HQW80ZLS Hg1ePzimMGW47whqe+e3l0r96Krhb0tpMHqoSfgcXwMZAx1I7ql/SdsACvY+JC92O2kp kWpcUCKYQ1VmWbi39nXlizKQf1Tze5dbPlsDQQPQ5qfV94CYkUET0ZS+nv+Vb0djo2QN Gac036kFCXen7VJ63PcmuB5Sc7OZ0gMdVo2f2k4qMADUq9pxWRZ+ExN9U/GoNjUlsJxj QpwrD0zeIcfL48w3v9Rb9HSGcgWraei4X55bO4P4ptT5i9EWds2ySNXERcOtUaAY4kEU wU0w== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=QoTJgZONeHbyS+9GfKMhXYk4L6Ir1cl3iHlyl4dcfyw=; b=VtzYQTCtmqfT0+zDKsrdviays3xGlxPCKy/FDlAPvE8pTg3bYDhsvIXcdAAMYllJNx Zx8IAcpF/dg8LKviYyf6xjStioS5EpsfEl7MlFaaWtpjtOgJypRvdS2pZywyl0QU1mEN 0IWamZrJI6G1qxcwEiUknl6V0uk3XoojscjPLyc5+8mmf6Av0yycpkJrhBiQNpCAE7i6 bozZ4Dq47M2VOt7b4VCus4HNniGFl7eTS1vYUjdMyfxv4TzbdFiJdjBGohJV3kEiH9CL ZmQPmqDIB7NTR5tvQLhpCKoKQ7yiF5YlXR0Z0Z6dXVQjHD09pIfcwDZYZ5/mWDlmvCmr tjYw== 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 w29si880982oth.313.2020.02.17.14.21.51; Mon, 17 Feb 2020 14:22:03 -0800 (PST) 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 S1726081AbgBQWVf (ORCPT + 99 others); Mon, 17 Feb 2020 17:21:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:46820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725829AbgBQWVf (ORCPT ); Mon, 17 Feb 2020 17:21:35 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (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 EC93B2070B; Mon, 17 Feb 2020 22:21:32 +0000 (UTC) Date: Mon, 17 Feb 2020 17:21:31 -0500 From: Steven Rostedt To: "Paul E. McKenney" Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, 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, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org, Linus Torvalds Subject: Re: [PATCH tip/core/rcu 22/30] rcu: Don't flag non-starting GPs before GP kthread is running Message-ID: <20200217172131.1f4c48d2@gandalf.local.home> In-Reply-To: <20200217220356.GY2935@paulmck-ThinkPad-P72> References: <20200214235536.GA13364@paulmck-ThinkPad-P72> <20200214235607.13749-22-paulmck@kernel.org> <20200214225305.48550d6a@oasis.local.home> <20200215110111.GZ2935@paulmck-ThinkPad-P72> <20200215134208.GA9879@paulmck-ThinkPad-P72> <20200217152517.26cc11ea@gandalf.local.home> <20200217220356.GY2935@paulmck-ThinkPad-P72> X-Mailer: Claws Mail 3.17.3 (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 On Mon, 17 Feb 2020 14:03:56 -0800 "Paul E. McKenney" wrote: > And what is a day without micro-optimization of a slowpath? :-) A day you have off, but still find yourself working ;-) > > OK, let's see... > > Grace-period kthread wakeups are normally mediated by rcu_start_this_gp(), > which uses a funnel lock to consolidate concurrent requests to start > a grace period. If a grace period is already in progress, it refrains > from doing a wakeup because that means that the grace-period kthread > will check for another grace period being needed at the end of the > current grace period. > > Exceptions include: > > o The wakeup reporting the last quiescent state of the current > grace period. > > o Emergency situations such as callback overloads and RCU CPU stalls. > > So on a busy system that is not overloaded, the common case is that > rcu_gp_kthread_wake() is invoked only once per grace period because there > is no emergency and there is a grace period in progress. If this system > has short idle periods and a fair number of quiescent states, a reasonable > amount of idle time, then the last quiescent state will not normally be > detected by the grace-period kthread. But workloads can of course vary. > > The "!t" holds only during early boot. So we could put a likely() around > the "t". But more to the point, at runtime, "!t" would always be false, > so it really should be last in the list of "||" clauses. This isn't > enough of a fastpath for a static branch to make sense. Hey! Does that mean we can add a static branch for that check? struct static_key rcu_booting = STATIC_KEY_INIT_TRUE; [...] if (READ_ONCE(rcu_state.gp_flags) || (current == t && !in_irq() && !in_serving_softirq()) return; if (static_branch_unlikely(&rcu_booting) && !t) return; At end of boot: static_key_disable(&rcu_booting); That way we can really micro-optimize the slow path, and it basically becomes a nop! -- Steve > > The "!READ_ONCE(rcu_state.gp_flags)" will normally hold, though it is > false often enough to pay for itself. Or has been in the past, anyway. > I suspect that access to the global variable rcu_state.gp_flags is not > always fast either. > > So I am having difficulty talking myself into modifying this one given > the frequency of operations. > > Thanx, Paul