Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4037755pxk; Tue, 29 Sep 2020 12:33:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2qC24wWJn9AlQHH8aEbZBktOUY0bAk39h/MJ4xicNKXj1es4o8ZhgDEw0iP41i8R7LyWg X-Received: by 2002:a50:99d6:: with SMTP id n22mr5052101edb.265.1601407997171; Tue, 29 Sep 2020 12:33:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601407997; cv=none; d=google.com; s=arc-20160816; b=EnPnaRk0vwiN6eD6vbhyYozrC+9APc1T2+3IG2ITrNHZao/2OiKkEkq3pSU4zGPwzx p/zd8NjrtPOoPEVXa1cbVnRTTdjHsxfxm9sEJNI7v5wXlYmkZacBm+PaE3AGC1IjoNxV OgZzDeMT9q9Ef2hnzR64yxIWfRIpImNrZ0wdC01bhjF2WM4ojPJikznGK0yTFCNhO645 Vv0qt12Ivfh4a7E6uZAduzFAQG3oIDxJNw7at544Had+puPswKc8SuP+u/jAcI3ZO74p 2C1DtGUxZI+aGEiWGTX0dyrdTVLXqqWj9hNt5VRo9fNmbJDbn7HvN9cT20LAkuAuzbnA oiBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=HQjBA9NgyL26LnUuoSDLOqhNdN/FWjyvKU8svYcqWsk=; b=FSc0RHqTXXZLN/ImkH3r1BN/0t/OHye/9xj0/rAGhUm2I+MOi/l6E2JwBacYodedy3 Tb9zjZecqA1OHGq9WPUCmH9J0QPmiWPGfRIrhl7+QMFJWy4iGanPijRErP1JJhF7R6IX 1M8Rai+q7IUz2rUabI6gz1YE8qeKXYPWj/dOuSRbegX+ypp+nQL1ghOXEji8jK/XIgGc js9pfkJI4HWZu14LcrpOIASlHQG0u2dQ0L+USqjNI6bE+nzN3OSU68tfDAfnF1rH2isu kdzHiFU4qe+aPvxE/G664ycM6y9wQ/V6UAavDleFqApNH6+jfrDQ841PKSKm6NZQLADH FmFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=Ce8LTnc8; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q26si3299648ejz.749.2020.09.29.12.32.53; Tue, 29 Sep 2020 12:33:17 -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=@joelfernandes.org header.s=google header.b=Ce8LTnc8; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728693AbgI2T3q (ORCPT + 99 others); Tue, 29 Sep 2020 15:29:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728602AbgI2T3p (ORCPT ); Tue, 29 Sep 2020 15:29:45 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BFD6C061755 for ; Tue, 29 Sep 2020 12:29:45 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id o21so4577077qtp.2 for ; Tue, 29 Sep 2020 12:29:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HQjBA9NgyL26LnUuoSDLOqhNdN/FWjyvKU8svYcqWsk=; b=Ce8LTnc8e/zH9MehkioLTQWGUhuleeWSeiMQwntLEhQs92eE59HfRttFq9qE61S2Xw 0F5HbktYGoepjGQHGS7dw5Re7zLmU4a0zcP3keEqP51Q0tl44DJdrfoSR7VjDnu3kpk9 ZjEmjob35yN1LhZLsOSWox4kpZZGaUYjZZ95Q= 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:mime-version :content-transfer-encoding; bh=HQjBA9NgyL26LnUuoSDLOqhNdN/FWjyvKU8svYcqWsk=; b=n97LAJsAz/rSIO+R4tdbuc5KVd3QNmJ89ytueC8o7OQaAEF5mryPMuGdu3s1lXZo/d 7//OoipdXjRAZ7/unqZ649t6cf+ynnlgii14JScm9DYAo9uBq6BKuAjTpXIB8CsQ0NQC wXULw03Wyj92qy9MC0sGQ++ANRsRaICuWqS2P2imjEa4A/ub5PXPgw08p7JI7aupZY+r oKDs2Ey82vMLgkUJbgdbECOwilAHyCkvN/itib/gwx5kvLyISMrV+RceupRRUMj0GqcD LINA9ghZh6tv5GlLh5wy/bntO2c7IQBkLsUN3TcAne1SWsY5J/6ppzeVv6Ogap+8bso6 4PGg== X-Gm-Message-State: AOAM531W3JGW2RHi7Sw8lCc1zsnu4iTSgq+uVygE0tqztOXPwClnxSms q1GyfVOPgURUVo6h3Nfv+Xp5phwtbuEADw== X-Received: by 2002:aed:2f61:: with SMTP id l88mr5024636qtd.262.1601407784422; Tue, 29 Sep 2020 12:29:44 -0700 (PDT) Received: from joelaf.cam.corp.google.com ([2620:15c:6:12:cad3:ffff:feb3:bd59]) by smtp.gmail.com with ESMTPSA id n7sm6892887qtf.27.2020.09.29.12.29.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 12:29:43 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , "Paul E . McKenney" , 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: [PATCH 1/2] rcu/tree: Add a warning if CPU being onlined did not report QS already Date: Tue, 29 Sep 2020 15:29:27 -0400 Message-Id: <20200929192928.3749502-1-joel@joelfernandes.org> X-Mailer: git-send-email 2.28.0.709.gb0816b6eb0-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) --- 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