mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
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>
This commit is contained in:
parent
8f78378de7
commit
e60cbeec19
2 changed files with 29 additions and 7 deletions
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue