From nobody Thu Apr 2 20:22:00 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 B6B592417E0; Thu, 26 Mar 2026 12:59:56 +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=1774529999; cv=none; b=qrM+DPcX1kWH2gsN99YBZ0icBReipAeJUOkmdIFYc85BTpxRM+5ie7QQHzXZ4wYeYhAyt8gXuiIvF5oNPoQ/9bHNOh5Ppod5mjHvT7hjUQRzDWOvFrHR0t7UmAgR6LedC/h6oXbzVw3l6NhPs6LdxF7rxDduTN08gTZGrdMvGyI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774529999; c=relaxed/simple; bh=TUqf1Lg6NRKTWxTIQ5K0SirN0gQ/C+nSa4MmzRnYYlQ=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=F64QXk1hwGyFY42/FIr3/u7Nq60NYruHZ0w39vRRmBRlUjfX/201pkXfTwXvnH816lR08zj8w/e+mTFjb86gVfuAfIJ2rCQbBG8XVKQdyGb6Whm2YYxr0unXJtav3+4pw3XQoHBXcfBj8/+cDWHGuYTx7o88q2HJqs03QgJibb8= 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=FrQfTRbD; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=FKpqrNpv; 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="FrQfTRbD"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="FKpqrNpv" Date: Thu, 26 Mar 2026 12:59:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1774529994; 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=i999mv80BDX5x9SBz5gsA5E4NsVXiTSzipRP69pVp7w=; b=FrQfTRbDEm/24eHtpPVb/5qEV22FB3ZwaYfXu3b6C9e/KRE1x72kcjAtR55R0WiJ0bkA8Z ZyqBILm2hmbgL7h5EbaU0vUI3Vc4q1TuiQ2bbc5P4r8AVJpEPAy87d0gaKvXZuRkZzOUux 89TbcjPD75R9YMXKlFVixcbPD/Ew1zLSLkB8rJTFPblzQTJpIOj0TcTehbWd26Ito8BWI9 TMZ6MeVrfec5i7MwCReUNzxurkxZ7Wi6bVHzfiuYI+3puq/VIB0+W2xCeoH2Zxli9/NPGF 9a0e6dk5rNvIj1cWU3rZ3jxYZWH6L0ANHrCFRuDehfPUdNeHYZ/OF8TpixZPaQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1774529994; 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=i999mv80BDX5x9SBz5gsA5E4NsVXiTSzipRP69pVp7w=; b=FKpqrNpvkk+3/942z3GYX4M8QN9EqA0fC7cq+80/YY9LUIhckJH7Cdo7ryi9O8yIqVUPhp XCsqaCreZ80uBWAA== From: "tip-bot2 for Paul E. McKenney" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: smp/core] smp: Improve smp_call_function_single() CSD-lock diagnostics Cc: "Paul E. McKenney" , Thomas Gleixner , Ulf Hansson , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <25c2eb97-77c8-49a5-80ac-efe78dea272c@paulmck-laptop> References: <25c2eb97-77c8-49a5-80ac-efe78dea272c@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177452999316.1647592.118093660207781017.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: b0473dcd4b1d7e2e44947e7ac1820c73a268821a Gitweb: https://git.kernel.org/tip/b0473dcd4b1d7e2e44947e7ac1820c73a= 268821a Author: Paul E. McKenney AuthorDate: Fri, 20 Mar 2026 03:45:36 -07:00 Committer: Thomas Gleixner CommitterDate: Wed, 25 Mar 2026 20:11:30 +01:00 smp: Improve smp_call_function_single() CSD-lock diagnostics Both smp_call_function() and smp_call_function_single() use per-CPU call_single_data_t variable to hold the infamous CSD lock. However, while smp_call_function() acquires the destination CPU's CSD lock, smp_call_function_single() instead uses the source CPU's CSD lock. (These are two separate sets of CSD locks, cfd_data and csd_data, respectively.) This otherwise inexplicable pair of choices is explained by their respective queueing properties. If smp_call_function() where to use the sending CPU's CSD lock, that would serialize the destination CPUs' IPI handlers and result in long smp_call_function() latencies, especially on systems with large numbers of CPUs. For its part, if smp_call_function_single() were to use the (single) destination CPU's CSD lock, this would similarly serialize in the case where many CPUs are sending IPIs to a single "victim" CPU. Plus it would result in higher levels of memory contention. Except that if there is no NMI-based stack tracing on a weakly ordered system where remote unsynchronized stack traces are especially unreliable, the improved debugging beats the improved queueing. This improved queueing only matters if a bunch of CPUs are calling smp_call_function_single() concurrently for a single "victim" CPU, which is not the common case. Therefore, make smp_call_function_single() use the destination CPU's csd_data instance in kernels built with CONFIG_CSD_LOCK_WAIT_DEBUG=3Dy where csdlock_debug_enabled is also set. Otherwise, continue to use the source CPU's csd_data. Signed-off-by: Paul E. McKenney Signed-off-by: Thomas Gleixner Reviewed-by: Ulf Hansson Link: https://patch.msgid.link/25c2eb97-77c8-49a5-80ac-efe78dea272c@paulmck= -laptop --- kernel/smp.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/kernel/smp.c b/kernel/smp.c index bdbf145..0fc4ff2 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -377,6 +377,20 @@ static __always_inline void csd_unlock(call_single_dat= a_t *csd) =20 static DEFINE_PER_CPU_SHARED_ALIGNED(call_single_data_t, csd_data); =20 +#ifdef CONFIG_CSD_LOCK_WAIT_DEBUG +static call_single_data_t *get_single_csd_data(int cpu) +{ + if (static_branch_unlikely(&csdlock_debug_enabled)) + return per_cpu_ptr(&csd_data, cpu); + return this_cpu_ptr(&csd_data); +} +#else +static call_single_data_t *get_single_csd_data(int cpu) +{ + return this_cpu_ptr(&csd_data); +} +#endif + void __smp_call_single_queue(int cpu, struct llist_node *node) { /* @@ -671,7 +685,7 @@ int smp_call_function_single(int cpu, smp_call_func_t f= unc, void *info, =20 csd =3D &csd_stack; if (!wait) { - csd =3D this_cpu_ptr(&csd_data); + csd =3D get_single_csd_data(cpu); csd_lock(csd); } =20