Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2398985pxa; Fri, 7 Aug 2020 10:09:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy82IZsAgrnvW+t80Z9f2rm2t4T6ZFGrFp1X/0qhTwFmsFr1KKYIApTJW/XMILO/j4ACrPV X-Received: by 2002:aa7:c544:: with SMTP id s4mr9704782edr.51.1596820149845; Fri, 07 Aug 2020 10:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596820149; cv=none; d=google.com; s=arc-20160816; b=Ck/ZpJ3kpluRnlN3nL5/V7W6+aqbSAf3JOkMdBexz0OC4uMzzuf99ByETXei5K8BCc M5g19i7V5dvLl96erP3g0naHUDiKPtzdX9OF1epPcQ5ehoLhYvhlQe9P8k8lhpYU/eZm hW9k86H+Y5ML+BQ8NvJpAAGyc55sIy/VbYrglDdGU9oDJ0zb4Nrsp9XXvJ6/mCcLhJZ2 wxm6FuzefDWJVIkzHX4N0YUlNv71dbqlmAmSSlWcrtXnM9L4O6KzsXT2HnR5m77uv2up RB8k8UZbRR07oWA383ZfzYoh/q1D7EEvWXwO/+O1KIo29e59ZsPZorkqcs+LkfSPRcdk cAxw== 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:date:subject:cc:to:from :dkim-signature; bh=9MZydlpZQdg9xwKnugPlE3q4Dt+DJHoXBV4KQJAvjEY=; b=iG4GU8UkmuxcNnF7wbMQ7MBlALJF7cS/P4Npq2VoTs8bvUWV/JiDmaA43iweNGDN1g 6SQE8o5v+ulAcRqgu2BigcbSQAXxyDhV0WR4/1OS0TRUp+jKl3HRvaey0NrtOwnc900F V5ZYsFw2y57dmFyban8gbRTUguqBOdcWyI7+kmrkMJEI/uFHL1G7gqmUpqEkPmZ/8ZdR IYrp6b1Au7esdABMH/EnBBMcKfOt9v+K+dAoyNvT12/oHoRHcXOZaWKasdY6tZJbSsDh APh4z2J2JhE5THklRMaIiGwShYtzCHVKG8ue62qzK+9O/4VNv/+94cVlXXIngMFp/nHs 4emg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=deJkkdWO; 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 um10si5665374ejb.119.2020.08.07.10.08.47; Fri, 07 Aug 2020 10:09:09 -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=deJkkdWO; 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 S1726937AbgHGRID (ORCPT + 99 others); Fri, 7 Aug 2020 13:08:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726595AbgHGRHb (ORCPT ); Fri, 7 Aug 2020 13:07:31 -0400 Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FCD0C061A29 for ; Fri, 7 Aug 2020 10:07:30 -0700 (PDT) Received: by mail-qv1-xf44.google.com with SMTP id j10so1054430qvo.13 for ; Fri, 07 Aug 2020 10:07:30 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=9MZydlpZQdg9xwKnugPlE3q4Dt+DJHoXBV4KQJAvjEY=; b=deJkkdWOEfKC+kvKx7+ClVkyba0wnSQ8rJM4NqNvIF79qpU2xahjNyIRC1c1Y/YyF5 XgzORW6SmZfDojsp6Zc12OtykRcV3OLEjSrwSHSoOnUdsUAff9VY33xJi9YhQTdkJpk1 urtOTNP6u99muORbmAQ8qHsZ0OkI2TxO7cRSA= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=9MZydlpZQdg9xwKnugPlE3q4Dt+DJHoXBV4KQJAvjEY=; b=TD6j6CczSuCJfqnsGty0MKWA6O8o8DKaqs+D7IhvThpwR2vDZdTIsdNw7eVd58t6Ym yqDmGZRwPA6ol2pYzUDMCHetJ0OLmbCFRQ7l5apNpqWV0zOKN5fonTjEqgLZBDxZNFDM uVOE5xsRCgBU+K7HC1GXxckLxLD1lBh3G8+iVLS7a/4llzlGq6pe0vA6aO83iTpcjqfr ZQ3k8C1/8Op2W/gvMLEudGtjJyD9GRbQqdqFv58G0oedXF7wL6+Yx0g2uqLTDpsK2SWH 5tkuJuyEgFr4NR74DcGecBUZlv8zl4UBIDEhCgVnZ9lHXnwG7cPonSySGgfXMP490VqW gHQA== X-Gm-Message-State: AOAM532Hqyq+DNdMIXyALl0dgrU4SB0GQzqoG8/Xo2S2PRQLMBiuPCcO ahlr0LeFuLTE0nLNw16EjG+n8h6OjoM= X-Received: by 2002:ad4:4302:: with SMTP id c2mr15344941qvs.246.1596820049011; Fri, 07 Aug 2020 10:07:29 -0700 (PDT) Received: from joelaf.cam.corp.google.com ([2620:15c:6:12:cad3:ffff:feb3:bd59]) by smtp.gmail.com with ESMTPSA id w18sm8559905qtk.1.2020.08.07.10.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2020 10:07:28 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , "Paul E . McKenney" , Neeraj Upadhyay , Davidlohr Bueso , Jonathan Corbet , Josh Triplett , Lai Jiangshan , linux-doc@vger.kernel.org, Mathieu Desnoyers , Mauro Carvalho Chehab , peterz@infradead.org, Randy Dunlap , rcu@vger.kernel.org, Steven Rostedt , tglx@linutronix.de, vineethrp@gmail.com Subject: [PATCH v4 1/5] rcu/tree: Add a warning if CPU being onlined did not report QS already Date: Fri, 7 Aug 2020 13:07:18 -0400 Message-Id: <20200807170722.2897328-2-joel@joelfernandes.org> X-Mailer: git-send-email 2.28.0.236.gb10cc79966-goog In-Reply-To: <20200807170722.2897328-1-joel@joelfernandes.org> References: <20200807170722.2897328-1-joel@joelfernandes.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org 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 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 65e1b5e92319..a49fa3b60faa 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -3996,7 +3996,14 @@ 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? */ + + /* + * XXX: The following rcu_report_qs_rnp() is redundant. If the below + * warning does not fire, consider replacing it with the "else" block, + * by June 2021 or so (while keeping the warning). Refer to RCU's + * Requirements documentation for the rationale. + */ + 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.236.gb10cc79966-goog