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

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