From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sg-1-104.ptr.blmpb.com (sg-1-104.ptr.blmpb.com [118.26.132.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1FBA212B0A for ; Mon, 2 Mar 2026 07:53:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=118.26.132.104 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772438041; cv=none; b=M5wXVu4zJu8+PB5REaUjKmzNSkO20Y0tGSmXjKtUZRMbcFq8QkRoHPocblirR9g75UU9DEt97lMdNbhyGqc+E0vBTjhtLOh2iwZl2r/Oix7pYOzEQ396Gb6KKsgfCpgGT7F3piblCN9vQ9s1pPvZh3cmhNRiEI7Nnja6Fcdv9VA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772438041; c=relaxed/simple; bh=8pznXcKFYJvoxH8YItppNkL6UjU79rjgMSlX6zdOH1I=; h=From:References:Message-Id:Mime-Version:Content-Type:Subject: In-Reply-To:Date:To:Cc; b=C30cYzQXBFjuTuq4ShGTi3uX4lNWQy/MAVIH6sIC+VOVW4FFrFDE61ImgIeyDbN9dkvI47BTTw65tQ3as9xtXd0E8VMwibvVD7wnbrZMwSbOW2They3+b7dMUUZYc9siHDVgeDZoCIXtJbLlecVrJIHAYo5XdjcHg+O61hEHm10= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=QinAPqca; arc=none smtp.client-ip=118.26.132.104 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="QinAPqca" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1772438028; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=1rbj8jBDHrec0FdITBc5ycuECF8/Wgdmn0NL2xBzeZQ=; b=QinAPqcafuBeVQWAsAC/BGxCT5rm+2qFy7O4LWDHA4fxBkxTWgBiYaUl4j8xgOgh9/7Y5T p+vYogZvvt35H3OnbIq46XifJxSmS6ZZu8e3EEBy2ilxZVOjuOiEhTjpWDk+HktBI/dI4t JMiBPtwhSqPW0QqpzBMEUr7+USXe6HQWKzkKxEMpZfGYBHYYSEjP8DuOEiC7T8cRQJH2hZ MpcobpoHDItBuItlznxeMZnNHf2FxFeMKawOtszLpW1AQZC7EsYJJGXmS6AMjq0r4QLSa4 r0ctnNCW0KUnmocnk7vAwZ/Uz5MR/OnFMDtaljwC1yiV9G9CrwVsxoY6N7eKyw== Content-Transfer-Encoding: 7bit From: "Chuyi Zhou" X-Original-From: Chuyi Zhou References: <20260302075216.2170675-1-zhouchuyi@bytedance.com> Message-Id: <20260302075216.2170675-6-zhouchuyi@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Lms-Return-Path: X-Mailer: git-send-email 2.20.1 Content-Type: text/plain; charset=UTF-8 Subject: [PATCH v2 05/12] smp: Free call_function_data via RCU in smpcfd_dead_cpu In-Reply-To: <20260302075216.2170675-1-zhouchuyi@bytedance.com> Date: Mon, 2 Mar 2026 15:52:09 +0800 To: , , , , , , , , , , , Cc: , "Chuyi Zhou" Use rcu_read_lock to protect the hole scope of smp_call_function_many_cond and wait for all read critical sections to exit before releasing percpu csd data. This is a preparation for enabling preemption during csd_lock_wait(). Signed-off-by: Chuyi Zhou --- kernel/smp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/smp.c b/kernel/smp.c index 9728ba55944d..ad6073b71bbd 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -77,6 +77,7 @@ int smpcfd_dead_cpu(unsigned int cpu) { struct call_function_data *cfd = &per_cpu(cfd_data, cpu); + synchronize_rcu(); free_cpumask_var(cfd->cpumask); free_cpumask_var(cfd->cpumask_ipi); free_percpu(cfd->csd); @@ -810,6 +811,7 @@ static void smp_call_function_many_cond(const struct cpumask *mask, lockdep_assert_preemption_disabled(); + rcu_read_lock(); cfd = this_cpu_ptr(&cfd_data); cpumask = cfd->cpumask; @@ -907,6 +909,7 @@ static void smp_call_function_many_cond(const struct cpumask *mask, if (preemptible_wait) free_cpumask_var(cpumask_stack); + rcu_read_unlock(); } /** -- 2.20.1