Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp744499rdb; Fri, 8 Sep 2023 15:20:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+lDNebiMqRWgx5IMwfE1lja6dwyIqcKerpzPtrsZbQToYyF1Bb9LQ//EOKiZIn7d3snPR X-Received: by 2002:a05:6512:3454:b0:500:b828:7a04 with SMTP id j20-20020a056512345400b00500b8287a04mr2403667lfr.18.1694211622169; Fri, 08 Sep 2023 15:20:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694211622; cv=none; d=google.com; s=arc-20160816; b=DBKWIIDWDE8v5DurXIgsHS2Qctw3YEuO7yd2LWG7JIOb3MGDK42rMPBAv9WY4RlcMb P9VzLQqbH2Cf7dPw7gwUWH5bbBLtM6OENQ69qAIKMb7a/CRyu5qoOt108/kQAw9aLbdi dM6RCONf9VPFGlnwspsCuDSup/zsIsFtWfj3EkLj1XgCeBODanzndFQ4pTb45LuoWEya 5DKeE8YKx95pN1d9e0KUmx5QphSdUwLwHZgGPgit+oRLPBWC3zt2NUnB06IJ/NYX+hcT eC4Jy+YaWXezsEOFn24/Ihj1IO77HFQLMRr9rYbhtqxn26hgUTiOFv1DDydFdrwluDqV 0QwQ== 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=aZFlG0htBrFMQ8FbpoWCt1rpXGn0Qzewb1RH8m7DXXQ=; fh=b/0dXqvz0kAo+07ch4KNz5dZ+JhJoOmBzkQIhQsuGPg=; b=a9G9rmEikH4iXmSD/ocQFphO1txbPsiEUf/Crv+da7Mp4I61fPhLbOBxMbY82qDYzJ 9+a+OIZYxHPaXAzxs3w5DeXhy4JE3jMIVPD8znZP2EnzsqsXpP6wYCGGUbG7l4p0Uqmr vtrEh5EqV6EdoD90Au3rHGgNrqJC8MV9SqRKk7Fmv1Q5afBukfL86B8EC4IU34PD0bEQ 1Hkeg1Zcg77rEYna+m+FCa65yrluPZNdidxJPnNX0wuINgUQ3uaYgBKn3m3Kjf+KIEgj 1kqSTrgoztZbYyJRp0hjBOsAJkExCYORPkN3pafaJ0NrYaG/rWzD1GjP9uSyUBUI9gzm MOvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W0tN5Z7T; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p15-20020aa7d30f000000b005233d0a02absi2173689edq.29.2023.09.08.15.19.47; Fri, 08 Sep 2023 15:20:22 -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=W0tN5Z7T; 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 S1344529AbjIHUgj (ORCPT + 99 others); Fri, 8 Sep 2023 16:36:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344285AbjIHUgg (ORCPT ); Fri, 8 Sep 2023 16:36:36 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 741CDB2; Fri, 8 Sep 2023 13:36:28 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 015D5C433C8; Fri, 8 Sep 2023 20:36:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694205388; bh=6boxuA0q94N/Ed+FRmKuiKbsWIdOVvAtoMhIDXQWL44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W0tN5Z7ThROb64K9jyX34QkgwAALEzcAns/+NdYr90LdFK4qlApeyiX12brzy/q1Z xtUNO3D1oO7VhYvbSnBBfY90lVEvyjeiSTm1lDZwPEKJ6mEXMibG9Vju2jQ4Klu5A1 MSuWCIbVW2aV1NLRgiCQ+HLQx8CeI65oLeaH13dDy4afo33GwMcoy2U+XSJVdI/Y5r uDdJZlssMSyon4VQFqcMsRSIk/H0CQgYhna8wMQS2FBF43lcQYkqSlo6fjtFBRCWA5 N3HTM5Wwb+V/7ciWUCq7aV7DagAoXGH+e5Vcw+l2/vvO7W6Z/IqJ2XShVJZBa3gahS wY/u8smjc9tUQ== From: Frederic Weisbecker To: "Paul E . McKenney" Cc: LKML , Frederic Weisbecker , rcu , Uladzislau Rezki , Neeraj Upadhyay , Boqun Feng , Joel Fernandes Subject: [PATCH 06/10] rcu: Assume rcu_report_dead() is always called locally Date: Fri, 8 Sep 2023 22:35:59 +0200 Message-ID: <20230908203603.5865-7-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 Content-Transfer-Encoding: 8bit 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 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 --- 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