From nobody Mon Feb 9 13:58:44 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