cryptospore / rpms / qemu-kvm

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