From nobody Sun Feb 8 05:23:28 2026 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 4D9FA2D3EC7 for ; Wed, 28 Jan 2026 03:14:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769570059; cv=none; b=lbbVD85OGNkSyAUfeojU7ai41uE58lAEI3agiEW81Cr+dh/Wp+CVHRhjABeFJml+AMS1FcP79xPxo/MT4DSs3qjmRTkWGW8i47sREZQkbXZjCCyPFOYxkUR8asHDFo13Qo7hRVI9Vh4lfIIv5mj40VUGrc7B+BPHb4fB/KGTVTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769570059; c=relaxed/simple; bh=AupPtMQvFiMG7VACHHBXMqpdMmngm394at2PWRRmXAE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LOMx1pmlX8TnGiWMTOmidHXbWyq82320u0PhYOb1MOi6bjq3cz4hkJfUXUvhfi0fRjShHQN9ezYqxUq70C0/ORTmoulBqyr1z9mTuuFu7IttYG3uCw/skaVT+yorSHto1IkoxCPqfN+9Qm65TArYgyp1D1e7GFgqeyiOPPi3Ivc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XNVrS3h0; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XNVrS3h0" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-81f4e136481so3203716b3a.3 for ; Tue, 27 Jan 2026 19:14:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769570058; x=1770174858; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2dsQvA1IE42mWpawG51mEwsz8H+DMIh2Xdt8UMyE8mY=; b=XNVrS3h04VzKDKFJ69oHtZZ1MRV911qrqx9gQNK4lTJfnoKMUZ36oHrKBeE+bFbAt5 m2rlHDsyrRkiWMl/v3+P9xJPD/9SbfOoT12bwyKSKif6DoGSdgUn/3QJqbyc1xo66hJC hGraX2ig/reFHyZiwgUNcx8+Ah5kxkPEdhYHDaa+ZmrQlUkUN/b/yVhyoS4RH/8ksFaM B+lpVOw+3uwQJW0sQqf2r9BsZA+iauEHiK4g0T12BZdA+7sinAGTwsD7hsObY2SKjgiL HrXSOpbmQQOVTINRPbYq3mN2M59XjMyqtaDTAfCavOkCvpjnHji9eFGmjhU47JFpOn5h 6l7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769570058; x=1770174858; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=2dsQvA1IE42mWpawG51mEwsz8H+DMIh2Xdt8UMyE8mY=; b=iR3Oh+Oh0F3m7FRugqGWGEtpoNcz8dilby8+7SCqq5TF8npB0cW9opRAjoaMYOlszo Ey/+52s+TV7XmARX0JVY24YVyTPeIDteOCdAful7QhNcwwrQvThCNi9i3YBJ7dy8yoqd vDVUGRAW+Eiy8Iwg5iAy5+DbOIj9HjHuAA+c6PPJrvh/vRZGB18bkGw6k9CNAsC+Lrzq qhQgiFk5S6u1BFeu2UHZrFSEKkqo5q3Cep5+mpjV9o/VOBMv5DPWjBLjLfDQk3iFq1Vf M1NUa4Cxwl4dTWfZIfyzqHeSB0HhQnwday7ipHHJDkQMFrPW7joTUNsL2TG3wk4p3fPk lXDQ== X-Gm-Message-State: AOJu0YzHNqdPD5lvacevuCImocwB5Z4wk8O+sq0XhSbUfYO/lLGzG1NL /RZ/Lo7C+X/qpZm6pmMUDWoQdLfdsHKy3fbG0hGMuKQP4s80Og7ehp/N X-Gm-Gg: AZuq6aKTUIytQkBTabpfhE6miqzqhwRuvSnrDycQxrmsu7NGsDVFzbPdlDlMAtTdej8 mQYhDnYmF8uktNIvTaNWOY7tUvkUPrzavzLcX3ziguwmlJcD+ov24SfjaSG1XJvg88NNVImNrYl 8uuVCSGE70hjXSaRNSfnynNbNRGQiusjGN2E7OpQOyhrvkP6lOFzDIcJPocFNMKCfi+WWdz8WgU +jTm0ZUHL4kBH9a9iklz/dP5a2EudaLW/EOsb8f5wN/j6pAKSajuBOcYvvpPq53mM6AcEkcLG98 UFw/ZvSZoeHpMofNUDjTza4VZkZ7/IyTQL75DODMHRHdUBzgzMffK0gwZTgsHM5Sxqrt5jKjeix bfsLlMTv036WLKuHJs8egrQ+BYYiLka68bVjUzQHMtsCgpO0F0F2g8/VDLY0lI9EFqO4VrmeuKa 8U+r39dN7Py6XaEFUn5pUmLT2zX5uNFVZ/mTo= X-Received: by 2002:a05:6a00:1495:b0:822:abcd:db0f with SMTP id d2e1a72fcca58-823692c3b99mr3891485b3a.52.1769570057631; Tue, 27 Jan 2026 19:14:17 -0800 (PST) Received: from DESKTOP-MOQC9AF.mioffice.cn ([43.224.245.239]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82379c56e20sm915471b3a.65.2026.01.27.19.14.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jan 2026 19:14:17 -0800 (PST) From: Zhan Xusheng X-Google-Original-From: Zhan Xusheng To: Thomas Gleixner Cc: linux-kernel@vger.kernel.org, linux-irq@vger.kernel.org, Zhan Xusheng Subject: [PATCH v3 1/2] genirq/matrix: Clarify CPU selection logic Date: Wed, 28 Jan 2026 11:14:05 +0800 Message-ID: <20260128031406.9473-2-zhanxusheng@xiaomi.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260128031406.9473-1-zhanxusheng@xiaomi.com> References: <87wm13bgd8.ffs@tglx> <20260128031406.9473-1-zhanxusheng@xiaomi.com> 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 Content-Type: text/plain; charset="utf-8" The CPU selection loops in matrix_find_best_cpu() and matrix_find_best_cpu_managed() mix the online check with the comparison that determines whether a CPU becomes the current best candidate. Restructure the loops to filter out offline CPUs first and then perform the comparison separately. This makes the selection criteria easier to read and reason about. No functional change intended. Signed-off-by: Zhan Xusheng --- kernel/irq/matrix.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/kernel/irq/matrix.c b/kernel/irq/matrix.c index a50f2305a8dc..c363e918087c 100644 --- a/kernel/irq/matrix.c +++ b/kernel/irq/matrix.c @@ -140,14 +140,17 @@ static unsigned int matrix_find_best_cpu(struct irq_m= atrix *m, =20 best_cpu =3D UINT_MAX; =20 + /* Select the online CPU with the most available vectors */ for_each_cpu(cpu, msk) { cm =3D per_cpu_ptr(m->maps, cpu); =20 - if (!cm->online || cm->available <=3D maxavl) + if (!cm->online) continue; =20 - best_cpu =3D cpu; - maxavl =3D cm->available; + if (cm->available > maxavl) { + best_cpu =3D cpu; + maxavl =3D cm->available; + } } return best_cpu; } @@ -161,14 +164,17 @@ static unsigned int matrix_find_best_cpu_managed(stru= ct irq_matrix *m, =20 best_cpu =3D UINT_MAX; =20 + /* Select the online CPU with the fewest managed allocated vectors */ for_each_cpu(cpu, msk) { cm =3D per_cpu_ptr(m->maps, cpu); =20 - if (!cm->online || cm->managed_allocated > allocated) + if (!cm->online) continue; =20 - best_cpu =3D cpu; - allocated =3D cm->managed_allocated; + if (cm->managed_allocated <=3D allocated) { + best_cpu =3D cpu; + allocated =3D cm->managed_allocated; + } } return best_cpu; } --=20 2.43.0 From nobody Sun Feb 8 05:23:28 2026 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 5D396309DA5 for ; Wed, 28 Jan 2026 03:14:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769570063; cv=none; b=P+x5ZO9T4fc2xw8VxmqFRJ9HBLo/GE3O15OMb34IKTEyhFN2uK4vBWrsyyyhjE8DXKdADfvpEVJ9+hBA0On8vOj2rUZ+b3yWdchj71m7GQQsj7PS5jU1kmoyR/l5mdStU/Mb0nCxvTl0LAilz8RSOnmxGMoi8C0rGC6ENPOUEFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769570063; c=relaxed/simple; bh=IXECO4Ssecg/eOYVe5CLGtYpcL5+Z6vLzQbFvrohjas=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SrUkZ6MKIBHHbRm1c+Ju/ll1S87S0vumMQJEVdhEPK6vFSgVsriF15IbhnIHBIbpqlnEguYpDSf+Zr59hB3K/kMSVU4ISaBsVwMaiVGOzac32tiB0Likyx9upkj1Ac0mxcBl3ZLo4Eilfg9Nv5mPwZDZwUXyLUMz2rbpH8JcSzQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=azL0mg2e; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="azL0mg2e" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-81ecbdfdcebso3402134b3a.1 for ; Tue, 27 Jan 2026 19:14:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769570062; x=1770174862; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YvfYAjJ7LCMBmJJ7teY9fkvlFc/wyxP4XAZ5xmQ7orU=; b=azL0mg2eHZvZc7yDaczeo+E/Mhb+ljmTzlnUmXypl8o22VidwrcCm7p0RyO0/AVU4n 3XEHLsl9YeT7gLk1S1okKtIdSzDWxCb5qyZyLyEtDoO/Khp8kYmnrZyYO9ULF23KRGrZ XrkaRl2nVcuJUaiaQ1mafzLslG7eAaNGMaB5HUIM9eX09RWCb7OIh2IIhHUJfuwUSCsx oYKrsBtajGP2yCuLOi/CotEXT9BIa6IrquDuoRLILbCevmpVwMT46iXJ3gPG4VfHUzVB ab6Fo9tcUnQpz9dKPVynjNHYEFlLysuxwonkgt7q6RtTUeGeF2dz7voAdtKNkmYeZgmA TxGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769570062; x=1770174862; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=YvfYAjJ7LCMBmJJ7teY9fkvlFc/wyxP4XAZ5xmQ7orU=; b=APJKpLkT0PK0VPwqrZHFHURH20tPkPlXcQz6xFmdM9P6qIZyofBYzx4dw85a8GAT1k K7Rx+TaD80ySyuCawAGeUD2mQmpGrZD3x9qlROyI73nctmPnjdoASMue+Xni4j9FvDhu wAwrEBXGchpHpdE/jXHp8LYGr2tOKoQXbqrI70JxuSV5CJheKy3G5JIn2PryZgx0sPB7 7tluvQABvZMVHlmgGvUzggKRPW/OrPdQSibPrnZqhkHvShmnBUlE9CYY4miAHYz3Wk1A +7mZYsQr1qLbylkVufGPM7ldij+mwrqO0NNU86IDlENDoqTa1Jc47TfIZguPFjZRO0WG jvFw== X-Gm-Message-State: AOJu0YyxCuqUnSsSUzl7VgDFgtdO3RkrQGBMpOwaIlFaYEVru3aA7TKa YduID5lXH7OOUclGYv9HvzJv7rKJGh4gMKKx0BAaT8w/+QkSqCM42cKP X-Gm-Gg: AZuq6aLpx8XsA5REXj6H4eAnGAnMBN7+8PJQx/4Ej+UUOt58/CDKt5aUCcs76TC6UdV dQGevWUg0zyhzckg0MbHvcERB3BmhKleSP8N5PtyUsht2sGbPxvKZCLhutUZMQDNvrpBISaprdI eq7ke8dhr5fyG3vCOtoAESuOGR3F6TG+6GYUst4GeQgVkllH0gdi5F51Asc/pYYsDPZ6LvFxCQQ 2CMTYjHRwvJhEeUxm5HN1yDBya/5/4Uui71LFO9PtfG98GdrTJvKqVlGJTYxp+uvoK6tJzPO0Qr 9v/vSaN4QkpzhrRW6HQe2dcYVdGl92j0pJmrPpVBHQA0pgSGCDQL8tEzXoR0+Pc+OogzauWt+zA y0SHQJYme8K+GGNmpvgNKL/ThO/VZzVLQ6VUYDVL566XZ71Ua90OAdIUaP7T8cN2ialMDX0Flp8 HJC9UPdT/UTFkH/xXOCYet9xT59ov2ip3grT8= X-Received: by 2002:a05:6a00:1883:b0:81f:4529:83a7 with SMTP id d2e1a72fcca58-8236917be27mr3617617b3a.15.1769570061719; Tue, 27 Jan 2026 19:14:21 -0800 (PST) Received: from DESKTOP-MOQC9AF.mioffice.cn ([43.224.245.239]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82379c56e20sm915471b3a.65.2026.01.27.19.14.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jan 2026 19:14:21 -0800 (PST) From: Zhan Xusheng X-Google-Original-From: Zhan Xusheng To: Thomas Gleixner Cc: linux-kernel@vger.kernel.org, linux-irq@vger.kernel.org, Zhan Xusheng Subject: [PATCH v3 2/2] genirq/matrix: Avoid implicit tie-breaking by CPU iteration order Date: Wed, 28 Jan 2026 11:14:06 +0800 Message-ID: <20260128031406.9473-3-zhanxusheng@xiaomi.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260128031406.9473-1-zhanxusheng@xiaomi.com> References: <87wm13bgd8.ffs@tglx> <20260128031406.9473-1-zhanxusheng@xiaomi.com> 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 Content-Type: text/plain; charset="utf-8" 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 --- 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; =20 - if (cm->managed_allocated <=3D allocated) { + if (cm->managed_allocated < allocated) { best_cpu =3D cpu; allocated =3D cm->managed_allocated; } --=20 2.43.0