[PATCH 0/2] smp: Fix CSD lock debug regressions

From: Chuyi Zhou

Date: Mon Jun 08 2026 - 07:31:06 EST


This series fixes two regressions introduced by commit b0473dcd4b1d
("smp: Improve smp_call_function_single() CSD-lock diagnostics").

That commit made smp_call_function_single() use the destination CPU's
csd_data while CSD lock debugging is enabled. This improves diagnostics,
but it changes two assumptions that the existing code relied on.

The first patch keeps invalid CPU numbers from being used for the
destination CPU csd_data lookup before generic_exec_single() has a chance
to reject them. This preserves the existing -ENXIO path for callers such
as smp_call_function_any() when no online CPU can be selected.

The second patch makes csd_lock() acquire CSD_FLAG_LOCK atomically in the
debug configuration. With destination CPU csd_data, multiple remote CPUs
can concurrently send async calls to the same target CPU and therefore
contend for the same CSD object. The old non-atomic wait-then-set sequence
can let two senders enqueue the same llist node, corrupting
call_single_queue and leaving later synchronous callbacks stuck behind it.

The non-debug fast path keeps the existing wait-then-set sequence.

Chuyi Zhou (2):
smp: Avoid invalid per-CPU CSD lookup with CSD lock debug
smp: Make CSD lock acquisition atomic for debug mode

kernel/smp.c | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)

--
2.20.1