From nobody Wed Apr 1 11:21:48 2026 Received: from va-1-115.ptr.blmpb.com (va-1-115.ptr.blmpb.com [209.127.230.115]) (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 1E4163090E2 for ; Tue, 31 Mar 2026 11:32:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.127.230.115 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774956726; cv=none; b=YpAgmSPBxwP3ETiD6zkZORbYhqx4rHCKuOCSGx6nNfcGHULy+LaxGfkyqLqPShuOoCU791fFmULPnmWNjmMLNT7vyE9D44+E06enqrpZUcilKzjKuzkFc4HWZFUUiZM2fk7altL6ONVrWaxKRoi/VAxssfDy58PF7wz9gWES8q8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774956726; c=relaxed/simple; bh=LldljtaPW5ZtrUdVB5DF65oiNbDI86xEp7E1a1JNrg8=; h=From:Message-Id:To:Cc:Mime-Version:In-Reply-To:Date:Subject: References:Content-Type; b=aX86FYokoXz8QboMs86dm7f1sOjEAKGzBKjtCh+BWzToksCHdsbXkeXVCJ/zn4Tn6GPnoCKiWM1lVQhlf6xixe073J3BZMVDNnE7dF+yGzh2Jymr3lsK18ehGgM2E8uS8SKVgEBh1RVtQN+k6sFH3Y3mzZpKeOPrZaRanw9HZt4= 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=m1laIbeU; arc=none smtp.client-ip=209.127.230.115 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="m1laIbeU" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1774956714; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=zaVLXF5fAu4ZiPLqJExgKtU8coNIuqJ1IUnigMO3d+0=; b=m1laIbeUf6uvJo5UKOu9w1mGGMReQ+4dqteRx5aCtpoZZZcpseigZ/XNLhB83CCIhqBYSQ msxPvj/wAEkKv0Ko80LY55hme4kpYG/1DTB0+aCyE8LqeBNWD8DgXybQfmj6L8lBm4BXrk x/x7kpy+Db0hnLcjbXA+mR7ztlSGRsgy1bS+ppg2LA2x/q721FgCfFUSgNLA0uRyiRFZyj m+YE3hC9NUtNlbvPZtgmwhonttQXXG57n/bGO531cOSpHQuHEoVpJcmSADnz5zrULsuI4k q/3/hMHzmEpc6YSyR+GhM/P6MkyhneuN3OJLSVUrphGlwXukJo0PjecEkhvuGQ== From: "Chuyi Zhou" Message-Id: <20260331113103.2197007-3-zhouchuyi@bytedance.com> To: , , , , , , , , , , , , Cc: , "Chuyi Zhou" 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 In-Reply-To: <20260331113103.2197007-1-zhouchuyi@bytedance.com> Date: Tue, 31 Mar 2026 19:30:53 +0800 X-Lms-Return-Path: X-Mailer: git-send-email 2.20.1 Subject: [PATCH v4 02/12] smp: Enable preemption early in smp_call_function_single X-Original-From: Chuyi Zhou References: <20260331113103.2197007-1-zhouchuyi@bytedance.com> 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