From patchwork Fri Sep 8 20:35:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 137807 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp823952vqo; Fri, 8 Sep 2023 15:27:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0FT6jc6ZMmcvME9sfVu2eFVkWVILkFlxTRPDuBHJETqg4zrtFH4o9mWD6jMdLhgwNzusa X-Received: by 2002:a05:6808:1908:b0:3a7:f153:b5e5 with SMTP id bf8-20020a056808190800b003a7f153b5e5mr4600988oib.29.1694212025037; Fri, 08 Sep 2023 15:27:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694212025; cv=none; d=google.com; s=arc-20160816; b=iDUBgjpIKPByimcIYcmSYdNrv7t8SwrKrkM09PJScSk7L80BecmA9XmqB7p7JlK+q6 c9wznUtDmL/p1aCta5z2ig/f0Etge/tILfVbAr3gqGsE0E5560ASdtmSS5PvS1Klg6lE V7c7pxmUITA+lu8+F0stP6QruxF5blxlxzmjcpCBAbk0qj2qInwSujHhmM3ZhsA5+amH TkDNlqVZrANjtNj6a7A2nKu3rPCnIX4eq9zSxbP3SQidYJlP6PwVkU7NNlofpJATufHe EgYvRHT0mtezqtOKUjAanb8St3p/tA5+Prc9DllfbXySfPaVM8EnC8rXtRrpc+dTWkNi Y9tw== 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=yLQ+CqQpaJKz7DH/yVrEy8muqSdGGO8889JEDJZrkxg=; fh=b/0dXqvz0kAo+07ch4KNz5dZ+JhJoOmBzkQIhQsuGPg=; b=xOtVkEiKOryKZvwqtPU5mkqVRfvVg/hhVAJq7Nt24Q65Rlr1Omr4BofTrLiQJ6vZ5Z WYIgH24gFxJmYkrVELNsnENwcWsXgOTycSMhqgp3B/MZNmXAxuCC5cNgxGHhDO9reOag eaXPJxLJgTqXdWulY5Mb8h4x42KqPi+Le4jToNN+CqVXaxtf60LVQPeC/yUzOCOmaxXa yEfo+I9772VkmNsEnpuq9L63xw7/Bv+nrfqOC/aHZzGlKJNzFpSkRc9kGLHFNx4It9Of LVqnqm+PTUJ2txrAv/k+Kxm7vEJqTaRpA9hrtlJ84GD5g7xvnOzJYvitSfunksySUFaO uCfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="XPpmn/Dm"; 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 m187-20020a6326c4000000b00573fcfe9f19si2117473pgm.283.2023.09.08.15.26.57; Fri, 08 Sep 2023 15:27:04 -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="XPpmn/Dm"; 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 S1344384AbjIHUgc (ORCPT + 39 others); Fri, 8 Sep 2023 16:36:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344240AbjIHUgb (ORCPT ); Fri, 8 Sep 2023 16:36:31 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC3A012B; Fri, 8 Sep 2023 13:36:25 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76BFAC433CB; Fri, 8 Sep 2023 20:36:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694205385; bh=jDNkBDS/qfTFPfcD21qgFaMBxLKgVcToMO54awbM3I4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XPpmn/DmCtFxr+xOeItYC9TcDzjbNDWMr9tkF5K68mh93CaOUVS5q+SXn34MRwg9p GJjYK8PJkQIAboGENjtWkb7uQcNgNSgj45hYcaFXtwRD3k3VO2CB4bwW6QvcPlHZfk tMhmVecVYjMgKebTkthKhWjWVslirLZDQlzxQP5vyJdoQZOcge6ViG7K0ZZ0ZDF25T u/J7PusNlWTRFA4XibyAsebL4M5iBbucAdfutwlqOmPIh9dR3okAfeyi0m2tMon0be IAun0m6SUAEBCBgT9QvIOzRCIrTjBkwuTjBU4tj+WZlB+Slygkaefigt4U7PvOjgNH 6KuRh5JvkTvlg== From: Frederic Weisbecker To: "Paul E . McKenney" Cc: LKML , Frederic Weisbecker , rcu , Uladzislau Rezki , Neeraj Upadhyay , Boqun Feng , Joel Fernandes Subject: [PATCH 05/10] rcu: Assume IRQS disabled from rcu_report_dead() Date: Fri, 8 Sep 2023 22:35:58 +0200 Message-ID: <20230908203603.5865-6-frederic@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908203603.5865-1-frederic@kernel.org> References: <20230908203603.5865-1-frederic@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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: INBOX X-GMAIL-THRID: 1776510068199808218 X-GMAIL-MSGID: 1776510068199808218 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. Reviewed-by: Joel Fernandes (Google) Signed-off-by: Frederic Weisbecker Reviewed-by: Paul E. McKenney --- 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 a83ecab77917..8b5ebef32e17 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -4553,11 +4553,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); @@ -4565,7 +4570,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); @@ -4579,8 +4583,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; }