114 lines
4.1 KiB
Diff
114 lines
4.1 KiB
Diff
From 66c935b435d90ef9c1ae4446c5edc07cbd8ba0ed Mon Sep 17 00:00:00 2001
|
|
From: Yanan Wang <wangyanan55@huawei.com>
|
|
Date: Fri, 7 Jan 2022 16:32:29 +0800
|
|
Subject: [PATCH 17/24] hw/acpi/aml-build: Improve scalability of PPTT
|
|
generation
|
|
|
|
Use g_queue APIs to reduce the nested loops and code indentation
|
|
with the processor hierarchy levels increasing. Consenquently,
|
|
it's more scalable to add new topology level to build_pptt.
|
|
|
|
No functional change intended.
|
|
|
|
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
|
|
Reviewed-by: Andrew Jones <drjones@redhat.com>
|
|
Message-id: 20220107083232.16256-4-wangyanan55@huawei.com
|
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
|
---
|
|
hw/acpi/aml-build.c | 50 +++++++++++++++++++++++++++++----------------
|
|
1 file changed, 32 insertions(+), 18 deletions(-)
|
|
|
|
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
|
|
index b3b3310df3..6aaedca2e5 100644
|
|
--- a/hw/acpi/aml-build.c
|
|
+++ b/hw/acpi/aml-build.c
|
|
@@ -2001,7 +2001,10 @@ static void build_processor_hierarchy_node(GArray *tbl, uint32_t flags,
|
|
void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
|
|
const char *oem_id, const char *oem_table_id)
|
|
{
|
|
- int pptt_start = table_data->len;
|
|
+ GQueue *list = g_queue_new();
|
|
+ guint pptt_start = table_data->len;
|
|
+ guint parent_offset;
|
|
+ guint length, i;
|
|
int uid = 0;
|
|
int socket;
|
|
AcpiTable table = { .sig = "PPTT", .rev = 2,
|
|
@@ -2010,9 +2013,8 @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
|
|
acpi_table_begin(&table, table_data);
|
|
|
|
for (socket = 0; socket < ms->smp.sockets; socket++) {
|
|
- uint32_t socket_offset = table_data->len - pptt_start;
|
|
- int core;
|
|
-
|
|
+ g_queue_push_tail(list,
|
|
+ GUINT_TO_POINTER(table_data->len - pptt_start));
|
|
build_processor_hierarchy_node(
|
|
table_data,
|
|
/*
|
|
@@ -2021,35 +2023,47 @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
|
|
*/
|
|
(1 << 0),
|
|
0, socket, NULL, 0);
|
|
+ }
|
|
|
|
- for (core = 0; core < ms->smp.cores; core++) {
|
|
- uint32_t core_offset = table_data->len - pptt_start;
|
|
- int thread;
|
|
+ length = g_queue_get_length(list);
|
|
+ for (i = 0; i < length; i++) {
|
|
+ int core;
|
|
|
|
+ parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list));
|
|
+ for (core = 0; core < ms->smp.cores; core++) {
|
|
if (ms->smp.threads > 1) {
|
|
+ g_queue_push_tail(list,
|
|
+ GUINT_TO_POINTER(table_data->len - pptt_start));
|
|
build_processor_hierarchy_node(
|
|
table_data,
|
|
(0 << 0), /* not a physical package */
|
|
- socket_offset, core, NULL, 0);
|
|
-
|
|
- for (thread = 0; thread < ms->smp.threads; thread++) {
|
|
- build_processor_hierarchy_node(
|
|
- table_data,
|
|
- (1 << 1) | /* ACPI Processor ID valid */
|
|
- (1 << 2) | /* Processor is a Thread */
|
|
- (1 << 3), /* Node is a Leaf */
|
|
- core_offset, uid++, NULL, 0);
|
|
- }
|
|
+ parent_offset, core, NULL, 0);
|
|
} else {
|
|
build_processor_hierarchy_node(
|
|
table_data,
|
|
(1 << 1) | /* ACPI Processor ID valid */
|
|
(1 << 3), /* Node is a Leaf */
|
|
- socket_offset, uid++, NULL, 0);
|
|
+ parent_offset, uid++, NULL, 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
+ length = g_queue_get_length(list);
|
|
+ for (i = 0; i < length; i++) {
|
|
+ int thread;
|
|
+
|
|
+ parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list));
|
|
+ for (thread = 0; thread < ms->smp.threads; thread++) {
|
|
+ build_processor_hierarchy_node(
|
|
+ table_data,
|
|
+ (1 << 1) | /* ACPI Processor ID valid */
|
|
+ (1 << 2) | /* Processor is a Thread */
|
|
+ (1 << 3), /* Node is a Leaf */
|
|
+ parent_offset, uid++, NULL, 0);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ g_queue_free(list);
|
|
acpi_table_end(linker, &table);
|
|
}
|
|
|
|
--
|
|
2.27.0
|
|
|