Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2399274pxa; Fri, 7 Aug 2020 10:09:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbjyjERYFzmJ6AkwRsEqcLPYUC3p/RsK0geu3guBKNXgq4ADR6tyyGlIbrKs0mucWPtkUp X-Received: by 2002:a50:9d88:: with SMTP id w8mr9451419ede.122.1596820173679; Fri, 07 Aug 2020 10:09:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596820173; cv=none; d=google.com; s=arc-20160816; b=w1hs9d2WUi+2nBj4mwzCqGmvP8KDks4ZJMfzJt+ZknuXq1WaQ/n+/a3p1pLG+zalYi MTFkLrOCBD//2vursyMp4KsqXLWDy9HxRXDqfV+xZFqTJGBnyEsMZxDxYxqtOcjRlPXi 4jHKi/HTlcBrbXm408STWUmIWDMdynqwsrgrkVGA2mSf6GBgyzQnG5bYxXjVKPMMjAww yXVLv/Jr2mTobq8XMPfgfXBvuv7Gl67UKgpUd2+VW4Vm8g/0CsttEl7sVYUdtzyI7eD1 xRsXPzkmxi5TaE+RjSfPP1CKoPBHJvpwgdrZUqZg+F4sZzl+7YwNt3hqGgGyqOw3/FPr IBtw== 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=gicPVw0CqSD8CviuYDeBK7XWa+PKPPBQRJgIkcRqYe8=; b=H+JyZDb3ueiO+Z8tEwuHXtFUL5kPoIb3KgEbK2swlmvmLuyW0dRO9kHmUc+rym9HY7 xIdteiJQ4MGHKsPjGBxOZ1DCfdEvC2w/Buusew/lPvbDqDo2oSrzyT+F/UN4eXn33M2J D18KuxR0iRpR5lNmKttpMTAH6YR4cdfRX8kIwYuLN4McQXGAw8ODUxQB7Z+6HKBacTyz EF1R+vQ8rc13nDCL4X79yCRJRNmE9MoSnAJeA8F7+Z+Rz8IVsqHPi0atvbmlRYIGdzOL ozoPQ6opjvzjfo/2GC/15R+EgUogAFtuZeNyeGIlq6YL2xw8x2e8l6u/klbHI8+53CJd gwfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b="qm6S/7Ua"; 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 lo3si5817603ejb.219.2020.08.07.10.09.10; Fri, 07 Aug 2020 10:09:33 -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="qm6S/7Ua"; 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 S1727005AbgHGRIU (ORCPT + 99 others); Fri, 7 Aug 2020 13:08:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726094AbgHGRHu (ORCPT ); Fri, 7 Aug 2020 13:07:50 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E87DC061A30 for ; Fri, 7 Aug 2020 10:07:32 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id 2so2329838qkf.10 for ; Fri, 07 Aug 2020 10:07:32 -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=gicPVw0CqSD8CviuYDeBK7XWa+PKPPBQRJgIkcRqYe8=; b=qm6S/7Ualllrfwl4E6yQMbWN6fgGnMafA5K5NBJHki4cmb0uDO3WczO8vny81N9oWS 9A+3eh/htpTKUbYFJPCE7ttB/y93pt4ToNaOgdrGJ6zzikB/A+NQe2cSel06AwszJXBS 51zGUVQm2TGuSV1a0hNqOWGsM1eHoaNWk5Ot0= 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=gicPVw0CqSD8CviuYDeBK7XWa+PKPPBQRJgIkcRqYe8=; b=F5iQELHLlVyKr2ZxBIJ1+yfnrIux5hDU9qPAB3jPywZY7cuk9EjJUOnAoJTFowlkWe z84dsOSoTrlEItevuFZ02JwKdDCmAFBGhz5UwfO+jCaQeNrdyLU7QVP1zvdD1SiwsUGJ FTwJXj96pv/WAzqsacszp6gfeE2W2RyVHyDN65lY6A6DhwXWEMyE4YE8+ZBL0sXZOhPm 7VAnO/RFAmG32WmRVVv+8yYUHA+eQU/m9mGBY/Fd+DJZWe8IC0o+2uE7+/tlWVllN8ds 1wUc4G4LiDCScgEmQCP7DXsjjqonlcHwMYP3dkeLJ3hetAMGgAwZN69EMammsUL5bvSL JUOg== X-Gm-Message-State: AOAM5315ulgiWZ9uA/zSLkxBLOIgW5NmDN9vHo8Z0Z2UcLQSerBx4HYy jJGX2dbbXxFYC8FYeQ+Hq9tzFCqY/RE= X-Received: by 2002:a05:620a:10ab:: with SMTP id h11mr14132645qkk.219.1596820051354; Fri, 07 Aug 2020 10:07:31 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2020 10:07:30 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , Davidlohr Bueso , Jonathan Corbet , Josh Triplett , Lai Jiangshan , linux-doc@vger.kernel.org, Mathieu Desnoyers , Mauro Carvalho Chehab , neeraju@codeaurora.org, "Paul E. McKenney" , peterz@infradead.org, Randy Dunlap , rcu@vger.kernel.org, Steven Rostedt , tglx@linutronix.de, vineethrp@gmail.com Subject: [PATCH v4 3/5] rcu/tree: Make FQS complaining about offline CPU more aggressive Date: Fri, 7 Aug 2020 13:07:20 -0400 Message-Id: <20200807170722.2897328-4-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 The FQS loop detecting that an offline CPU has not yet reported a quiescent state, is a serious problem. The current interaction between RCU quiescent-state reporting and CPU-hotplug operations means that the FQS loop should never find that an offline CPU (by RCU's understanding of what is offline or not) has not yet reported a quiescent state. First, the outgoing CPU explicitly reports a quiescent state if needed in rcu_report_dead(). 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 in rcu_gp_init(). Third, the CPU's leaf rcu_node structure's ->lock serializes these modifications and checks. At the moment, the FQS loop detections this anomaly but only reports it after a second has elapsed. This commit therefore makes the warning more aggressive such that we fail immediately when the FQS loop scan happens and bring the problem to everyone's attention. Light testing with TREE03 and hotplug shows no warnings. Converted the warning as well to WARN_ON_ONCE() to reduce log spam. Signed-off-by: Joel Fernandes (Google) --- kernel/rcu/tree.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 2fb66cdbfa25..850628aba813 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -1208,13 +1208,27 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp) return 1; } - /* If waiting too long on an offline CPU, complain. */ - if (!(rdp->grpmask & rcu_rnp_online_cpus(rnp)) && - time_after(jiffies, rcu_state.gp_start + HZ)) { + /* + * Complain if an offline CPU by RCU's hotplug bookkeeping has not + * reported a quiescent state yet. + * + * Either a quiescent state for the offline CPU should have been + * reported during CPU offlining, or during rcu_gp_init() if it + * detected a race with either CPU offlining or task unblocking on a + * node with all of its CPUs previously offlined. If neither of these + * happened, we have a problem. + * + * The node lock is held here, ensuring exclusion from the + * modification/checking of RCU's hotplug books by RCU's hotplug + * notifier hooks and grace period initialization code. + * + * Refer to RCU's Requirements documentation about hotplug requirements + * as well. + */ + if (WARN_ON_ONCE(!(rdp->grpmask & rcu_rnp_online_cpus(rnp)))) { bool onl; struct rcu_node *rnp1; - WARN_ON(1); /* Offline CPUs are supposed to report QS! */ pr_info("%s: grp: %d-%d level: %d ->gp_seq %ld ->completedqs %ld\n", __func__, rnp->grplo, rnp->grphi, rnp->level, (long)rnp->gp_seq, (long)rnp->completedqs); -- 2.28.0.236.gb10cc79966-goog