From: Yanan Wang via <qemu-devel@nongnu.org>
To: <qemu-devel@nongnu.org>, <qemu-arm@nongnu.org>
Cc: Peter Maydell <peter.maydell@linaro.org>,
Andrew Jones <drjones@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
Igor Mammedov <imammedo@redhat.com>,
Shannon Zhao <shannon.zhaosl@gmail.com>,
Ani Sinha <ani@anisinha.ca>, Eric Auger <eauger@redhat.com>,
<wanghaibin.wang@huawei.com>, Yanan Wang <wangyanan55@huawei.com>
Subject: [PATCH v6 3/7] hw/acpi/aml-build: Improve scalability of PPTT generation
Date: Mon, 3 Jan 2022 16:46:32 +0800 [thread overview]
Message-ID: <20220103084636.2496-4-wangyanan55@huawei.com> (raw)
In-Reply-To: <20220103084636.2496-1-wangyanan55@huawei.com>
Currently we generate a PPTT table of n-level processor hierarchy
with n-level loops in build_pptt(). It works fine as now there are
only three CPU topology parameters. But the code may become less
scalable with the processor hierarchy levels increasing.
This patch only improves the scalability of build_pptt by reducing
the loops, and intends to make no functional change.
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
---
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..be3851be36 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 father_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;
+ father_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);
- }
+ father_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);
+ father_offset, uid++, NULL, 0);
}
}
}
+ length = g_queue_get_length(list);
+ for (i = 0; i < length; i++) {
+ int thread;
+
+ father_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 */
+ father_offset, uid++, NULL, 0);
+ }
+ }
+
+ g_queue_free(list);
acpi_table_end(linker, &table);
}
--
2.27.0
next prev parent reply other threads:[~2022-01-03 8:52 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-03 8:46 [PATCH v6 0/7] ARM virt: Support CPU cluster topology Yanan Wang via
2022-01-03 8:46 ` [PATCH v6 1/7] hw/arm/virt: Support CPU cluster on ARM virt machine Yanan Wang via
2022-01-03 11:24 ` Andrew Jones
2022-01-03 8:46 ` [PATCH v6 2/7] hw/arm/virt: Support cluster level in DT cpu-map Yanan Wang via
2022-01-03 11:25 ` Andrew Jones
2022-01-03 8:46 ` Yanan Wang via [this message]
2022-01-03 11:24 ` [PATCH v6 3/7] hw/acpi/aml-build: Improve scalability of PPTT generation Andrew Jones
2022-01-04 2:05 ` wangyanan (Y) via
2022-01-03 8:46 ` [PATCH v6 4/7] hw/arm/virt-acpi-build: Make an ARM specific PPTT generator Yanan Wang via
2022-01-03 11:30 ` Andrew Jones
2022-01-04 2:06 ` wangyanan (Y) via
2022-01-03 8:46 ` [PATCH v6 5/7] tests/acpi/bios-tables-test: Allow changes to virt/PPTT file Yanan Wang via
2022-01-03 11:51 ` Ani Sinha
2022-01-03 8:46 ` [PATCH v6 6/7] hw/arm/virt-acpi-build: Support cluster level in PPTT generation Yanan Wang via
2022-01-03 11:32 ` Andrew Jones
2022-01-04 2:15 ` wangyanan (Y) via
2022-01-03 8:46 ` [PATCH v6 7/7] tests/acpi/bios-table-test: Update expected virt/PPTT file Yanan Wang via
2022-01-03 12:01 ` Ani Sinha
2022-01-04 2:28 ` wangyanan (Y) via
2022-01-04 4:27 ` Ani Sinha
2022-01-04 4:51 ` wangyanan (Y) via
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220103084636.2496-4-wangyanan55@huawei.com \
--to=qemu-devel@nongnu.org \
--cc=ani@anisinha.ca \
--cc=drjones@redhat.com \
--cc=eauger@redhat.com \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=shannon.zhaosl@gmail.com \
--cc=wanghaibin.wang@huawei.com \
--cc=wangyanan55@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).