diff options
| author | Xiaoyao Li <xiaoyao.li@intel.com> | 2024-12-19 06:01:20 -0500 |
|---|---|---|
| committer | Paolo Bonzini <pbonzini@redhat.com> | 2025-01-10 23:34:45 +0100 |
| commit | e60cbeec190d349682bf97cf55446e8ae260b11a (patch) | |
| tree | 48d9af2b3ef0b8984a171dff351950b8668d5f94 /include/hw | |
| parent | 8f78378de70fc79fdc7e1318496bd91ddd22df49 (diff) | |
| download | focaccia-qemu-e60cbeec190d349682bf97cf55446e8ae260b11a.tar.gz focaccia-qemu-e60cbeec190d349682bf97cf55446e8ae260b11a.zip | |
i386/topology: Introduce helpers for various topology info of different level
Introduce various helpers for getting the topology info of different semantics. Using the helper is more self-explanatory. Besides, the semantic of the helper will stay unchanged even when new topology is added in the future. At that time, updating the implementation of the helper without affecting the callers. Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com> Link: https://lore.kernel.org/r/20241219110125.1266461-6-xiaoyao.li@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/hw')
| -rw-r--r-- | include/hw/i386/topology.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index 21b65219a5..f6380f1ed7 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -203,4 +203,29 @@ static inline bool x86_has_extended_topo(unsigned long *topo_bitmap) test_bit(CPU_TOPOLOGY_LEVEL_DIE, topo_bitmap); } +static inline unsigned x86_module_per_pkg(X86CPUTopoInfo *topo_info) +{ + return topo_info->modules_per_die * topo_info->dies_per_pkg; +} + +static inline unsigned x86_cores_per_pkg(X86CPUTopoInfo *topo_info) +{ + return topo_info->cores_per_module * x86_module_per_pkg(topo_info); +} + +static inline unsigned x86_threads_per_pkg(X86CPUTopoInfo *topo_info) +{ + return topo_info->threads_per_core * x86_cores_per_pkg(topo_info); +} + +static inline unsigned x86_threads_per_module(X86CPUTopoInfo *topo_info) +{ + return topo_info->threads_per_core * topo_info->cores_per_module; +} + +static inline unsigned x86_threads_per_die(X86CPUTopoInfo *topo_info) +{ + return x86_threads_per_module(topo_info) * topo_info->modules_per_die; +} + #endif /* HW_I386_TOPOLOGY_H */ |