Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1448479rdb; Mon, 2 Oct 2023 09:45:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYNuGYIuN3vYMfkWYZG2G/KsI+puNNkNk2EQmQJVVDqQZBhej+rrOQQjgxpqDphYlvzPld X-Received: by 2002:a17:902:f80a:b0:1c0:cb4d:df7c with SMTP id ix10-20020a170902f80a00b001c0cb4ddf7cmr10174704plb.1.1696265137354; Mon, 02 Oct 2023 09:45:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696265137; cv=none; d=google.com; s=arc-20160816; b=rQK/WO6DUoR8IJjDLscgEDUIiAY25phEfTXMPQoAiuR66BjpzglGOXxlvrLb+sQq3z GX6ARYiJchkjknSuIsD11cKSJjwr6v+2WSIPQx6R+o9AXhhjNApWZPn6pExYjd1IWkYN Hms04SCkwsbxsbSuyR7jdS8lcYBEAfP7fa+FnORntvfxWJxMLO1T8RN8lU3If2zrZLOa ha+g+9eXHbYozhk9siKcQ7lO9Vlc3mc1/UrTuPiAbjRK+POSw9EPIGQkCHhKGF3nyhwr ywkl4dvD+aOCuIhJyDvolNgle0F2HOqSg9NyjECwaYN1fclF8mnIdE/TEr4i3bboxIh4 S2kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=9Vi10BEgKCTX2qbRzMCxGcFJq6JjdHqTcAdygRhHhaY=; fh=vvIxxotwr/5I3LAaua/faPKkOqW5Gug4vtwueRdQQCg=; b=aDAwbrc/goErxIWZmgoPuCbLZ0rLbItzKvpT8/AOXzsfIXtYqVtUMADbvtJFFFpTBV wTgW6W1jTTgQE+MUjHfzjhpmj0bEAgrP4YcHiXhaWS0IjLhlWUqt1VZaJOP93k3oRgWj 2/k+TAlU2dLypN+INbcvUC4ZG1tOxCENrH5j4LfXmlM+SBql8ywixyKOi4Ahlke6VGak lbkLLB6oK204Acek9e39PcyjoZubvjPkPUJtb/2kplLKN9MWG7QOUsTA8sLpGxnmJ2Uo +oBsjMxbSJE4mFT8CJq9vM6XTC9QcyDZ8i7xx4gELINVn+Ys3TVtKokrZcrwrrkrAIIk FeeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UzcgrRZT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id lo5-20020a170903434500b001c62b51ac0fsi16113261plb.306.2023.10.02.09.45.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 09:45:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UzcgrRZT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 4CC448072580; Mon, 2 Oct 2023 08:45:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238211AbjJBPpk (ORCPT + 99 others); Mon, 2 Oct 2023 11:45:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238155AbjJBPpj (ORCPT ); Mon, 2 Oct 2023 11:45:39 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02581A4; Mon, 2 Oct 2023 08:45:36 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96035C433C7; Mon, 2 Oct 2023 15:45:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696261535; bh=gnflgoj/4t5aXhvqE1jJ7nBMN1dHV/5laG0EVdN1cG4=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=UzcgrRZTcB0U5fChegyD+GRbZ3TS0yzcuIozm39qGUTZMC9bwD0p0pKp7XGK3ELSa Ibvgn175ol1Q+eEpdDw9zaJT+bduDTXYzOGelaXswzoHkiheBT87cZ4qp0LrupVLGE EzbS6UgbyXKX1HpAzhxIsrm57E8/FhqEEQiNyp6b+c7JXb/YwbRRsquBRYkTXW/9cR ntrTdY7z/FeoD+vTjifzO+iER9sHjddRtgfrNuOWVCDUU1rA3b/fX5TTYirM+Dn4yv kZeMAWXN8E7yb+TXKfd0+5j9ll5PKYpkXcx9LpsO59GKDYWTIa+qtacr75D/UxnUDq 3KkqkBDS0+BUA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 3A527CE0CCF; Mon, 2 Oct 2023 08:45:35 -0700 (PDT) Date: Mon, 2 Oct 2023 08:45:35 -0700 From: "Paul E. McKenney" To: Frederic Weisbecker Cc: LKML , rcu , Uladzislau Rezki , Neeraj Upadhyay , Boqun Feng , Joel Fernandes Subject: Re: [PATCH 06/10] rcu: Assume rcu_report_dead() is always called locally Message-ID: <685c5e4e-491c-4fef-b7d7-499a32158e39@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20230908203603.5865-1-frederic@kernel.org> <20230908203603.5865-7-frederic@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230908203603.5865-7-frederic@kernel.org> 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 02 Oct 2023 08:45:43 -0700 (PDT) On Fri, Sep 08, 2023 at 10:35:59PM +0200, Frederic Weisbecker wrote: > rcu_report_dead() has to be called locally by the CPU that is going to > exit the RCU state machine. Passing a cpu argument here is error-prone > and leaves the possibility for a racy remote call. > > Use local access instead. > > Signed-off-by: Frederic Weisbecker I was going to ask for an assertion for "cpu" in cpu_die_early(), but given that its value comes from smp_processor_id() just a few lines earlier, there isn't a whole lot of point to that. So: Reviewed-by: Paul E. McKenney > --- > arch/arm64/kernel/smp.c | 2 +- > include/linux/rcupdate.h | 2 +- > kernel/cpu.c | 2 +- > kernel/rcu/tree.c | 4 ++-- > 4 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > index edd63894d61e..ce672cb69f1c 100644 > --- a/arch/arm64/kernel/smp.c > +++ b/arch/arm64/kernel/smp.c > @@ -401,7 +401,7 @@ void __noreturn cpu_die_early(void) > > /* Mark this CPU absent */ > set_cpu_present(cpu, 0); > - rcu_report_dead(cpu); > + rcu_report_dead(); > > if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) { > update_cpu_boot_status(CPU_KILL_ME); > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h > index 5e5f920ade90..aa351ddcbe8d 100644 > --- a/include/linux/rcupdate.h > +++ b/include/linux/rcupdate.h > @@ -122,7 +122,7 @@ static inline void call_rcu_hurry(struct rcu_head *head, rcu_callback_t func) > void rcu_init(void); > extern int rcu_scheduler_active; > void rcu_sched_clock_irq(int user); > -void rcu_report_dead(unsigned int cpu); > +void rcu_report_dead(void); > void rcutree_migrate_callbacks(int cpu); > > #ifdef CONFIG_TASKS_RCU_GENERIC > diff --git a/kernel/cpu.c b/kernel/cpu.c > index 88a7ede322bd..86f08eafbd9f 100644 > --- a/kernel/cpu.c > +++ b/kernel/cpu.c > @@ -1368,7 +1368,7 @@ void cpuhp_report_idle_dead(void) > struct cpuhp_cpu_state *st = this_cpu_ptr(&cpuhp_state); > > BUG_ON(st->state != CPUHP_AP_OFFLINE); > - rcu_report_dead(smp_processor_id()); > + rcu_report_dead(); > st->state = CPUHP_AP_IDLE_DEAD; > /* > * We cannot call complete after rcu_report_dead() so we delegate it > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 8b5ebef32e17..289c51417cbc 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -4551,11 +4551,11 @@ void rcu_cpu_starting(unsigned int cpu) > * from the outgoing CPU rather than from the cpuhp_step mechanism. > * This is because this function must be invoked at a precise location. > */ > -void rcu_report_dead(unsigned int cpu) > +void rcu_report_dead(void) > { > unsigned long flags; > unsigned long mask; > - struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu); > + struct rcu_data *rdp = this_cpu_ptr(&rcu_data); > struct rcu_node *rnp = rdp->mynode; /* Outgoing CPU's rdp & rnp. */ > > /* > -- > 2.41.0 >