From nobody Mon Apr 6 21:20:21 2026 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 030812FB08C for ; Wed, 18 Mar 2026 04:59:20 +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=1773809962; cv=none; b=qoMSMuMM9YdX/ABOTsdfhabgHJIu+3ftMV/7ns3z0f6b2jYapooBP7dziQ8i5+eJRSoVvr9bUzXe24N7yux+aF07+DB49CSbc2sNSgSIKJK6XywRfbbtSehf97p1GeKCctzrdbIKd7j7b7um5Y7y0cavxa2PusxCDtvCH+i+Z8g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773809962; c=relaxed/simple; bh=3B8Q6Z8qPVom0wVfa/u6kST+pmSoHMdNyiVxux+JTCs=; h=To:Subject:Date:Mime-Version:From:Message-Id:References: Content-Type:Cc:In-Reply-To; b=ld87M+Xker4v6ikIkprXpGZSJhgCEX9z/2DPvJofsEple6TsnIzq11goJbNphxf4sNMl956KzYwdcGRO96COgaZATWTFTGjdBnCeycmzLlae5mJKmHKQno82iJGmYGNoBR7qHGZhzsSYKGmk4HVjEiZ17GMUrESsZ/p4h1PXZzA= 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=dajwY+5k; 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="dajwY+5k" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1773809910; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=qRbRybQjfXLTnRKgiGnZ/NjEGu5Y+VtHmSP6i6C3aeA=; b=dajwY+5kcdxvz5h/0nOxB5dwJr4p+jheXPBActQNTiIi4pExWPO0wEbzvWqK5EuPQVS+1l 2d3ChYf1qelkYsjqyIHhaaMFlTJUOhvootfuQU8pClOlLpOonbC/o7mxAgj8BwTgYSVo2U Y9YArUDOhQblemjBZ4cOif+WOKznvEv2XhpNA64egM91msrvXVDxU2bZDN2Sd7dp8dVxLt cTUaUkPcvhWwnrL4wMAh8T5/Unw2ujWVlQzsGXLkM0dJhUgdXqZWbqA4BRvKf2cKOdvZXy w2eACEW+uAlhC0spFdUxsyACZUH3Z+dhOn2Y1bNK0wOC8tbXD5i4WCHc0QKngA== To: , , , , , , , , , , , Subject: [PATCH v3 05/12] smp: Free call_function_data via RCU in smpcfd_dead_cpu Date: Wed, 18 Mar 2026 12:56:31 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: "Chuyi Zhou" Message-Id: <20260318045638.1572777-6-zhouchuyi@bytedance.com> References: <20260318045638.1572777-1-zhouchuyi@bytedance.com> Cc: , "Chuyi Zhou" X-Lms-Return-Path: X-Mailer: git-send-email 2.20.1 X-Original-From: Chuyi Zhou In-Reply-To: <20260318045638.1572777-1-zhouchuyi@bytedance.com> Content-Type: text/plain; charset="utf-8" Use rcu_read_lock() to protect csd in smp_call_function_many_cond() and wait for all read critical sections to exit before releasing percpu csd data. This is preparation for enabling preemption during csd_lock_wait() and can prevent accessing cfd->csd data that has already been freed in smpcfd_dead_cpu(). 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..32c293d8be0e 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 =3D &per_cpu(cfd_data, cpu); =20 + 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 cp= umask *mask, =20 lockdep_assert_preemption_disabled(); =20 + rcu_read_lock(); cfd =3D this_cpu_ptr(&cfd_data); cpumask =3D cfd->cpumask; =20 @@ -905,6 +907,7 @@ static void smp_call_function_many_cond(const struct cp= umask *mask, } } =20 + rcu_read_unlock(); if (preemptible_wait) free_cpumask_var(cpumask_stack); } --=20 2.20.1