cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
902636
From 0f11aae02dcabd3a5ee0b5946aec39da6dddea52 Mon Sep 17 00:00:00 2001
902636
From: "plai@redhat.com" <plai@redhat.com>
902636
Date: Thu, 21 May 2020 23:56:53 +0100
902636
Subject: [PATCH 10/12] tests/numa: Add case for QMP build HMAT
902636
902636
RH-Author: plai@redhat.com
902636
Message-id: <20200521235655.27141-10-plai@redhat.com>
902636
Patchwork-id: 96735
902636
O-Subject: [RHEL8.2.1 AV qemu-kvm PATCH 09/11] tests/numa: Add case for QMP build HMAT
902636
Bugzilla: 1600217
902636
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
902636
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
902636
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
902636
902636
From: Tao Xu <tao3.xu@intel.com>
902636
902636
Check configuring HMAT usecase
902636
902636
Acked-by: Markus Armbruster <armbru@redhat.com>
902636
Suggested-by: Igor Mammedov <imammedo@redhat.com>
902636
Signed-off-by: Tao Xu <tao3.xu@intel.com>
902636
Message-Id: <20191213011929.2520-8-tao3.xu@intel.com>
902636
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
902636
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
902636
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
902636
(cherry picked from commit d00817c944ed15fbe4a61d44fe7f9fe166c7df88)
902636
Signed-off-by: Paul Lai <plai@redhat.com>
902636
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
902636
---
902636
 tests/numa-test.c | 213 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
902636
 1 file changed, 213 insertions(+)
902636
902636
diff --git a/tests/numa-test.c b/tests/numa-test.c
902636
index 8de8581..17dd807 100644
902636
--- a/tests/numa-test.c
902636
+++ b/tests/numa-test.c
902636
@@ -327,6 +327,216 @@ static void pc_dynamic_cpu_cfg(const void *data)
902636
     qtest_quit(qs);
902636
 }
902636
 
