yeahuh / rpms / qemu-kvm

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