[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250720014146.432316-3-yury.norov@gmail.com>
Date: Sat, 19 Jul 2025 21:41:45 -0400
From: Yury Norov <yury.norov@...il.com>
To: Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"H. Peter Anvin" <hpa@...or.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Andrew Morton <akpm@...ux-foundation.org>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>,
Fernando Fernandez Mancera <ffmancera@...eup.net>,
"Xin Li (Intel)" <xin@...or.com>,
x86@...nel.org,
linux-kernel@...r.kernel.org
Cc: Yury Norov <yury.norov@...il.com>
Subject: [PATCH 2/2] x86: topology: simplify topo_unit_count()
From: Yury Norov (NVIDIA) <yury.norov@...il.com>
Switch the function to using bitmap_weight_from(), and make it (almost)
a one-liner.
Signed-off-by: Yury Norov (NVIDIA) <yury.norov@...il.com>
---
arch/x86/kernel/cpu/topology.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kernel/cpu/topology.c b/arch/x86/kernel/cpu/topology.c
index e35ccdc84910..db19c5384f92 100644
--- a/arch/x86/kernel/cpu/topology.c
+++ b/arch/x86/kernel/cpu/topology.c
@@ -208,15 +208,10 @@ static __init bool check_for_real_bsp(u32 apic_id)
static unsigned int topo_unit_count(u32 lvlid, enum x86_topology_domains at_level,
unsigned long *map)
{
- unsigned int id, end, cnt = 0;
-
/* Calculate the exclusive end */
- end = lvlid + (1U << x86_topo_system.dom_shifts[at_level]);
+ unsigned int end = lvlid + (1U << x86_topo_system.dom_shifts[at_level]);
- /* Unfortunately there is no bitmap_weight_range() */
- for (id = find_next_bit(map, end, lvlid); id < end; id = find_next_bit(map, end, ++id))
- cnt++;
- return cnt;
+ return bitmap_weight_from(map, lvlid, end);
}
static __init void topo_register_apic(u32 apic_id, u32 acpi_id, bool present)
--
2.43.0
Powered by blists - more mailing lists