Only generate cluster node in PPTT when specified
v2 cover Only generate cluster node in PPTT when specified
From: Yicong Yang <[email protected]>
This series mainly change the policy for building a cluster topology node in PPTT. Previously we'll always build a cluster node in PPTT without asking the user, after this set the cluster node will be built only the the user specify through "-smp clusters=X".
One problem is related to this but not fully caused by this, see the discussion in [*]. When booting the VM with -smp 8 and 4 numa nodes, the linux scheduling domains in the VM misses the NUMA domains. It's because the MC level span extends to Cluster level (which is generated by the Qemu by default) that spans all the cpus in the system, then the scheduling domain building stops at MC level since it already includes all the cpus.
Considering cluster is an optional level and most platforms don't have it, they may even don't realize this is built and a always build policy cannot emulate the topology on these platforms. So in this series improve the policy to only generate cluster when the user explicitly want.
Update the tests and test tables accordingly.
[*] https://lore.kernel.org/lkml/[email protected]/
Change since v1:
- Only includes the test tables which is really needed
- Enrich the commit
Yicong Yang (4):
hw/acpi/aml-build: Only generate cluster node in PPTT when specified
tests: virt: update expected ACPI tables for virt test
tests: acpi: aarch64: add topology test for aarch64
tests: acpi: aarch64: add *.topology tables
hw/acpi/aml-build.c | 2 +- hw/core/machine-smp.c | 3 +++ include/hw/boards.h | 2 ++ qemu-options.hx | 2 ++ tests/data/acpi/virt/APIC.topology | Bin 0 -> 700 bytes tests/data/acpi/virt/DSDT.topology | Bin 0 -> 5398 bytes tests/data/acpi/virt/PPTT | Bin 96 -> 76 bytes tests/data/acpi/virt/PPTT.topology | Bin 0 -> 336 bytes tests/qtest/bios-tables-test.c | 22 ++++++++++++++++++++++ 9 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/data/acpi/virt/APIC.topology create mode 100644 tests/data/acpi/virt/DSDT.topology create mode 100644 tests/data/acpi/virt/PPTT.topology
Signature · 1 line
2.24.0
PATCH v2 1/4 hw/acpi/aml-build: Only generate cluster node in PPTT when specified
From: Yicong Yang <[email protected]>
Currently we'll always generate a cluster node no matter user has specified '-smp clusters=X' or not. Cluster is an optional level and will participant the building of Linux scheduling domains and only appears on a few platforms. It's unncessary to always build it which cannot reflect the real topology on platforms have no cluster and to avoid affecting the linux scheduling domains in the VM. So only generate it when user specified explicitly.
Tested qemu-system-aarch64 with -smp 8 and linux 6.1-rc1, without this patch:
estuary:/sys/devices/system/cpu/cpu0/topology$ cat cluster_* ff # cluster_cpus 0-7 # cluster_cpus_list 56 # cluster_id
with this patch:
estuary:/sys/devices/system/cpu/cpu0/topology$ cat cluster_* ff # cluster_cpus 0-7 # cluster_cpus_list 36 # cluster_id, with no cluster node kernel will make it to physical package id
--- hw/acpi/aml-build.c | 2 +- hw/core/machine-smp.c | 3 +++ include/hw/boards.h | 2 ++ qemu-options.hx | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-)
hw/acpi/aml-build.c +1 -1
@@ -2030,7 +2030,7 @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms, 0, socket_id, NULL, 0); } -if (mc->smp_props.clusters_supported) { +if (mc->smp_props.clusters_supported && ms->smp.build_cluster) {if (cpus->cpus[n].props.cluster_id != cluster_id) {assert (cpus->cpus[n].props.cluster_id > cluster_id); cluster_id = cpus->cpus[n].props.cluster_id;
hw/core/machine-smp.c +3 -0
@@ -158,6 +158,9 @@ void machine_parse_smp_config(MachineState *ms, ms->smp.threads = threads; ms->smp.max_cpus = maxcpus; +if (config->has_clusters) + ms->smp.build_cluster = true; +/* sanity-check of the computed topology */ if (sockets * dies * clusters * cores * threads != maxcpus) { g_autofree char *topo_msg = cpu_hierarchy_to_string(ms);
include/hw/boards.h +2 -0
@@ -305,6 +305,7 @@ typedef struct DeviceMemoryState {* @cores: the number of cores in one cluster * @threads: the number of threads in one core * @max_cpus: the maximum number of logical processors on the machine +* @build_cluster: build cluster topology or not */ typedef struct CpuTopology { unsigned int cpus;
@@ -314,6 +315,7 @@ typedef struct CpuTopology {unsigned int cores;unsigned int threads;unsigned int max_cpus; +bool build_cluster; } CpuTopology;/**
qemu-options.hx +2 -0
@@ -342,6 +342,8 @@ SRST were preferred over threads), however, this behaviour is considered liable to change. Prior to 6.2 the preference was sockets over cores over threads. Since 6.2 the preference is cores over sockets over threads. + The cluster topology will only be generated if explicitly specified + by the "-cluster" option. For example, the following option defines a machine board with 2 sockets of 1 core before 6.2 and 1 socket of 2 cores after 6.2:
Signature · 1 line
2.24.0
Re: [PATCH v2 1/4] hw/acpi/aml-build: Only generate cluster node in PPTT when specified
Hi Yicong,
Quoted 72 lines · Yicong Yang
From: Yicong Yang <[email protected]>
Currently we'll always generate a cluster node no matter user has specified '-smp clusters=X' or not. Cluster is an optional level and will participant the building of Linux scheduling domains and only appears on a few platforms. It's unncessary to always build it which cannot reflect the real topology on platforms have no cluster and to avoid affecting the linux scheduling domains in the VM. So only generate it when user specified explicitly.
Tested qemu-system-aarch64 with
-smp 8and linux 6.1-rc1, without this patch:estuary:/sys/devices/system/cpu/cpu0/topology$ cat cluster_* ff # cluster_cpus 0-7 # cluster_cpus_list 56 # cluster_idwith this patch:
estuary:/sys/devices/system/cpu/cpu0/topology$ cat cluster_* ff # cluster_cpus 0-7 # cluster_cpus_list 36 # cluster_id, with no cluster node kernel will make it to physical package idSigned-off-by Yicong Yang <[email protected]>--- hw/acpi/aml-build.c | 2 +- hw/core/machine-smp.c | 3 +++ include/hw/boards.h | 2 ++ qemu-options.hx | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-)hw/acpi/aml-build.c +1
-1@@ -2030,7 +2030,7 @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms, 0, socket_id, NULL, 0); } -if (mc->smp_props.clusters_supported) { +if (mc->smp_props.clusters_supported && ms->smp.build_cluster) {if (cpus->cpus[n].props.cluster_id != cluster_id) {assert (cpus->cpus[n].props.cluster_id > cluster_id); cluster_id = cpus->cpus[n].props.cluster_id;hw/core/machine-smp.c +3
-0@@ -158,6 +158,9 @@ void machine_parse_smp_config(MachineState *ms, ms->smp.threads = threads; ms->smp.max_cpus = maxcpus; +if (config->has_clusters) + ms->smp.build_cluster = true; +/* sanity-check of the computed topology */ if (sockets * dies * clusters * cores * threads != maxcpus) { g_autofree char *topo_msg = cpu_hierarchy_to_string(ms);include/hw/boards.h +1
-0@@ -305,6 +305,7 @@ typedef struct DeviceMemoryState {* @cores: the number of cores in one cluster * @threads: the number of threads in one core * @max_cpus: the maximum number of logical processors on the machine +* @build_cluster: build cluster topology or not */ typedef struct CpuTopology { unsigned int cpus;
include/hw/boards.h typedef struct CpuTopology { · line 318
Quoted 4 lines
include/hw/boards.h +1
-0@@ -314,6 +315,7 @@ typedef struct CpuTopology {unsigned int cores;unsigned int threads;unsigned int max_cpus; +bool build_cluster;
build_cluster seems a variable defined specifically for ACPI PPTT generation. It may not be proper to place it in the generic struct CpuTopology which only holds topo members.
What about a more generic variable in struct SMPCompatProps together with @clusters_supported. Something like below:
include/hw/boards.h +0 -0
@@ -130,11 +130,14 @@ typedef struct {
* @prefer_sockets - whether sockets are preferred over cores in smp parsing
* @dies_supported - whether dies are supported by the machine
* @clusters_supported - whether clusters are supported by the machine
+ * @has_clusters - whether clusters is explicitly specified in the user
+ * provided SMP configuration.
*/
typedef struct {
bool prefer_sockets;
bool dies_supported;
bool clusters_supported;
+ bool has_clusters;
} SMPCompatProps;
qemu-options.hx SRST · line 346
Quoted 13 lines
include/hw/boards.h +0
-0} CpuTopology;/** qemu-options.hx +2
-0@@ -342,6 +342,8 @@ SRST were preferred over threads), however, this behaviour is considered liable to change. Prior to 6.2 the preference was sockets over cores over threads. Since 6.2 the preference is cores over sockets over threads. + The cluster topology will only be generated if explicitly specified + by the "-cluster" option.
no "-cluster" option, only "-smp" :)
qemu-options.hx SRST · line 348
Quoted 2 lines
qemu-options.hx +0
-0For example, the following option defines a machine board with 2 sockets of 1 core before 6.2 and 1 socket of 2 cores after 6.2:
Maybe better to add a note at *end* of the doc about -smp like:
Note: The cluster topology will only be generated in ACPI and exposed to guest if it's explicitly specified in -smp.
Thanks,
Yanan
Re: [PATCH v2 1/4] hw/acpi/aml-build: Only generate cluster node in PPTT when specified
Hi Yanan,
Quoted 81 lines · wangyanan (Y)
Hi Yicong,
Quoted 70 lines · Yicong Yang
From: Yicong Yang <[email protected]>
Currently we'll always generate a cluster node no matter user has specified '-smp clusters=X' or not. Cluster is an optional level and will participant the building of Linux scheduling domains and only appears on a few platforms. It's unncessary to always build it which cannot reflect the real topology on platforms have no cluster and to avoid affecting the linux scheduling domains in the VM. So only generate it when user specified explicitly.
Tested qemu-system-aarch64 with
-smp 8and linux 6.1-rc1, without this patch:estuary:/sys/devices/system/cpu/cpu0/topology$ cat cluster_* ff # cluster_cpus 0-7 # cluster_cpus_list 56 # cluster_idwith this patch:
estuary:/sys/devices/system/cpu/cpu0/topology$ cat cluster_* ff # cluster_cpus 0-7 # cluster_cpus_list 36 # cluster_id, with no cluster node kernel will make it to physical package idSigned-off-by Yicong Yang <[email protected]>---
hw/acpi/aml-build.c | 2 +-
hw/core/machine-smp.c| 3 +++
include/hw/boards.h | 2 ++
qemu-options.hx | 2 ++4 files changed, 8 insertions(+), 1 deletion(-)hw/acpi/aml-build.c +1
-0@@ -2030,7 +2030,7 @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms, 0, socket_id, NULL, 0); } - if (mc->smp_props.clusters_supported) { + if (mc->smp_props.clusters_supported && ms->smp.build_cluster) { if (cpus->cpus[n].props.cluster_id != cluster_id) { assert(cpus->cpus[n].props.cluster_id > cluster_id); cluster_id = cpus->cpus[n].props.cluster_id;hw/core/machine-smp.c +2
-0@@ -158,6 +158,9 @@ void machine_parse_smp_config(MachineState *ms, ms->smp.threads = threads; ms->smp.max_cpus = maxcpus; + if (config->has_clusters) + ms->smp.build_cluster = true; + /* sanity-check of the computed topology */ if (sockets * dies * clusters * cores * threads != maxcpus) { g_autofree char *topo_msg = cpu_hierarchy_to_string(ms);include/hw/boards.h +1
-0@@ -305,6 +305,7 @@ typedef struct DeviceMemoryState {* @cores: the number of cores in one cluster * @threads: the number of threads in one core * @max_cpus: the maximum number of logical processors on the machine +* @build_cluster: build cluster topology or not */ typedef struct CpuTopology { unsigned int cpus;include/hw/boards.h typedef struct CpuTopology { · line 318
Quoted 4 lines
include/hw/boards.h +1
-0@@ -314,6 +315,7 @@ typedef struct CpuTopology { unsigned int cores; unsigned int threads; unsigned int max_cpus; + bool build_cluster;
build_clusterseems a variable defined specifically for ACPI PPTT generation. It may not be proper to place it in the generic struct CpuTopology which only holds topo members.
Quoted 3 lines
What about a more generic variable in struct SMPCompatProps together with @clusters_supported. Something like below:
ok. will follow the suggestion. Thanks for the snippet :)
Quoted 23 lines
include/hw/boards.h +3
-0@@ -130,11 +130,14 @@ typedef struct {* @prefer_sockets - whether sockets are preferred over cores in smp parsing * @dies_supported - whether dies are supported by the machine * @clusters_supported - whether clusters are supported by the machine +* @has_clusters - whether clusters is explicitly specified in the user +* provided SMP configuration. */ typedef struct { bool prefer_sockets; bool dies_supported; bool clusters_supported; + bool has_clusters; } SMPCompatProps; > } CpuTopology;Quoted 4 lines
include/hw/boards.h +0
-0/**qemu-options.hx +0
-1--- a/qemu-options.hx
Quoted 8 lines
Quoted 7 lines
+++ b/qemu-options.hx
qemu-options.hx +0
-0@@ -342,6 +342,8 @@ SRSTwere preferred over threads), however, this behaviour is considered liable to change. Prior to 6.2 the preference was sockets over cores over threads. Since 6.2 the preference is cores over sockets over threads. + The cluster topology will only be generated if explicitly specified + by the "-cluster" option.
no "-cluster" option, only "-smp" :)
ok.
Quoted 7 lines
Quoted 2 lines
For example, the following option defines a machine board with 2 sockets of 1 core before 6.2 and 1 socket of 2 cores after 6.2:
Maybe better to add a note at *end* of the doc about -smp like:
Note: The cluster topology will only be generated in ACPI and exposed to guest if it's explicitly specified in -smp.
will do.
Thanks.
PATCH v2 2/4 tests: virt: update expected ACPI tables for virt test
In reply to Yicong Yang viaFrom: Yicong Yang <[email protected]>
Update the ACPI tables according to the acpi aml_build change.
--- tests/data/acpi/virt/PPTT | Bin 96 -> 76 bytes 1 file changed, 0 insertions(+), 0 deletions(-)
tests/data/acpi/virt/PPTT binary +0 -0
Signature · 1 line
2.24.0
Re: [PATCH v2 2/4] tests: virt: update expected ACPI tables for virt test
Quoted 5 lines · Yicong Yang
From: Yicong Yang <[email protected]>
Update the ACPI tables according to the acpi
aml_buildchange.Signed-off-by Yicong Yang <[email protected]>
OK nice but if patch 1 is applied alone that will break make check won't it? And this means the patchset breaks git bisect. Pls look at top of tests/qtest/bios-tables-test.c to see how to organize a patchset changing expected tables.
Quoted 15 lines
--- tests/data/acpi/virt/PPTT | Bin 96 -> 76 bytes 1 file changed, 0 insertions(+), 0 deletions(-)tests/data/acpi/virt/PPTT binary +0
-0Signature · 2 lines
-- 2.24.0
Re: [PATCH v2 2/4] tests: virt: update expected ACPI tables for virt test
Quoted 12 lines · Michael S. Tsirkin
Quoted 5 lines · Yicong Yang
From: Yicong Yang <[email protected]>
Update the ACPI tables according to the acpi
aml_buildchange.Signed-off-by Yicong Yang <[email protected]>OK nice but if patch 1 is applied alone that will break make check won't it? And this means the patchset breaks git bisect. Pls look at top of
tests/qtest/bios-tables-test.cto see how to organize a patchset changing expected tables.
Will follow the guidance and correctly mentioned the changes in tests/qtest/bios-tables-test-allowed-diff.h. So is the rest patches in the series.
Thanks.
Quoted 19 lines
Quoted 16 lines
--- tests/data/acpi/virt/PPTT | Bin 96 -> 76 bytes 1 file changed, 0 insertions(+), 0 deletions(-)tests/data/acpi/virt/PPTT binary +0
-0Signature · 2 lines
-- 2.24.0.
PATCH v2 3/4 tests: acpi: aarch64: add topology test for aarch64
In reply to Yicong Yang viaFrom: Yicong Yang <[email protected]>
Add test for aarch64's ACPI topology building for all the supported levels.
--- tests/qtest/bios-tables-test.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
tests/qtest/bios-tables-test.c +22 -0
@@ -1533,6 +1533,27 @@ static void test_acpi_virt_tcg(void)free_test_data (&data); } +static void test_acpi_virt_tcg_topology (void ) +{ +test_data data = { + .machine ="virt" , + .variant =".topology" , + .tcg_only = true, + .uefi_fl1 ="pc-bios/edk2-aarch64-code.fd" , + .uefi_fl2 ="pc-bios/edk2-arm-vars.fd" , + .cd ="tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2" , + .ram_start =0x40000000ULL , + .scan_len =128ULL *1024 *1024 , + }; + + data.smbios_cpu_max_speed =2900 ; + data.smbios_cpu_curr_speed =2700 ; +test_acpi_one ("-cpu cortex-a57 " +"-smbios type=4,max-speed=2900,current-speed=2700 " +"-smp sockets=1,clusters=2,cores=2,threads=2" , &data); +free_test_data (&data); +} +static void test_acpi_q35_viot (void ) {test_data data = {
@@ -1864,6 +1885,7 @@ int main(int argc, char *argv[]) }else if (strcmp (arch,"aarch64" ) ==0 ) {if (has_tcg) {qtest_add_func ("acpi/virt" , test_acpi_virt_tcg); +qtest_add_func ("acpi/virt/topology" , test_acpi_virt_tcg_topology);qtest_add_func ("acpi/virt/numamem" , test_acpi_virt_tcg_numamem);qtest_add_func ("acpi/virt/memhp" , test_acpi_virt_tcg_memhp);qtest_add_func ("acpi/virt/pxb" , test_acpi_virt_tcg_pxb);
Signature · 1 line
2.24.0
Re: [PATCH v2 3/4] tests: acpi: aarch64: add topology test for aarch64
Quoted 6 lines · Yicong Yang
From: Yicong Yang <[email protected]>
Add test for aarch64's ACPI topology building for all the supported levels.
Signed-off-by Yicong Yang <[email protected]>
And same comment here.
Pls follow the process in bios-tables-test
Quoted 46 lines
--- tests/qtest/bios-tables-test.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)tests/qtest/bios-tables-test.c +22
-0@@ -1533,6 +1533,27 @@ static void test_acpi_virt_tcg(void)free_test_data (&data); } +static void test_acpi_virt_tcg_topology (void ) +{ +test_data data = { + .machine ="virt" , + .variant =".topology" , + .tcg_only = true, + .uefi_fl1 ="pc-bios/edk2-aarch64-code.fd" , + .uefi_fl2 ="pc-bios/edk2-arm-vars.fd" , + .cd ="tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2" , + .ram_start =0x40000000ULL , + .scan_len =128ULL *1024 *1024 , + }; + + data.smbios_cpu_max_speed =2900 ; + data.smbios_cpu_curr_speed =2700 ; +test_acpi_one ("-cpu cortex-a57 " +"-smbios type=4,max-speed=2900,current-speed=2700 " +"-smp sockets=1,clusters=2,cores=2,threads=2" , &data); +free_test_data (&data); +} +static void test_acpi_q35_viot (void ) {test_data data = {@@ -1864,6 +1885,7 @@ int main(int argc, char *argv[]) }else if (strcmp (arch,"aarch64" ) ==0 ) {if (has_tcg) {qtest_add_func ("acpi/virt" , test_acpi_virt_tcg); +qtest_add_func ("acpi/virt/topology" , test_acpi_virt_tcg_topology);qtest_add_func ("acpi/virt/numamem" , test_acpi_virt_tcg_numamem);qtest_add_func ("acpi/virt/memhp" , test_acpi_virt_tcg_memhp);qtest_add_func ("acpi/virt/pxb" , test_acpi_virt_tcg_pxb);Signature · 1 line
2.24.0
PATCH v2 4/4 tests: acpi: aarch64: add *.topology tables
In reply to Yicong Yang viaFrom: Yicong Yang <[email protected]>
Add *.topology tables for the aarch64's topology test.
--- tests/data/acpi/virt/APIC.topology | Bin 0 -> 700 bytes tests/data/acpi/virt/DSDT.topology | Bin 0 -> 5398 bytes tests/data/acpi/virt/PPTT.topology | Bin 0 -> 336 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/data/acpi/virt/APIC.topology create mode 100644 tests/data/acpi/virt/DSDT.topology create mode 100644 tests/data/acpi/virt/PPTT.topology
tests/data/acpi/virt/APIC.topology new file binary +0 -0
tests/data/acpi/virt/DSDT.topology new file binary +0 -0
tests/data/acpi/virt/PPTT.topology new file binary +0 -0
Signature · 1 line
2.24.0
Quoted 20 lines · Yicong Yang
From: Yicong Yang <[email protected]>
This series mainly change the policy for building a cluster topology node in PPTT. Previously we'll always build a cluster node in PPTT without asking the user, after this set the cluster node will be built only the the user specify through "-smp clusters=X".
One problem is related to this but not fully caused by this, see the discussion in [*]. When booting the VM with
-smp 8and 4 numa nodes, the linux scheduling domains in the VM misses the NUMA domains. It's because the MC level span extends to Cluster level (which is generated by the Qemu by default) that spans all the cpus in the system, then the scheduling domain building stops at MC level since it already includes all the cpus.Considering cluster is an optional level and most platforms don't have it, they may even don't realize this is built and a always build policy cannot emulate the topology on these platforms. So in this series improve the policy to only generate cluster when the user explicitly want.
Quoted 8 lines
Update the tests and test tables accordingly.
[*] https://lore.kernel.org/lkml/[email protected]/
Change since v1:
- Only includes the test tables which is really needed
- Enrich the commit
Looks superficually ok. ARM maintainers? Ack? Will you take this or want me to?
Quoted 22 lines
Yicong Yang (4):
hw/acpi/aml-build: Only generate cluster node in PPTT when specified
tests: virt: update expected ACPI tables for virt test
tests: acpi: aarch64: add topology test for aarch64
tests: acpi: aarch64: add *.topology tableshw/acpi/aml-build.c | 2 +- hw/core/machine-smp.c | 3 +++ include/hw/boards.h | 2 ++ qemu-options.hx | 2 ++ tests/data/acpi/virt/APIC.topology | Bin 0 -> 700 bytes tests/data/acpi/virt/DSDT.topology | Bin 0 -> 5398 bytes tests/data/acpi/virt/PPTT | Bin 96 -> 76 bytes tests/data/acpi/virt/PPTT.topology | Bin 0 -> 336 bytes tests/qtest/bios-tables-test.c | 22 ++++++++++++++++++++++ 9 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/data/acpi/virt/APIC.topology create mode 100644 tests/data/acpi/virt/DSDT.topology create mode 100644 tests/data/acpi/virt/PPTT.topologySignature · 1 line
2.24.0