[PATCH v3 2/2] genirq/matrix: Avoid implicit tie-breaking by CPU iteration order

Zhan Xusheng posted 2 patches 1 week, 5 days ago
[PATCH v3 2/2] genirq/matrix: Avoid implicit tie-breaking by CPU iteration order
Posted by Zhan Xusheng 1 week, 5 days ago
matrix_find_best_cpu_managed() updates best_cpu even when two CPUs
have the same managed_allocated count. As a result, the final
selection implicitly depends on CPU iteration order.

Update the comparison to replace the current best CPU only when a
CPU has a strictly smaller managed_allocated value. This removes
the iteration-order-based tie-breaking for equal cases.

This patch intentionally changes the selection behavior.

Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
---
 kernel/irq/matrix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/irq/matrix.c b/kernel/irq/matrix.c
index c363e918087c..ed4b1e44dc1e 100644
--- a/kernel/irq/matrix.c
+++ b/kernel/irq/matrix.c
@@ -171,7 +171,7 @@ static unsigned int matrix_find_best_cpu_managed(struct irq_matrix *m,
 		if (!cm->online)
 			continue;
 
-		if (cm->managed_allocated <= allocated) {
+		if (cm->managed_allocated < allocated) {
 			best_cpu = cpu;
 			allocated = cm->managed_allocated;
 		}
-- 
2.43.0
Re: [PATCH v3 2/2] genirq/matrix: Avoid implicit tie-breaking by CPU iteration order
Posted by Thomas Gleixner 1 week, 4 days ago
On Wed, Jan 28 2026 at 11:14, Zhan Xusheng wrote:
> matrix_find_best_cpu_managed() updates best_cpu even when two CPUs
> have the same managed_allocated count. As a result, the final
> selection implicitly depends on CPU iteration order.

And?

> Update the comparison to replace the current best CPU only when a
> CPU has a strictly smaller managed_allocated value. This removes
> the iteration-order-based tie-breaking for equal cases.

And replaces it by a different iteration order based decision, no?

What are you actually trying to solve here and why does it matter at
all? If it solves nothing then what's the point?

> This patch intentionally changes the selection behavior.

1) # git grep 'This patch' Documentation/process/

2) It's already clear from the above that this changes the behaviour, so
   no point in repeating the obvious.

   The phrase "No functional change intended" is very different because
   it tells the reviewer that this is a pure code refactoring.

Thanks,

        tglx