mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 01:33:56 -06:00
i386: Support modules_per_die in X86CPUTopoInfo
Support module level in i386 cpu topology structure "X86CPUTopoInfo". Since x86 does not yet support the "modules" parameter in "-smp", X86CPUTopoInfo.modules_per_die is currently always 1. Therefore, the module level width in APIC ID, which can be calculated by "apicid_bitwidth_for_count(topo_info->modules_per_die)", is always 0 for now, so we can directly add APIC ID related helpers to support module level parsing. In addition, update topology structure in test-x86-topo.c. Tested-by: Yongwei Ma <yongwei.ma@intel.com> Co-developed-by: Zhuocheng Ding <zhuocheng.ding@intel.com> Signed-off-by: Zhuocheng Ding <zhuocheng.ding@intel.com> Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Tested-by: Babu Moger <babu.moger@amd.com> Message-ID: <20240424154929.1487382-14-zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
81c392ab5c
commit
3568adc995
4 changed files with 58 additions and 31 deletions
|
@ -30,13 +30,16 @@ static void test_topo_bits(void)
|
|||
{
|
||||
X86CPUTopoInfo topo_info = {0};
|
||||
|
||||
/* simple tests for 1 thread per core, 1 core per die, 1 die per package */
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 1};
|
||||
/*
|
||||
* simple tests for 1 thread per core, 1 core per module,
|
||||
* 1 module per die, 1 die per package
|
||||
*/
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 1, 1};
|
||||
g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 0);
|
||||
g_assert_cmpuint(apicid_core_width(&topo_info), ==, 0);
|
||||
g_assert_cmpuint(apicid_die_width(&topo_info), ==, 0);
|
||||
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 1};
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 1, 1};
|
||||
g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 0), ==, 0);
|
||||
g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1), ==, 1);
|
||||
g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 2), ==, 2);
|
||||
|
@ -45,39 +48,39 @@ static void test_topo_bits(void)
|
|||
|
||||
/* Test field width calculation for multiple values
|
||||
*/
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 2};
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 1, 2};
|
||||
g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 1);
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 3};
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 1, 3};
|
||||
g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 2);
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 4};
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 1, 4};
|
||||
g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 2);
|
||||
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 14};
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 1, 14};
|
||||
g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 4);
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 15};
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 1, 15};
|
||||
g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 4);
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 16};
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 1, 16};
|
||||
g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 4);
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 17};
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 1, 17};
|
||||
g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 5);
|
||||
|
||||
|
||||
topo_info = (X86CPUTopoInfo) {1, 30, 2};
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 30, 2};
|
||||
g_assert_cmpuint(apicid_core_width(&topo_info), ==, 5);
|
||||
topo_info = (X86CPUTopoInfo) {1, 31, 2};
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 31, 2};
|
||||
g_assert_cmpuint(apicid_core_width(&topo_info), ==, 5);
|
||||
topo_info = (X86CPUTopoInfo) {1, 32, 2};
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 32, 2};
|
||||
g_assert_cmpuint(apicid_core_width(&topo_info), ==, 5);
|
||||
topo_info = (X86CPUTopoInfo) {1, 33, 2};
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 33, 2};
|
||||
g_assert_cmpuint(apicid_core_width(&topo_info), ==, 6);
|
||||
|
||||
topo_info = (X86CPUTopoInfo) {1, 30, 2};
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 30, 2};
|
||||
g_assert_cmpuint(apicid_die_width(&topo_info), ==, 0);
|
||||
topo_info = (X86CPUTopoInfo) {2, 30, 2};
|
||||
topo_info = (X86CPUTopoInfo) {2, 1, 30, 2};
|
||||
g_assert_cmpuint(apicid_die_width(&topo_info), ==, 1);
|
||||
topo_info = (X86CPUTopoInfo) {3, 30, 2};
|
||||
topo_info = (X86CPUTopoInfo) {3, 1, 30, 2};
|
||||
g_assert_cmpuint(apicid_die_width(&topo_info), ==, 2);
|
||||
topo_info = (X86CPUTopoInfo) {4, 30, 2};
|
||||
topo_info = (X86CPUTopoInfo) {4, 1, 30, 2};
|
||||
g_assert_cmpuint(apicid_die_width(&topo_info), ==, 2);
|
||||
|
||||
/* build a weird topology and see if IDs are calculated correctly
|
||||
|
@ -85,18 +88,18 @@ static void test_topo_bits(void)
|
|||
|
||||
/* This will use 2 bits for thread ID and 3 bits for core ID
|
||||
*/
|
||||
topo_info = (X86CPUTopoInfo) {1, 6, 3};
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 6, 3};
|
||||
g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 2);
|
||||
g_assert_cmpuint(apicid_core_offset(&topo_info), ==, 2);
|
||||
g_assert_cmpuint(apicid_die_offset(&topo_info), ==, 5);
|
||||
g_assert_cmpuint(apicid_pkg_offset(&topo_info), ==, 5);
|
||||
|
||||
topo_info = (X86CPUTopoInfo) {1, 6, 3};
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 6, 3};
|
||||
g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 0), ==, 0);
|
||||
g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1), ==, 1);
|
||||
g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 2), ==, 2);
|
||||
|
||||
topo_info = (X86CPUTopoInfo) {1, 6, 3};
|
||||
topo_info = (X86CPUTopoInfo) {1, 1, 6, 3};
|
||||
g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1 * 3 + 0), ==,
|
||||
(1 << 2) | 0);
|
||||
g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1 * 3 + 1), ==,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue