Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1018845pxk; Thu, 1 Oct 2020 21:41:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZ3X3j34OjHOxOj8hJKL96fa4VfxCGs+nJI4u2d9fxo0/S92jxdR5Rp7PeWS5yfYxSGgKk X-Received: by 2002:a50:cdd7:: with SMTP id h23mr367354edj.48.1601613683124; Thu, 01 Oct 2020 21:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601613683; cv=none; d=google.com; s=arc-20160816; b=1JtMLzskDT0uvjc1Sf1gDjz06HLVnREthWtsaFDZ4VvGy2EyXqzXaTJYY2PJVirBJv PAtgi7ZsEAPoQ/7dcKOqFq0cQlX65i8C6PjAnc88z8hQwqqfflN8puhXvmGoABn0xuFG Of2gdGnDSomvUNtNxyocP5iv6Ah1bvgdtYUk1zJk5qkkj4O7fiBJmRDJ8vLalnh0vYRh x5y8aOpElNY4HGkqBzTgwnAQBhnyHTHe2PucYrZg8cCQluNQSyl2JoOJ0RUfIbWzTIhG JsExOH+uyrOGtcdu8q0CGAknBxVEm65nUCwvVyv4MnSKD7xsqIeHkSFABmkqaiEbE797 CzxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=UfmuYRx8RgEEUV0plmuMwWym7n/CjoBpagIAvORKQoc=; b=InV62BHT7DnHjoaS+Vw90TK+/GCBNApah4tNfdBC9XZ1Zaed/mYff25DC1PmWr80pI bnFWQNUNrvlVJXOvgMIvt4ihnVoMtms8OD/3yR0nn231GfJ6iYW1f8Ff5roi8C5zui2B wxYfd3KaZknhSsFFoJYa+14NWsyMiGUlbO8ssErWiHr1sTrQ5A1d/j6Lkq4okjiieTw4 aWcnY7CvJcwAmcobxLF+Hc6tKMpoirs4O2k7wpf0VnBoC+2m6Bit2Anl3w5qb6Zm1gaX zsCB4zjd5aRuN07HJC9Ltwqh9/p47vUGWY5CfJXf5QzgukVvqmxpg852ZfPnzvGAdoiT MMMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="YY/1Lv2s"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l9si168521edt.504.2020.10.01.21.40.57; Thu, 01 Oct 2020 21:41:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="YY/1Lv2s"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725968AbgJBEjw (ORCPT + 99 others); Fri, 2 Oct 2020 00:39:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:54682 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725948AbgJBEjv (ORCPT ); Fri, 2 Oct 2020 00:39:51 -0400 Received: from paulmck-ThinkPad-P72.home (unknown [50.45.173.55]) (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 1A4022072E; Fri, 2 Oct 2020 04:39:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601613591; bh=zbG2iEh9bQFGJLHd+0KwxDAW/5RszvjdWnLdbMOPS7o=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=YY/1Lv2sEiR77Cwbq80MBqwJ1oLz+9XHTJB0/Z7dwL9dRgnFHcV41OurKT/kmmV0q 9adRNOXPEqCj5i8U/lxS7UtQvma7cZH0fJ/2/6g7Xv/YxkA5etImdpCSiuKcOX3wKT +mIhj1qqlt2JTWzSPB/r7HqERwFZ0cTdGLuO7r28= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id D67563522B33; Thu, 1 Oct 2020 21:39:50 -0700 (PDT) Date: Thu, 1 Oct 2020 21:39:50 -0700 From: "Paul E. McKenney" To: "Joel Fernandes (Google)" Cc: linux-kernel@vger.kernel.org, Neeraj Upadhyay , Jonathan Corbet , Josh Triplett , Lai Jiangshan , linux-doc@vger.kernel.org, Mathieu Desnoyers , Mauro Carvalho Chehab , Randy Dunlap , rcu@vger.kernel.org, Steven Rostedt , Will Deacon Subject: Re: [PATCH 1/2] rcu/tree: Add a warning if CPU being onlined did not report QS already Message-ID: <20201002043950.GG29330@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20200929192928.3749502-1-joel@joelfernandes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200929192928.3749502-1-joel@joelfernandes.org> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 29, 2020 at 03:29:27PM -0400, Joel Fernandes (Google) wrote: > Currently, rcu_cpu_starting() checks to see if the RCU core expects a > quiescent state from the incoming CPU. However, the current interaction > between RCU quiescent-state reporting and CPU-hotplug operations should > mean that the incoming CPU never needs to report a quiescent state. > First, the outgoing CPU reports a quiescent state if needed. Second, > the race where the CPU is leaving just as RCU is initializing a new > grace period is handled by an explicit check for this condition. Third, > the CPU's leaf rcu_node structure's ->lock serializes these checks. > > This means that if rcu_cpu_starting() ever feels the need to report > a quiescent state, then there is a bug somewhere in the CPU hotplug > code or the RCU grace-period handling code. This commit therefore > adds a WARN_ON_ONCE() to bring that bug to everyone's attention. > > Cc: Paul E. McKenney > Cc: Neeraj Upadhyay > Suggested-by: Paul E. McKenney > Signed-off-by: Joel Fernandes (Google) Queued for testing and further review, thank you! Thanx, Paul > --- > kernel/rcu/tree.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 55d3700dd1e7..5efe0a98ea45 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -4119,7 +4119,9 @@ void rcu_cpu_starting(unsigned int cpu) > rcu_gpnum_ovf(rnp, rdp); /* Offline-induced counter wrap? */ > rdp->rcu_onl_gp_seq = READ_ONCE(rcu_state.gp_seq); > rdp->rcu_onl_gp_flags = READ_ONCE(rcu_state.gp_flags); > - if (rnp->qsmask & mask) { /* RCU waiting on incoming CPU? */ > + > + /* An incoming CPU should never be blocking a grace period. */ > + if (WARN_ON_ONCE(rnp->qsmask & mask)) { /* RCU waiting on incoming CPU? */ > rcu_disable_urgency_upon_qs(rdp); > /* Report QS -after- changing ->qsmaskinitnext! */ > rcu_report_qs_rnp(mask, rnp, rnp->gp_seq, flags); > -- > 2.28.0.709.gb0816b6eb0-goog >