902636
+static void pc_hmat_build_cfg(const void *data)
902636
+{
902636
+    QTestState *qs = qtest_initf("%s -nodefaults --preconfig -machine hmat=on "
902636
+                     "-smp 2,sockets=2 "
902636
+                     "-m 128M,slots=2,maxmem=1G "
902636
+                     "-object memory-backend-ram,size=64M,id=m0 "
902636
+                     "-object memory-backend-ram,size=64M,id=m1 "
902636
+                     "-numa node,nodeid=0,memdev=m0 "
902636
+                     "-numa node,nodeid=1,memdev=m1,initiator=0 "
902636
+                     "-numa cpu,node-id=0,socket-id=0 "
902636
+                     "-numa cpu,node-id=0,socket-id=1",
902636
+                     data ? (char *)data : "");
902636
+
902636
+    /* Fail: Initiator should be less than the number of nodes */
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-lb', 'initiator': 2, 'target': 0,"
902636
+        " 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }")));
902636
+
902636
+    /* Fail: Target should be less than the number of nodes */
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 2,"
902636
+        " 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }")));
902636
+
902636
+    /* Fail: Initiator should contain cpu */
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-lb', 'initiator': 1, 'target': 0,"
902636
+        " 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }")));
902636
+
902636
+    /* Fail: Data-type mismatch */
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
902636
+        " 'hierarchy': \"memory\", 'data-type': \"write-latency\","
902636
+        " 'bandwidth': 524288000 } }")));
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
902636
+        " 'hierarchy': \"memory\", 'data-type': \"read-bandwidth\","
902636
+        " 'latency': 5 } }")));
902636
+
902636
+    /* Fail: Bandwidth should be 1MB (1048576) aligned */
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
902636
+        " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\","
902636
+        " 'bandwidth': 1048575 } }")));
902636
+
902636
+    /* Configuring HMAT bandwidth and latency details */
902636
+    g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
902636
+        " 'hierarchy': \"memory\", 'data-type': \"access-latency\","
902636
+        " 'latency': 1 } }")));    /* 1 ns */
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
902636
+        " 'hierarchy': \"memory\", 'data-type': \"access-latency\","
902636
+        " 'latency': 5 } }")));    /* Fail: Duplicate configuration */
902636
+    g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
902636
+        " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\","
902636
+        " 'bandwidth': 68717379584 } }")));    /* 65534 MB/s */
902636
+    g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1,"
902636
+        " 'hierarchy': \"memory\", 'data-type': \"access-latency\","
902636
+        " 'latency': 65534 } }")));    /* 65534 ns */
902636
+    g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1,"
902636
+        " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\","
902636
+        " 'bandwidth': 34358689792 } }")));    /* 32767 MB/s */
902636
+
902636
+    /* Fail: node_id should be less than the number of nodes */
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-cache', 'node-id': 2, 'size': 10240,"
902636
+        " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\","
902636
+        " 'line': 8 } }")));
902636
+
902636
+    /* Fail: level should be less than HMAT_LB_LEVELS (4) */
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
902636
+        " 'level': 4, 'associativity': \"direct\", 'policy': \"write-back\","
902636
+        " 'line': 8 } }")));
902636
+
902636
+    /* Fail: associativity option should be 'none', if level is 0 */
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
902636
+        " 'level': 0, 'associativity': \"direct\", 'policy': \"none\","
902636
+        " 'line': 0 } }")));
902636
+    /* Fail: policy option should be 'none', if level is 0 */
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
902636
+        " 'level': 0, 'associativity': \"none\", 'policy': \"write-back\","
902636
+        " 'line': 0 } }")));
902636
+    /* Fail: line option should be 0, if level is 0 */
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
902636
+        " 'level': 0, 'associativity': \"none\", 'policy': \"none\","
902636
+        " 'line': 8 } }")));
902636
+
902636
+    /* Configuring HMAT memory side cache attributes */
902636
+    g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
902636
+        " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\","
902636
+        " 'line': 8 } }")));
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
902636
+        " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\","
902636
+        " 'line': 8 } }")));    /* Fail: Duplicate configuration */
902636
+    /* Fail: The size of level 2 size should be small than level 1 */
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
902636
+        " 'level': 2, 'associativity': \"direct\", 'policy': \"write-back\","
902636
+        " 'line': 8 } }")));
902636
+    /* Fail: The size of level 0 size should be larger than level 1 */
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
902636
+        " 'level': 0, 'associativity': \"direct\", 'policy': \"write-back\","
902636
+        " 'line': 8 } }")));
902636
+    g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-cache', 'node-id': 1, 'size': 10240,"
902636
+        " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\","
902636
+        " 'line': 8 } }")));
902636
+
902636
+    /* let machine initialization to complete and run */
902636
+    g_assert_false(qmp_rsp_is_err(qtest_qmp(qs,
902636
+        "{ 'execute': 'x-exit-preconfig' }")));
902636
+    qtest_qmp_eventwait(qs, "RESUME");
902636
+
902636
+    qtest_quit(qs);
902636
+}
902636
+
902636
+static void pc_hmat_off_cfg(const void *data)
902636
+{
902636
+    QTestState *qs = qtest_initf("%s -nodefaults --preconfig "
902636
+                     "-smp 2,sockets=2 "
902636
+                     "-m 128M,slots=2,maxmem=1G "
902636
+                     "-object memory-backend-ram,size=64M,id=m0 "
902636
+                     "-object memory-backend-ram,size=64M,id=m1 "
902636
+                     "-numa node,nodeid=0,memdev=m0",
902636
+                     data ? (char *)data : "");
902636
+
902636
+    /*
902636
+     * Fail: Enable HMAT with -machine hmat=on
902636
+     * before using any of hmat specific options
902636
+     */
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'node', 'nodeid': 1, 'memdev': \"m1\","
902636
+        " 'initiator': 0 } }")));
902636
+    g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'node', 'nodeid': 1, 'memdev': \"m1\" } }")));
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
902636
+        " 'hierarchy': \"memory\", 'data-type': \"access-latency\","
902636
+        " 'latency': 1 } }")));
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
902636
+        " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\","
902636
+        " 'line': 8 } }")));
902636
+
902636
+    /* let machine initialization to complete and run */
902636
+    g_assert_false(qmp_rsp_is_err(qtest_qmp(qs,
902636
+        "{ 'execute': 'x-exit-preconfig' }")));
902636
+    qtest_qmp_eventwait(qs, "RESUME");
902636
+
902636
+    qtest_quit(qs);
902636
+}
902636
+
902636
+static void pc_hmat_erange_cfg(const void *data)
902636
+{
902636
+    QTestState *qs = qtest_initf("%s -nodefaults --preconfig -machine hmat=on "
902636
+                     "-smp 2,sockets=2 "
902636
+                     "-m 128M,slots=2,maxmem=1G "
902636
+                     "-object memory-backend-ram,size=64M,id=m0 "
902636
+                     "-object memory-backend-ram,size=64M,id=m1 "
902636
+                     "-numa node,nodeid=0,memdev=m0 "
902636
+                     "-numa node,nodeid=1,memdev=m1,initiator=0 "
902636
+                     "-numa cpu,node-id=0,socket-id=0 "
902636
+                     "-numa cpu,node-id=0,socket-id=1",
902636
+                     data ? (char *)data : "");
902636
+
902636
+    /* Can't store the compressed latency */
902636
+    g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
902636
+        " 'hierarchy': \"memory\", 'data-type': \"access-latency\","
902636
+        " 'latency': 1 } }")));    /* 1 ns */
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1,"
902636
+        " 'hierarchy': \"memory\", 'data-type': \"access-latency\","
902636
+        " 'latency': 65535 } }")));    /* 65535 ns */
902636
+
902636
+    /* Test the 0 input (bandwidth not provided) */
902636
+    g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
902636
+        " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\","
902636
+        " 'bandwidth': 0 } }")));    /* 0 MB/s */
902636
+    /* Fail: bandwidth should be provided before memory side cache attributes */
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
902636
+        " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\","
902636
+        " 'line': 8 } }")));
902636
+
902636
+    /* Can't store the compressed bandwidth */
902636
+    g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
902636
+        " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1,"
902636
+        " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\","
902636
+        " 'bandwidth': 68718428160 } }")));    /* 65535 MB/s */
902636
+
902636
+    /* let machine initialization to complete and run */
902636
+    g_assert_false(qmp_rsp_is_err(qtest_qmp(qs,
902636
+        "{ 'execute': 'x-exit-preconfig' }")));
902636
+    qtest_qmp_eventwait(qs, "RESUME");
902636
+
902636
+    qtest_quit(qs);
902636
+}
902636
+
902636
 int main(int argc, char **argv)
902636
 {
902636
     const char *args = NULL;
902636
@@ -346,6 +556,9 @@ int main(int argc, char **argv)
902636
     if (!strcmp(arch, "i386") || !strcmp(arch, "x86_64")) {
902636
         qtest_add_data_func("/numa/pc/cpu/explicit", args, pc_numa_cpu);
902636
         qtest_add_data_func("/numa/pc/dynamic/cpu", args, pc_dynamic_cpu_cfg);
902636
+        qtest_add_data_func("/numa/pc/hmat/build", args, pc_hmat_build_cfg);
902636
+        qtest_add_data_func("/numa/pc/hmat/off", args, pc_hmat_off_cfg);
902636
+        qtest_add_data_func("/numa/pc/hmat/erange", args, pc_hmat_erange_cfg);
902636
     }
902636
 
902636
     if (!strcmp(arch, "ppc64")) {
902636
-- 
902636
1.8.3.1
902636