thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-qtest-numa-test-Correct-CPU-and-NUMA-association-in-.patch

29b115
From a039ed652e6d2f5edcef9d5d1d3baec17ce7f929 Mon Sep 17 00:00:00 2001
29b115
From: Gavin Shan <gshan@redhat.com>
29b115
Date: Wed, 11 May 2022 18:01:35 +0800
29b115
Subject: [PATCH 04/16] qtest/numa-test: Correct CPU and NUMA association in
29b115
 aarch64_numa_cpu()
29b115
29b115
RH-Author: Gavin Shan <gshan@redhat.com>
29b115
RH-MergeRequest: 86: hw/arm/virt: Fix the default CPU topology
29b115
RH-Commit: [4/6] 64e9908a179eb4fb586d662f70f275a81808e50c (gwshan/qemu-rhel-9)
29b115
RH-Bugzilla: 2041823
29b115
RH-Acked-by: Eric Auger <eric.auger@redhat.com>
29b115
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
29b115
RH-Acked-by: Andrew Jones <drjones@redhat.com>
29b115
29b115
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2041823
29b115
29b115
In aarch64_numa_cpu(), the CPU and NUMA association is something
29b115
like below. Two threads in the same core/cluster/socket are
29b115
associated with two individual NUMA nodes, which is unreal as
29b115
Igor Mammedov mentioned. We don't expect the association to break
29b115
NUMA-to-socket boundary, which matches with the real world.
29b115
29b115
NUMA-node socket cluster core thread
29b115
------------------------------------------
29b115
0 0 0 0 0
29b115
1 0 0 0 1
29b115
29b115
This corrects the topology for CPUs and their association with
29b115
NUMA nodes. After this patch is applied, the CPU and NUMA
29b115
association becomes something like below, which looks real.
29b115
Besides, socket/cluster/core/thread IDs are all checked when
29b115
the NUMA node IDs are verified. It helps to check if the CPU
29b115
topology is properly populated or not.
29b115
29b115
NUMA-node socket cluster core thread
29b115
------------------------------------------
29b115
0 1 0 0 0
29b115
1 0 0 0 0
29b115
29b115
Suggested-by: Igor Mammedov <imammedo@redhat.com>
29b115
Signed-off-by: Gavin Shan <gshan@redhat.com>
29b115
Acked-by: Igor Mammedov <imammedo@redhat.com>
29b115
Message-id: 20220503140304.855514-5-gshan@redhat.com
29b115
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
29b115
(cherry picked from commit e280ecb39bc1629f74ea5479d464fd1608dc8f76)
29b115
Signed-off-by: Gavin Shan <gshan@redhat.com>
29b115
---
29b115
 tests/qtest/numa-test.c | 18 ++++++++++++------
29b115
 1 file changed, 12 insertions(+), 6 deletions(-)
29b115
29b115
diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c
29b115
index aeda8c774c..32e35daaae 100644
29b115
--- a/tests/qtest/numa-test.c
29b115
+++ b/tests/qtest/numa-test.c
29b115
@@ -224,17 +224,17 @@ static void aarch64_numa_cpu(const void *data)
29b115
     g_autofree char *cli = NULL;
29b115
 
29b115
     cli = make_cli(data, "-machine "
29b115
-        "smp.cpus=2,smp.sockets=1,smp.clusters=1,smp.cores=1,smp.threads=2 "
29b115
+        "smp.cpus=2,smp.sockets=2,smp.clusters=1,smp.cores=1,smp.threads=1 "
29b115
         "-numa node,nodeid=0,memdev=ram -numa node,nodeid=1 "
29b115
-        "-numa cpu,node-id=1,thread-id=0 "
29b115
-        "-numa cpu,node-id=0,thread-id=1");
29b115
+        "-numa cpu,node-id=0,socket-id=1,cluster-id=0,core-id=0,thread-id=0 "
29b115
+        "-numa cpu,node-id=1,socket-id=0,cluster-id=0,core-id=0,thread-id=0");
29b115
     qts = qtest_init(cli);
29b115
     cpus = get_cpus(qts, &resp);
29b115
     g_assert(cpus);
29b115
 
29b115
     while ((e = qlist_pop(cpus))) {
29b115
         QDict *cpu, *props;
29b115
-        int64_t thread, node;
29b115
+        int64_t socket, cluster, core, thread, node;
29b115
 
29b115
         cpu = qobject_to(QDict, e);
29b115
         g_assert(qdict_haskey(cpu, "props"));
29b115
@@ -242,12 +242,18 @@ static void aarch64_numa_cpu(const void *data)
29b115
 
29b115
         g_assert(qdict_haskey(props, "node-id"));
29b115
         node = qdict_get_int(props, "node-id");
29b115
+        g_assert(qdict_haskey(props, "socket-id"));
29b115
+        socket = qdict_get_int(props, "socket-id");
29b115
+        g_assert(qdict_haskey(props, "cluster-id"));
29b115
+        cluster = qdict_get_int(props, "cluster-id");
29b115
+        g_assert(qdict_haskey(props, "core-id"));
29b115
+        core = qdict_get_int(props, "core-id");
29b115
         g_assert(qdict_haskey(props, "thread-id"));
29b115
         thread = qdict_get_int(props, "thread-id");
29b115
 
29b115
-        if (thread == 0) {
29b115
+        if (socket == 0 && cluster == 0 && core == 0 && thread == 0) {
29b115
             g_assert_cmpint(node, ==, 1);
29b115
-        } else if (thread == 1) {
29b115
+        } else if (socket == 1 && cluster == 0 && core == 0 && thread == 0) {
29b115
             g_assert_cmpint(node, ==, 0);
29b115
         } else {
29b115
             g_assert(false);
29b115
-- 
29b115
2.31.1
29b115