topology_unit_count(9)
๐ topology_unit_count(9) โ like, the whole Kernel API Manual vibe โจ
okay bestie, so this one lives in section 9 of the kernel API manual and it's called topology_unit_count โ say that three times fast, i dare you ๐ซถ
๐ธ NAME ๐ธ
topology_unit_count โ retrieves the count of specified units at a given topology domain level. that's it, that's the whole job, and she does it slayfully ๐
โจ SYNOPSIS โจ
unsigned int topology_unit_count (u32 apicid , enum x86_topology_domains which_units , enum x86_topology_domains at_level );
look at that signature. three args, one unsigned int coming back at ya. iconic behavior honestly ๐
๐ ARGUMENTS ๐
apicidโ the APIC ID, aka the little guy that specifies the search range ๐which_unitsโ the domain level that specifies which units we're counting, like, what are we even tallying hereat_levelโ the domain level at whichwhich_unitshave to be counted. soโฆ where the counting happens ๐งฎ
๐ฆ DESCRIPTION ๐ฆ
so what does she actually do? she returns the number of possible units according to the enumerated information. no cap, that's the whole thing ๐
like, for example โ and this is the moment, bestie โ topology_count_units(apicid, TOPO_CORE_DOMAIN, TOPO_PKG_DOMAIN) counts the number of possible cores in the package that apicid belongs to. cute right? cores in a package, counted, done ๐ธ
now the important part, pay attention:
at_levelmust obviously be greater thanwhich_levelto produce useful results. like, obviously. this is not a drill, this is the useful-results prerequisite ๐ฅ
- if
at_levelis equal towhich_units, the result is โ unsurprisingly โ1. yeah. one. that's it. one unit. don't act shocked ๐ - if
at_levelis less thanwhich_units, the result is, by definition, undefined, and the function returns0. undefined behavior bestie, we do NOT stan, be careful out there ๐
๐ SEE ALSO ๐
the kernel file ./arch/x86/kernel/cpu/topology.c and its whole friend group:
topology_register_apic(9)topology_register_boot_apic(9)topology_get_logical_id(9)topology_hotplug_apic(9)topology_hotunplug_apic(9)topology_apply_cmdline_limits_early(9)
go read them, they're all main character energy in their own way, iykyk โญ
okay that's the whole page, mwah ๐ this gem is brought to you straight from ./arch/x86/kernel/cpu, dated October 2026, and yes she's still serving topology_unit_count(9) realness. periodt. ๐๐ฆโจ
๐ฆ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms