From patchwork Wed May 31 10:17:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 101333 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2771004vqr; Wed, 31 May 2023 03:24:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ42AZZEiBn06mGuDMI5psYuKPfyVltR6zOAWoBuAoasX9YC22Rz+T/Y8fX02RVNMAw9dpyO X-Received: by 2002:a92:cecc:0:b0:33a:a6de:65b3 with SMTP id z12-20020a92cecc000000b0033aa6de65b3mr1964905ilq.0.1685528653802; Wed, 31 May 2023 03:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685528653; cv=none; d=google.com; s=arc-20160816; b=wRp9OZRA5Vz1t6ht+9BZ8Snewq1T+d4ZJP4itdGtPGUbbKTicgK+KSnUX9oeuR1fb5 fh77S8EXQy/jWYQSuo8rI3IP5QfQ1vq1QTh9gpqOkvbiUl1J3WK+JVAbdy84Bjgmanui a/sEBwLRLBkaxRC3II7RDLT31Z7I2jIXMEbtSjTismMonOgfoeYwuEc8MTYC4hquRjHP 2j6NxLkuK894tKkS72udI3byFGemqg+rGQTlBKWkAQM3/ezK+TvK0mJc/1NfGiBMS0fu +fk+MVSLK5SIQT1aWvJ85Xteqd+rHDqpX86QtaViElj9GgKvkE2gv6nT2F2/Y4B3ekn7 P10A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nRadYpHLbyCMJ7vdaJAkH60TH1qzd1HDaBTDLGzfXSI=; b=WvCEl5MthWn/9Al9uKz2QuCoq7kTEzftpflFtUt8d04yeXHd4AQfEYnSJg90ZuhRJ9 ogmEjqbjFHnniSKAWy64gd7fydwDayly9Rx+Jb2AWaEdDZ9E/0Yj2gMv0vPE1O9BnjHU 20+nNy+VoneZT3dBbqiGOkuLBieJJEZQ68wG7UAxIzoHbCc3j4SSRYx6DPg7gWI7qJDq lgZ5OyiV/X3P1AXHikWpLdiYBuwrNBmCy83pXZ8trIWfuEs2443S0Wm41a5VwWzTTMMj 96hKxcSMEXbpHg+f3dQrGjbSdXtDkORFPHsyj5R4tKAOUgL5nxnbFM6FpC9k4g1xX13x BVPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K++9WA8Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c12-20020a170903234c00b001aae82caf75si691631plh.66.2023.05.31.03.23.59; Wed, 31 May 2023 03:24:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K++9WA8Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S235853AbjEaKSB (ORCPT + 99 others); Wed, 31 May 2023 06:18:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235400AbjEaKRw (ORCPT ); Wed, 31 May 2023 06:17:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12699134; Wed, 31 May 2023 03:17:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 94FB860EFE; Wed, 31 May 2023 10:17:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB99EC4339C; Wed, 31 May 2023 10:17:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685528270; bh=DNw6SN2JUww7kf2Xz6WH9RgMFZWQt8aiAF4n3naxZ8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K++9WA8Zkr7l786Wuf62fwfUApIVGQi01biW6e8wGwQHBKgrpQAKkzLRVNJ9FJFEb 6q65BxMPjwToVuIYiLjc0tsamZrX2LVeun2tYJtaXb1oIs4VZ8f5zNynUVKIFo9Wzf 7Jp3q2wWzb5lwsh8j8K1CD0ggFseQ83QSaFCPehYErbXWv0Yt9ZbL3UfGolFiebYxL vwQS/eSA+ngbVol48R179tOYHhEdlXk0rd5tGNlytVY1fbLl6TGPabqkXjSJASlMwr +nWW1+WF/4o4WreAbpmiay1sUBGK2cZsdmmmneQyDHfkZLVJYvUejCepARivd4PRwJ 52LgxlEAwMn/w== From: Frederic Weisbecker To: "Paul E . McKenney" Cc: LKML , Frederic Weisbecker , rcu , Uladzislau Rezki , Neeraj Upadhyay , Joel Fernandes , Giovanni Gherdovich Subject: [PATCH 1/9] rcu: Assume IRQS disabled from rcu_report_dead() Date: Wed, 31 May 2023 12:17:28 +0200 Message-Id: <20230531101736.12981-2-frederic@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230531101736.12981-1-frederic@kernel.org> References: <20230531101736.12981-1-frederic@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767404893255047717?= X-GMAIL-MSGID: =?utf-8?q?1767404893255047717?= rcu_report_dead() is the last RCU word from the CPU down through the hotplug path. It is called in the idle loop right before the CPU shuts down for good. Because it removes the CPU from the grace period state machine and reports an ultimate quiescent state if necessary, no further use of RCU is allowed. Therefore it is expected that IRQs are disabled upon calling this function and are not to be re-enabled again until the CPU shuts down. Remove the IRQs disablement from that function and verify instead that it is actually called with IRQs disabled as it is expected at that special point in the idle path. Signed-off-by: Frederic Weisbecker Reviewed-by: Joel Fernandes (Google) --- kernel/rcu/tree.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index fae9b4e29c93..bc4e7c9b51cb 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -4476,11 +4476,16 @@ void rcu_cpu_starting(unsigned int cpu) */ void rcu_report_dead(unsigned int cpu) { - unsigned long flags, seq_flags; + unsigned long flags; unsigned long mask; struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu); struct rcu_node *rnp = rdp->mynode; /* Outgoing CPU's rdp & rnp. */ + /* + * IRQS must be disabled from now on and until the CPU dies, or an interrupt + * may introduce a new READ-side while it is actually off the QS masks. + */ + lockdep_assert_irqs_disabled(); // Do any dangling deferred wakeups. do_nocb_deferred_wakeup(rdp); @@ -4488,7 +4493,6 @@ void rcu_report_dead(unsigned int cpu) /* Remove outgoing CPU from mask in the leaf rcu_node structure. */ mask = rdp->grpmask; - local_irq_save(seq_flags); arch_spin_lock(&rcu_state.ofl_lock); raw_spin_lock_irqsave_rcu_node(rnp, flags); /* Enforce GP memory-order guarantee. */ rdp->rcu_ofl_gp_seq = READ_ONCE(rcu_state.gp_seq); @@ -4502,8 +4506,6 @@ void rcu_report_dead(unsigned int cpu) WRITE_ONCE(rnp->qsmaskinitnext, rnp->qsmaskinitnext & ~mask); raw_spin_unlock_irqrestore_rcu_node(rnp, flags); arch_spin_unlock(&rcu_state.ofl_lock); - local_irq_restore(seq_flags); - rdp->cpu_started = false; }