From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-189.mta0.migadu.com (out-189.mta0.migadu.com [91.218.175.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC89E3D565D for ; Tue, 10 Mar 2026 07:05:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.189 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773126327; cv=none; b=LAPAFHyF0vEVbyt/1GJfDjiHT7vEHyXVoh4w9ck5rMYUFYizUagLuLlBGVJckkhiKeKq89QcdGBujIe7LFqb800IjiLwbF1W9XWLiUYUGn5YySkG9eqMWylywEtB9R6gveCNGtvjmMJgNVZybHBIThcE/qXwJ+eCh7Bt4h+9vSA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773126327; c=relaxed/simple; bh=RyAOgp/ussi4asa0k5F2qne/Lwop2Onhn/YOGh6jwuA=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=E9qNdK7jGKiCSQzRSP2d5dkdJ2GQvHz6D2s5yfeg8WmJePRdF7JrwSgp0yzrO50CX5j+aY51Mz+AnNhxbL6a2aJzU3i/FKPqL3oUuqlR6GIAkhdD7yt4EDTxJPVYxs86cwXcWd/UFKrRD5bOFy80BUWdL8M5+F5PVNc1Bb+Sntc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Sr98OBKG; arc=none smtp.client-ip=91.218.175.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Sr98OBKG" Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1773126322; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lStYkbrWpO5nw0Q7n3KN0jheeXu63B87AtD9hg89drE=; b=Sr98OBKG88uJyCG4z0Y3vDlxHUBlR1Mvgql8h4hoOTMn/MfkBZm/iC8+4B8a2ER7ZKvKF7 0F+zTBdQhuQYNxsdC48jrGPMcih/oMo/A1ee5aFsIXjYlDDDfonjemMzljuFjjE/c/58T1 0ML1V7elRZvl8s9DhDqe+6gURKNlues= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: Re: [PATCH v2 05/12] smp: Free call_function_data via RCU in smpcfd_dead_cpu X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <20260302075216.2170675-6-zhouchuyi@bytedance.com> Date: Tue, 10 Mar 2026 15:05:02 +0800 Cc: tglx@linutronix.de, mingo@redhat.com, luto@kernel.org, peterz@infradead.org, paulmck@kernel.org, bp@alien8.de, dave.hansen@linux.intel.com, pbonzini@redhat.com, bigeasy@linutronix.de, clrkwllms@kernel.org, rostedt@goodmis.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <2A193780-53DC-469A-B770-8AA5B97C7D7E@linux.dev> References: <20260302075216.2170675-1-zhouchuyi@bytedance.com> <20260302075216.2170675-6-zhouchuyi@bytedance.com> To: Chuyi Zhou X-Migadu-Flow: FLOW_OUT > On Mar 2, 2026, at 15:52, Chuyi Zhou wrote: >=20 > Use rcu_read_lock to protect the hole scope of = smp_call_function_many_cond ^ whole BTW, The protection we often refer to actually pertains to data, not = code. Therefore, the rcu_read_lock() here is actually preventing = smp_call_function_many_cond() from accessing percpu csd data that has already been freed (which is what smpcfd_dead_cpu() does). > 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(). >=20 > Signed-off-by: Chuyi Zhou > --- > kernel/smp.c | 3 +++ > 1 file changed, 3 insertions(+) >=20 > 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 =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 cpumask *mask, >=20 > lockdep_assert_preemption_disabled(); >=20 > + rcu_read_lock(); > cfd =3D this_cpu_ptr(&cfd_data); > cpumask =3D cfd->cpumask; >=20 > @@ -907,6 +909,7 @@ static void smp_call_function_many_cond(const = struct cpumask *mask, >=20 > if (preemptible_wait) > free_cpumask_var(cpumask_stack); > + rcu_read_unlock(); We could call rcu_read_unlock() before free_cpumask_var() above. > } >=20 > /** > --=20 > 2.20.1