From nobody Tue Feb 10 00:57:52 2026 Received: from sg-1-101.ptr.blmpb.com (sg-1-101.ptr.blmpb.com [118.26.132.101]) (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 894282D249B for ; Tue, 3 Feb 2026 11:27:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=118.26.132.101 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770118039; cv=none; b=Dc+m9YhPqnBQ+H+xdRxxadWB6lfG9Zc4wIuvFDMWSAAdxPwFA8C5N3WFdWHqEzmdz50HMEx6SX5CmVhSoO1iOOcDAvBNfJtov1nzXYUoDZhp1iXXbniKb3tiJilwkwBH+02f67X+fsEtrQm3HjYTDZNEwR8RpkZdo9fFXQVLShE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770118039; c=relaxed/simple; bh=Q1P6izkVvYjrmOeu+q9ERUgfKxN3fmxiLcTLNClinWs=; h=Subject:Message-Id:Content-Type:References:To:In-Reply-To:Cc:From: Date:Mime-Version; b=f72F2e+u3Cc0KdNnzG8zexwJRwZ0d2gmbHu9JgfEmBI0WBehIzX0NBfrY4GDKbBcQetu7QUamkpRKjX3kg91uwmBfgWBUrxiKZ8jKJ2E37wQDZoHKOrlKTNGiuMc+KptZ4aYZ+PSkxDX0PqzBei2/ot57ItBYEGSF7NCZjlqhBo= 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=eTMwVFQ0; arc=none smtp.client-ip=118.26.132.101 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="eTMwVFQ0" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1770117916; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=08BXau/MsSHycfubVqb8Ektt5Nkz6Dg6w0xeBIf+a7Y=; b=eTMwVFQ00RCyl5yq/BpIVAD4AATnkLw77ko53zrmarptjF6do1xjqbWvNTb/ZBUDx2jrLX i5UU12te4BQ9RXURJfKomDWG4opfoRJdxBfpd58wVuAGertpVBE/mTiUrWk6o8L/ERa4sA CxeyodRWZdPYEiYrRFkFjm+JDOhasMBTyCO2cgAANYznVZjIuGtvKcy2rkVEeWUxyAN4y9 MlFoeOAIOHtz4Pha3dER0d9VZjY+x/UrvUSfG2rnJgjNx6rPN6L41Fiu6bKlTKJuGx4fJ7 YJKKMNMDQq6Y/DpByyCrE6aKVTIyhXYjBVNK3j/VTDazVoYoeLtdgutH4zdI1A== Subject: [PATCH 02/11] smp: Enable preemption early in smp_call_function_single Message-Id: <20260203112401.3889029-3-zhouchuyi@bytedance.com> X-Mailer: git-send-email 2.20.1 References: <20260203112401.3889029-1-zhouchuyi@bytedance.com> X-Lms-Return-Path: To: , , , , , , , In-Reply-To: <20260203112401.3889029-1-zhouchuyi@bytedance.com> Cc: , "Chuyi Zhou" From: "Chuyi Zhou" Date: Tue, 3 Feb 2026 19:23:52 +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 X-Original-From: Chuyi Zhou Content-Type: text/plain; charset="utf-8" Now smp_call_function_single() disables preemption mainly for the following reasons: - To protect the per-cpu csd_data from concurrent modification by other tasks on the current CPU in the !wait case. For the wait case, synchronization is not a concern as on-stack csd is used. - To prevent the remote online CPU from being offlined. Specifically, we want to ensure that no new IPIs are queued after smpcfd_dying_cpu() has finished. Disabling preemption for the entire execution is unnecessary, especially csd_lock_wait() part does not require preemption protection. This patch enables preemption before csd_lock_wait() to reduce the preemption-disabled critical section. Signed-off-by: Chuyi Zhou Reviewed-by: Muchun Song --- kernel/smp.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/kernel/smp.c b/kernel/smp.c index fc1f7a964616..0858553f3666 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -685,11 +685,24 @@ int smp_call_function_single(int cpu, smp_call_func_t= func, void *info, =20 err =3D generic_exec_single(cpu, csd); =20 + /* + * We may block in csd_lock_wait() for a significant amount of time (e.g.= , if the + * remote CPU has interrupts disabled). Disabling preemption throughout t= he entire + * smp_call_function_single() impacts the scheduling latency and is unnec= essary. + * + * - Preemption must be disabled before sending the IPI to ensure no new = IPIs are + * queued after smpcfd_dying_cpu() finishes. + * + * @csd is stack-allocated when @wait is true. No concurrent access except + * from the IPI completion path, so we can re-enable preemption early + * to reduce latency. + * + */ + put_cpu(); + if (wait) csd_lock_wait(csd); =20 - put_cpu(); - return err; } EXPORT_SYMBOL(smp_call_function_single); --=20 2.20.1