From nobody Fri Jul 24 21:53:25 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 ACDF7439F67; Thu, 23 Jul 2026 10:21:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784802090; cv=none; b=PLL7mjaM4Yk+0YVQ77sWhJ/ch5zYZ1N0MAT/baoxOwLR6w8UpQJDmhVWhsefV8YoWHlG1Es0FT2K6fsiDxp97mEKndkMJqWDxksx9rckcBEQoXGggSGN7+aEx19zaDlqc2ZLARRuYbPr1U18/dkPzillCuWJ8T4gNo3eg16vKys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784802090; c=relaxed/simple; bh=90NpxPsTuxOurLvQTml5ZXxu2TchqWBx6BrFs2z8uAY=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=PxLbQqPTquSbgmueyiJx/3oJotP3p4j4K73gLqFd3kkKmjcxjcKyw84FK+62jWIs0VXn8xkOa5in4YNVqyl3stmXGvbmUUf6cvjT8dfRA3XeDSQi47OQ0OprA0XrjynJKV4QFHC73q+VvFmbJCjAceWPDuRI+HWindbASCejygQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=tx1JsPTO; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=/fMsA4GD; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="tx1JsPTO"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="/fMsA4GD" Date: Thu, 23 Jul 2026 10:21:25 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1784802087; h=from:from:sender:sender:reply-to: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=2B1zKBR3YsGeYW2vs4IEdIsdstO55Zxsr1/NX+m3qGQ=; b=tx1JsPTOEmSJH9xATQXpYrxUYC2/st2ojsM0WHMvndO6BizY0P6SK6vLnv64twr0j9+EpU Uz3aFgiIdiebn0qThxwMmBpcA8KhC7qntLHuJ0b6dVq0ONWzP5KGPYXUllEfox0F1A0qRR tqpXxALnn9FwAVRsXyGQnBpRsrCHwskVzBGcJhaI74TwulbdNzt2Dqp9iZ4pauaswXudqh 3f9KoaY4B0xSmoXdzCqtHZHGFhiil7KBLh9BTcojHayvjC/5Dwp8LPznYYL5fgFxvO5zDg F7o4xF92MGYAsYTe9BR+SgdNO9i4/wEDlISPMWta3f51CBXuxwij+hukInYMRg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1784802087; h=from:from:sender:sender:reply-to: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=2B1zKBR3YsGeYW2vs4IEdIsdstO55Zxsr1/NX+m3qGQ=; b=/fMsA4GDhxIbbkAM9YTCo7KdETEmaYpTp4N3scYHk8Xkt/3agHqUNTR24cyTPi/4Uvn4pG ksGUOd1gXjJK+mBg== From: "tip-bot2 for Chuyi Zhou" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: smp/core] smp: Enable preemption early in smp_call_function_single() Cc: Chuyi Zhou , Thomas Gleixner , "Paul E. McKenney" , Muchun Song , "Steven Rostedt (Google)" , Sebastian Andrzej Siewior , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260709122933.4021501-3-zhouchuyi@bytedance.com> References: <20260709122933.4021501-3-zhouchuyi@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178480208549.2943223.18097708924872470732.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the smp/core branch of tip: Commit-ID: cdf0ba15c0898a04f55ca396d119b97bbcd801bc Gitweb: https://git.kernel.org/tip/cdf0ba15c0898a04f55ca396d119b97bb= cd801bc Author: Chuyi Zhou AuthorDate: Thu, 09 Jul 2026 20:29:21 +08:00 Committer: Thomas Gleixner CommitterDate: Thu, 16 Jul 2026 09:24:55 +02:00 smp: Enable preemption early in smp_call_function_single() smp_call_function_single() disables preemption while it validates the target CPU, prepares the call single data, queues the callback and sends the IPI. For the !wait case, preemption protects the per-CPU csd_data from concurrent modification by another task on the same CPU. For the wait case, the CSD is stack allocated and no other task can reuse it. CPU pinning is still required until the callback has been queued and the IPI has been sent, to ensure that the target CPU cannot be offlined after the online check but before dispatch. After generic_exec_single() has queued the callback, the synchronous csd_lock_wait() invocation at the end of the execution does not require the caller to remain pinned to the current CPU. Enable preemption before csd_lock_wait() to shorten the preemption-disabled section. Signed-off-by: Chuyi Zhou Signed-off-by: Thomas Gleixner Tested-by: Paul E. McKenney Reviewed-by: Muchun Song Reviewed-by: Steven Rostedt (Google) Reviewed-by: Sebastian Andrzej Siewior Link: https://patch.msgid.link/20260709122933.4021501-3-zhouchuyi@bytedance= .com --- kernel/smp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kernel/smp.c b/kernel/smp.c index f5a4d63..31cdb06 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -712,11 +712,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);