From nobody Mon Apr 6 21:27:06 2026 Received: from va-1-114.ptr.blmpb.com (va-1-114.ptr.blmpb.com [209.127.230.114]) (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 E37722EA16A for ; Wed, 18 Mar 2026 04:57:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.127.230.114 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773809881; cv=none; b=K3HKxk3DGVKMMPwkIdmr4dtxZ1ji2spk6oYULAK/GCAO/6HaLbB63F3aazLY4QqH9DWEZDvZKmMAsqrfhmX8xf8XltJnurBvXKlxXD4hgmO3qWt065kK8Dp1ty8Lb5vOdxhLqw/AwTGM1bMEnL3wcnq9J/SnNgzBs+D5RvzjcFY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773809881; c=relaxed/simple; bh=BUQMpQd8u4yUUj234WDO6+aggVbiGFe/pxhvaD81hJA=; h=Message-Id:Mime-Version:In-Reply-To:Cc:From:Content-Type:To: References:Subject:Date; b=KoPekEBNW8LuA7cU4A6xQhk9WV+BU6CnRHYY709JcmpjADIiDCoH9qpBg5U7J9Mjgv773jjmlhXz80tSVN4x1gzq8bi86T1ciOYkTz1yD/Gm1IKx9QgKw1zvYvgqRD6uKsnbpCQdPLHtr9QcsDiD5GsrxuVGPHYGZXYiW2trw8o= 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=NvSR84l9; arc=none smtp.client-ip=209.127.230.114 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="NvSR84l9" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1773809875; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=3XTAwPdhGZK2OUqdl9lebTQ6K/gQ43T09kCwqsH/4Gg=; b=NvSR84l9Ul3Ci9jxM1oVJA4Cx6HEKrCgPMAe2crYWSUMJLhLok4w9jQwRXW71iZx3G9+cb xlYy9mCJnkjeYKGYgy0JvJ1TvWFxxhhH+wljyo0d5RDThxOzOAYXDjPYwMW7lh/8thL+WG 3XBquo5Ah5lmdWxQhowGM1hIdwuXNofMNzwBN+VYt8zz/qtN0SXxZqFKXVj0jKsljzKHJd pH4l3ZFG4F9kv0/+iyS1DFGzA4pqqYPlgXUxSRVB6RFcY99Y0wEPf7zbkTb0tVxhS2adx9 neyjR0IbztJJK5y27z812OAz8yhHBie2jV5//+BxkrqkmkmUXdsKYpn7ZLsQBQ== Message-Id: <20260318045638.1572777-3-zhouchuyi@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 In-Reply-To: <20260318045638.1572777-1-zhouchuyi@bytedance.com> Cc: , "Chuyi Zhou" From: "Chuyi Zhou" To: , , , , , , , , , , , X-Mailer: git-send-email 2.20.1 X-Original-From: Chuyi Zhou References: <20260318045638.1572777-1-zhouchuyi@bytedance.com> Subject: [PATCH v3 02/12] smp: Enable preemption early in smp_call_function_single Date: Wed, 18 Mar 2026 12:56:28 +0800 Content-Transfer-Encoding: quoted-printable X-Lms-Return-Path: 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 Reviewed-by: Steven Rostedt (Google) --- kernel/smp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kernel/smp.c b/kernel/smp.c index fc1f7a964616..b603d4229f95 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -685,11 +685,16 @@ int smp_call_function_single(int cpu, smp_call_func_t= func, void *info, =20 err =3D generic_exec_single(cpu, csd); =20 + /* + * @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