2017-05-03 15:56:55 +03:00
|
|
|
/*
|
|
|
|
* NUMA configuration test cases
|
|
|
|
*
|
|
|
|
* Copyright (c) 2017 Red Hat Inc.
|
|
|
|
* Authors:
|
|
|
|
* Igor Mammedov <imammedo@redhat.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "qemu/osdep.h"
|
2020-08-04 21:00:40 +03:00
|
|
|
#include "libqos/libqtest.h"
|
2018-02-01 14:18:39 +03:00
|
|
|
#include "qapi/qmp/qdict.h"
|
2018-02-01 14:18:38 +03:00
|
|
|
#include "qapi/qmp/qlist.h"
|
2017-05-03 15:56:55 +03:00
|
|
|
|
2020-02-19 19:09:52 +03:00
|
|
|
static char *make_cli(const GString *generic_cli, const char *test_cli)
|
2017-05-03 15:56:55 +03:00
|
|
|
{
|
2020-02-19 19:09:52 +03:00
|
|
|
return g_strdup_printf("%s %s", generic_cli->str, test_cli);
|
2017-05-03 15:56:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_mon_explicit(const void *data)
|
|
|
|
{
|
2019-05-15 20:43:25 +03:00
|
|
|
QTestState *qts;
|
2020-02-19 19:09:52 +03:00
|
|
|
g_autofree char *s = NULL;
|
|
|
|
g_autofree char *cli = NULL;
|
2017-05-03 15:56:55 +03:00
|
|
|
|
2020-02-19 19:09:53 +03:00
|
|
|
cli = make_cli(data, "-smp 8 -numa node,nodeid=0,memdev=ram,cpus=0-3 "
|
|
|
|
"-numa node,nodeid=1,cpus=4-7");
|
2019-05-15 20:43:25 +03:00
|
|
|
qts = qtest_init(cli);
|
2017-05-03 15:56:55 +03:00
|
|
|
|
2019-05-15 20:43:25 +03:00
|
|
|
s = qtest_hmp(qts, "info numa");
|
2017-05-03 15:56:55 +03:00
|
|
|
g_assert(strstr(s, "node 0 cpus: 0 1 2 3"));
|
|
|
|
g_assert(strstr(s, "node 1 cpus: 4 5 6 7"));
|
|
|
|
|
2019-05-15 20:43:25 +03:00
|
|
|
qtest_quit(qts);
|
2017-05-03 15:56:55 +03:00
|
|
|
}
|
|
|
|
|
2020-02-19 19:09:53 +03:00
|
|
|
static void test_def_cpu_split(const void *data)
|
2017-05-03 15:56:55 +03:00
|
|
|
{
|
2019-05-15 20:43:25 +03:00
|
|
|
QTestState *qts;
|
2020-02-19 19:09:52 +03:00
|
|
|
g_autofree char *s = NULL;
|
|
|
|
g_autofree char *cli = NULL;
|
2017-05-03 15:56:55 +03:00
|
|
|
|
2020-02-19 19:09:53 +03:00
|
|
|
cli = make_cli(data, "-smp 8 -numa node,memdev=ram -numa node");
|
2019-05-15 20:43:25 +03:00
|
|
|
qts = qtest_init(cli);
|
2017-05-03 15:56:55 +03:00
|
|
|
|
2019-05-15 20:43:25 +03:00
|
|
|
s = qtest_hmp(qts, "info numa");
|
2017-05-03 15:56:55 +03:00
|
|
|
g_assert(strstr(s, "node 0 cpus: 0 2 4 6"));
|
|
|
|
g_assert(strstr(s, "node 1 cpus: 1 3 5 7"));
|
|
|
|
|
2019-05-15 20:43:25 +03:00
|
|
|
qtest_quit(qts);
|
2017-05-03 15:56:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_mon_partial(const void *data)
|
|
|
|
{
|
2019-05-15 20:43:25 +03:00
|
|
|
QTestState *qts;
|
2020-02-19 19:09:52 +03:00
|
|
|
g_autofree char *s = NULL;
|
|
|
|
g_autofree char *cli = NULL;
|
2017-05-03 15:56:55 +03:00
|
|
|
|
|
|
|
cli = make_cli(data, "-smp 8 "
|
2020-02-19 19:09:53 +03:00
|
|
|
"-numa node,nodeid=0,memdev=ram,cpus=0-1 "
|
2017-05-03 15:56:55 +03:00
|
|
|
"-numa node,nodeid=1,cpus=4-5 ");
|
2019-05-15 20:43:25 +03:00
|
|
|
qts = qtest_init(cli);
|
2017-05-03 15:56:55 +03:00
|
|
|
|
2019-05-15 20:43:25 +03:00
|
|
|
s = qtest_hmp(qts, "info numa");
|
2017-05-03 15:56:55 +03:00
|
|
|
g_assert(strstr(s, "node 0 cpus: 0 1 2 3 6 7"));
|
|
|
|
g_assert(strstr(s, "node 1 cpus: 4 5"));
|
|
|
|
|
2019-05-15 20:43:25 +03:00
|
|
|
qtest_quit(qts);
|
2017-05-03 15:56:55 +03:00
|
|
|
}
|
|
|
|
|
2019-05-15 20:43:25 +03:00
|
|
|
static QList *get_cpus(QTestState *qts, QDict **resp)
|
2017-05-10 14:29:56 +03:00
|
|
|
{
|
2019-05-15 20:43:25 +03:00
|
|
|
*resp = qtest_qmp(qts, "{ 'execute': 'query-cpus' }");
|
2017-05-10 14:29:56 +03:00
|
|
|
g_assert(*resp);
|
|
|
|
g_assert(qdict_haskey(*resp, "return"));
|
2017-05-26 14:04:55 +03:00
|
|
|
return qdict_get_qlist(*resp, "return");
|
2017-05-10 14:29:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_query_cpus(const void *data)
|
|
|
|
{
|
|
|
|
QDict *resp;
|
|
|
|
QList *cpus;
|
2017-05-26 14:04:55 +03:00
|
|
|
QObject *e;
|
2019-05-15 20:43:25 +03:00
|
|
|
QTestState *qts;
|
2020-02-19 19:09:52 +03:00
|
|
|
g_autofree char *cli = NULL;
|
2017-05-10 14:29:56 +03:00
|
|
|
|
2020-02-19 19:09:53 +03:00
|
|
|
cli = make_cli(data, "-smp 8 -numa node,memdev=ram,cpus=0-3 "
|
|
|
|
"-numa node,cpus=4-7");
|
2019-05-15 20:43:25 +03:00
|
|
|
qts = qtest_init(cli);
|
|
|
|
cpus = get_cpus(qts, &resp);
|
2017-05-10 14:29:56 +03:00
|
|
|
g_assert(cpus);
|
|
|
|
|
|
|
|
while ((e = qlist_pop(cpus))) {
|
|
|
|
QDict *cpu, *props;
|
|
|
|
int64_t cpu_idx, node;
|
|
|
|
|
2018-02-24 18:40:29 +03:00
|
|
|
cpu = qobject_to(QDict, e);
|
2017-05-10 14:29:56 +03:00
|
|
|
g_assert(qdict_haskey(cpu, "CPU"));
|
|
|
|
g_assert(qdict_haskey(cpu, "props"));
|
|
|
|
|
|
|
|
cpu_idx = qdict_get_int(cpu, "CPU");
|
|
|
|
props = qdict_get_qdict(cpu, "props");
|
|
|
|
g_assert(qdict_haskey(props, "node-id"));
|
|
|
|
node = qdict_get_int(props, "node-id");
|
|
|
|
if (cpu_idx >= 0 && cpu_idx < 4) {
|
|
|
|
g_assert_cmpint(node, ==, 0);
|
|
|
|
} else {
|
|
|
|
g_assert_cmpint(node, ==, 1);
|
|
|
|
}
|
2018-04-19 18:01:43 +03:00
|
|
|
qobject_unref(e);
|
2017-05-10 14:29:56 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 18:01:43 +03:00
|
|
|
qobject_unref(resp);
|
2019-05-15 20:43:25 +03:00
|
|
|
qtest_quit(qts);
|
2017-05-10 14:29:56 +03:00
|
|
|
}
|
|
|
|
|
2017-05-10 14:30:02 +03:00
|
|
|
static void pc_numa_cpu(const void *data)
|
|
|
|
{
|
|
|
|
QDict *resp;
|
|
|
|
QList *cpus;
|
2017-05-26 14:04:55 +03:00
|
|
|
QObject *e;
|
2019-05-15 20:43:25 +03:00
|
|
|
QTestState *qts;
|
2020-02-19 19:09:52 +03:00
|
|
|
g_autofree char *cli = NULL;
|
2017-05-10 14:30:02 +03:00
|
|
|
|
|
|
|
cli = make_cli(data, "-cpu pentium -smp 8,sockets=2,cores=2,threads=2 "
|
2020-02-19 19:09:53 +03:00
|
|
|
"-numa node,nodeid=0,memdev=ram -numa node,nodeid=1 "
|
2017-05-10 14:30:02 +03:00
|
|
|
"-numa cpu,node-id=1,socket-id=0 "
|
|
|
|
"-numa cpu,node-id=0,socket-id=1,core-id=0 "
|
|
|
|
"-numa cpu,node-id=0,socket-id=1,core-id=1,thread-id=0 "
|
|
|
|
"-numa cpu,node-id=1,socket-id=1,core-id=1,thread-id=1");
|
2019-05-15 20:43:25 +03:00
|
|
|
qts = qtest_init(cli);
|
|
|
|
cpus = get_cpus(qts, &resp);
|
2017-05-10 14:30:02 +03:00
|
|
|
g_assert(cpus);
|
|
|
|
|
|
|
|
while ((e = qlist_pop(cpus))) {
|
|
|
|
QDict *cpu, *props;
|
|
|
|
int64_t socket, core, thread, node;
|
|
|
|
|
2018-02-24 18:40:29 +03:00
|
|
|
cpu = qobject_to(QDict, e);
|
2017-05-10 14:30:02 +03:00
|
|
|
g_assert(qdict_haskey(cpu, "props"));
|
|
|
|
props = qdict_get_qdict(cpu, "props");
|
|
|
|
|
|
|
|
g_assert(qdict_haskey(props, "node-id"));
|
|
|
|
node = qdict_get_int(props, "node-id");
|
|
|
|
g_assert(qdict_haskey(props, "socket-id"));
|
|
|
|
socket = qdict_get_int(props, "socket-id");
|
|
|
|
g_assert(qdict_haskey(props, "core-id"));
|
|
|
|
core = qdict_get_int(props, "core-id");
|
|
|
|
g_assert(qdict_haskey(props, "thread-id"));
|
|
|
|
thread = qdict_get_int(props, "thread-id");
|
|
|
|
|
|
|
|
if (socket == 0) {
|
|
|
|
g_assert_cmpint(node, ==, 1);
|
|
|
|
} else if (socket == 1 && core == 0) {
|
|
|
|
g_assert_cmpint(node, ==, 0);
|
|
|
|
} else if (socket == 1 && core == 1 && thread == 0) {
|
|
|
|
g_assert_cmpint(node, ==, 0);
|
|
|
|
} else if (socket == 1 && core == 1 && thread == 1) {
|
|
|
|
g_assert_cmpint(node, ==, 1);
|
|
|
|
} else {
|
|
|
|
g_assert(false);
|
|
|
|
}
|
2018-04-19 18:01:43 +03:00
|
|
|
qobject_unref(e);
|
2017-05-10 14:30:02 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 18:01:43 +03:00
|
|
|
qobject_unref(resp);
|
2019-05-15 20:43:25 +03:00
|
|
|
qtest_quit(qts);
|
2017-05-10 14:30:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void spapr_numa_cpu(const void *data)
|
|
|
|
{
|
|
|
|
QDict *resp;
|
|
|
|
QList *cpus;
|
2017-05-26 14:04:55 +03:00
|
|
|
QObject *e;
|
2019-05-15 20:43:25 +03:00
|
|
|
QTestState *qts;
|
2020-02-19 19:09:52 +03:00
|
|
|
g_autofree char *cli = NULL;
|
2017-05-10 14:30:02 +03:00
|
|
|
|
|
|
|
cli = make_cli(data, "-smp 4,cores=4 "
|
2020-02-19 19:09:53 +03:00
|
|
|
"-numa node,nodeid=0,memdev=ram -numa node,nodeid=1 "
|
2017-05-10 14:30:02 +03:00
|
|
|
"-numa cpu,node-id=0,core-id=0 "
|
|
|
|
"-numa cpu,node-id=0,core-id=1 "
|
|
|
|
"-numa cpu,node-id=0,core-id=2 "
|
|
|
|
"-numa cpu,node-id=1,core-id=3");
|
2019-05-15 20:43:25 +03:00
|
|
|
qts = qtest_init(cli);
|
|
|
|
cpus = get_cpus(qts, &resp);
|
2017-05-10 14:30:02 +03:00
|
|
|
g_assert(cpus);
|
|
|
|
|
|
|
|
while ((e = qlist_pop(cpus))) {
|
|
|
|
QDict *cpu, *props;
|
|
|
|
int64_t core, node;
|
|
|
|
|
2018-02-24 18:40:29 +03:00
|
|
|
cpu = qobject_to(QDict, e);
|
2017-05-10 14:30:02 +03:00
|
|
|
g_assert(qdict_haskey(cpu, "props"));
|
|
|
|
props = qdict_get_qdict(cpu, "props");
|
|
|
|
|
|
|
|
g_assert(qdict_haskey(props, "node-id"));
|
|
|
|
node = qdict_get_int(props, "node-id");
|
|
|
|
g_assert(qdict_haskey(props, "core-id"));
|
|
|
|
core = qdict_get_int(props, "core-id");
|
|
|
|
|
|
|
|
if (core >= 0 && core < 3) {
|
|
|
|
g_assert_cmpint(node, ==, 0);
|
|
|
|
} else if (core == 3) {
|
|
|
|
g_assert_cmpint(node, ==, 1);
|
|
|
|
} else {
|
|
|
|
g_assert(false);
|
|
|
|
}
|
2018-04-19 18:01:43 +03:00
|
|
|
qobject_unref(e);
|
2017-05-10 14:30:02 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 18:01:43 +03:00
|
|
|
qobject_unref(resp);
|
2019-05-15 20:43:25 +03:00
|
|
|
qtest_quit(qts);
|
2017-05-10 14:30:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void aarch64_numa_cpu(const void *data)
|
|
|
|
{
|
|
|
|
QDict *resp;
|
|
|
|
QList *cpus;
|
2017-05-26 14:04:55 +03:00
|
|
|
QObject *e;
|
2019-05-15 20:43:25 +03:00
|
|
|
QTestState *qts;
|
2020-02-19 19:09:52 +03:00
|
|
|
g_autofree char *cli = NULL;
|
2017-05-10 14:30:02 +03:00
|
|
|
|
|
|
|
cli = make_cli(data, "-smp 2 "
|
2020-02-19 19:09:53 +03:00
|
|
|
"-numa node,nodeid=0,memdev=ram -numa node,nodeid=1 "
|
2017-05-10 14:30:02 +03:00
|
|
|
"-numa cpu,node-id=1,thread-id=0 "
|
|
|
|
"-numa cpu,node-id=0,thread-id=1");
|
2019-05-15 20:43:25 +03:00
|
|
|
qts = qtest_init(cli);
|
|
|
|
cpus = get_cpus(qts, &resp);
|
2017-05-10 14:30:02 +03:00
|
|
|
g_assert(cpus);
|
|
|
|
|
|
|
|
while ((e = qlist_pop(cpus))) {
|
|
|
|
QDict *cpu, *props;
|
|
|
|
int64_t thread, node;
|
|
|
|
|
2018-02-24 18:40:29 +03:00
|
|
|
cpu = qobject_to(QDict, e);
|
2017-05-10 14:30:02 +03:00
|
|
|
g_assert(qdict_haskey(cpu, "props"));
|
|
|
|
props = qdict_get_qdict(cpu, "props");
|
|
|
|
|
|
|
|
g_assert(qdict_haskey(props, "node-id"));
|
|
|
|
node = qdict_get_int(props, "node-id");
|
|
|
|
g_assert(qdict_haskey(props, "thread-id"));
|
|
|
|
thread = qdict_get_int(props, "thread-id");
|
|
|
|
|
|
|
|
if (thread == 0) {
|
|
|
|
g_assert_cmpint(node, ==, 1);
|
|
|
|
} else if (thread == 1) {
|
|
|
|
g_assert_cmpint(node, ==, 0);
|
|
|
|
} else {
|
|
|
|
g_assert(false);
|
|
|
|
}
|
2018-04-19 18:01:43 +03:00
|
|
|
qobject_unref(e);
|
2017-05-10 14:30:02 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 18:01:43 +03:00
|
|
|
qobject_unref(resp);
|
2019-05-15 20:43:25 +03:00
|
|
|
qtest_quit(qts);
|
2017-05-10 14:30:02 +03:00
|
|
|
}
|
|
|
|
|
2018-05-17 14:30:07 +03:00
|
|
|
static void pc_dynamic_cpu_cfg(const void *data)
|
|
|
|
{
|
|
|
|
QObject *e;
|
|
|
|
QDict *resp;
|
|
|
|
QList *cpus;
|
|
|
|
QTestState *qs;
|
2020-02-19 19:09:52 +03:00
|
|
|
g_autofree char *cli = NULL;
|
2018-05-17 14:30:07 +03:00
|
|
|
|
2020-02-19 19:09:52 +03:00
|
|
|
cli = make_cli(data, "-nodefaults --preconfig -smp 2");
|
|
|
|
qs = qtest_init(cli);
|
2018-05-17 14:30:07 +03:00
|
|
|
|
|
|
|
/* create 2 numa nodes */
|
|
|
|
g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
2020-02-19 19:09:53 +03:00
|
|
|
" 'arguments': { 'type': 'node', 'nodeid': 0, 'memdev': 'ram' } }")));
|
2018-05-17 14:30:07 +03:00
|
|
|
g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'node', 'nodeid': 1 } }")));
|
|
|
|
|
|
|
|
/* map 2 cpus in non default reverse order
|
|
|
|
* i.e socket1->node0, socket0->node1
|
|
|
|
*/
|
|
|
|
g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'cpu', 'node-id': 0, 'socket-id': 1 } }")));
|
|
|
|
g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'cpu', 'node-id': 1, 'socket-id': 0 } }")));
|
|
|
|
|
|
|
|
/* let machine initialization to complete and run */
|
2018-07-05 12:14:02 +03:00
|
|
|
g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'x-exit-preconfig' }")));
|
2018-05-17 14:30:07 +03:00
|
|
|
qtest_qmp_eventwait(qs, "RESUME");
|
|
|
|
|
|
|
|
/* check that CPUs are mapped as expected */
|
|
|
|
resp = qtest_qmp(qs, "{ 'execute': 'query-hotpluggable-cpus'}");
|
|
|
|
g_assert(qdict_haskey(resp, "return"));
|
|
|
|
cpus = qdict_get_qlist(resp, "return");
|
|
|
|
g_assert(cpus);
|
|
|
|
while ((e = qlist_pop(cpus))) {
|
|
|
|
const QDict *cpu, *props;
|
|
|
|
int64_t socket, node;
|
|
|
|
|
|
|
|
cpu = qobject_to(QDict, e);
|
|
|
|
g_assert(qdict_haskey(cpu, "props"));
|
|
|
|
props = qdict_get_qdict(cpu, "props");
|
|
|
|
|
|
|
|
g_assert(qdict_haskey(props, "node-id"));
|
|
|
|
node = qdict_get_int(props, "node-id");
|
|
|
|
g_assert(qdict_haskey(props, "socket-id"));
|
|
|
|
socket = qdict_get_int(props, "socket-id");
|
|
|
|
|
|
|
|
if (socket == 0) {
|
|
|
|
g_assert_cmpint(node, ==, 1);
|
|
|
|
} else if (socket == 1) {
|
|
|
|
g_assert_cmpint(node, ==, 0);
|
|
|
|
} else {
|
|
|
|
g_assert(false);
|
|
|
|
}
|
|
|
|
qobject_unref(e);
|
|
|
|
}
|
|
|
|
qobject_unref(resp);
|
|
|
|
|
|
|
|
qtest_quit(qs);
|
|
|
|
}
|
|
|
|
|
2019-12-13 04:19:28 +03:00
|
|
|
static void pc_hmat_build_cfg(const void *data)
|
|
|
|
{
|
2020-02-19 19:09:52 +03:00
|
|
|
QTestState *qs;
|
|
|
|
g_autofree char *cli = NULL;
|
|
|
|
|
|
|
|
cli = make_cli(data, "-nodefaults --preconfig -machine hmat=on "
|
|
|
|
"-smp 2,sockets=2 "
|
|
|
|
"-m 128M,slots=2,maxmem=1G "
|
|
|
|
"-object memory-backend-ram,size=64M,id=m0 "
|
|
|
|
"-object memory-backend-ram,size=64M,id=m1 "
|
|
|
|
"-numa node,nodeid=0,memdev=m0 "
|
|
|
|
"-numa node,nodeid=1,memdev=m1,initiator=0 "
|
|
|
|
"-numa cpu,node-id=0,socket-id=0 "
|
|
|
|
"-numa cpu,node-id=0,socket-id=1");
|
|
|
|
qs = qtest_init(cli);
|
2019-12-13 04:19:28 +03:00
|
|
|
|
|
|
|
/* Fail: Initiator should be less than the number of nodes */
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-lb', 'initiator': 2, 'target': 0,"
|
|
|
|
" 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }")));
|
|
|
|
|
|
|
|
/* Fail: Target should be less than the number of nodes */
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 2,"
|
|
|
|
" 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }")));
|
|
|
|
|
|
|
|
/* Fail: Initiator should contain cpu */
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-lb', 'initiator': 1, 'target': 0,"
|
|
|
|
" 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }")));
|
|
|
|
|
|
|
|
/* Fail: Data-type mismatch */
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
|
|
|
|
" 'hierarchy': \"memory\", 'data-type': \"write-latency\","
|
|
|
|
" 'bandwidth': 524288000 } }")));
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
|
|
|
|
" 'hierarchy': \"memory\", 'data-type': \"read-bandwidth\","
|
|
|
|
" 'latency': 5 } }")));
|
|
|
|
|
|
|
|
/* Fail: Bandwidth should be 1MB (1048576) aligned */
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
|
|
|
|
" 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\","
|
|
|
|
" 'bandwidth': 1048575 } }")));
|
|
|
|
|
|
|
|
/* Configuring HMAT bandwidth and latency details */
|
|
|
|
g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
|
|
|
|
" 'hierarchy': \"memory\", 'data-type': \"access-latency\","
|
|
|
|
" 'latency': 1 } }"))); /* 1 ns */
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
|
|
|
|
" 'hierarchy': \"memory\", 'data-type': \"access-latency\","
|
|
|
|
" 'latency': 5 } }"))); /* Fail: Duplicate configuration */
|
|
|
|
g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
|
|
|
|
" 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\","
|
|
|
|
" 'bandwidth': 68717379584 } }"))); /* 65534 MB/s */
|
|
|
|
g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1,"
|
|
|
|
" 'hierarchy': \"memory\", 'data-type': \"access-latency\","
|
|
|
|
" 'latency': 65534 } }"))); /* 65534 ns */
|
|
|
|
g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1,"
|
|
|
|
" 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\","
|
|
|
|
" 'bandwidth': 34358689792 } }"))); /* 32767 MB/s */
|
|
|
|
|
|
|
|
/* Fail: node_id should be less than the number of nodes */
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-cache', 'node-id': 2, 'size': 10240,"
|
|
|
|
" 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\","
|
|
|
|
" 'line': 8 } }")));
|
|
|
|
|
|
|
|
/* Fail: level should be less than HMAT_LB_LEVELS (4) */
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
|
|
|
|
" 'level': 4, 'associativity': \"direct\", 'policy': \"write-back\","
|
|
|
|
" 'line': 8 } }")));
|
|
|
|
|
|
|
|
/* Fail: associativity option should be 'none', if level is 0 */
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
|
|
|
|
" 'level': 0, 'associativity': \"direct\", 'policy': \"none\","
|
|
|
|
" 'line': 0 } }")));
|
|
|
|
/* Fail: policy option should be 'none', if level is 0 */
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
|
|
|
|
" 'level': 0, 'associativity': \"none\", 'policy': \"write-back\","
|
|
|
|
" 'line': 0 } }")));
|
|
|
|
/* Fail: line option should be 0, if level is 0 */
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
|
|
|
|
" 'level': 0, 'associativity': \"none\", 'policy': \"none\","
|
|
|
|
" 'line': 8 } }")));
|
|
|
|
|
|
|
|
/* Configuring HMAT memory side cache attributes */
|
|
|
|
g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
|
|
|
|
" 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\","
|
|
|
|
" 'line': 8 } }")));
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
|
|
|
|
" 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\","
|
|
|
|
" 'line': 8 } }"))); /* Fail: Duplicate configuration */
|
|
|
|
/* Fail: The size of level 2 size should be small than level 1 */
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
|
|
|
|
" 'level': 2, 'associativity': \"direct\", 'policy': \"write-back\","
|
|
|
|
" 'line': 8 } }")));
|
|
|
|
/* Fail: The size of level 0 size should be larger than level 1 */
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
|
|
|
|
" 'level': 0, 'associativity': \"direct\", 'policy': \"write-back\","
|
|
|
|
" 'line': 8 } }")));
|
|
|
|
g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-cache', 'node-id': 1, 'size': 10240,"
|
|
|
|
" 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\","
|
|
|
|
" 'line': 8 } }")));
|
|
|
|
|
|
|
|
/* let machine initialization to complete and run */
|
|
|
|
g_assert_false(qmp_rsp_is_err(qtest_qmp(qs,
|
|
|
|
"{ 'execute': 'x-exit-preconfig' }")));
|
|
|
|
qtest_qmp_eventwait(qs, "RESUME");
|
|
|
|
|
|
|
|
qtest_quit(qs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pc_hmat_off_cfg(const void *data)
|
|
|
|
{
|
2020-02-19 19:09:52 +03:00
|
|
|
QTestState *qs;
|
|
|
|
g_autofree char *cli = NULL;
|
|
|
|
|
|
|
|
cli = make_cli(data, "-nodefaults --preconfig "
|
|
|
|
"-smp 2,sockets=2 "
|
|
|
|
"-m 128M,slots=2,maxmem=1G "
|
2020-03-25 12:44:23 +03:00
|
|
|
"-object memory-backend-ram,size=64M,id=m0,prealloc=y "
|
2020-02-19 19:09:52 +03:00
|
|
|
"-object memory-backend-ram,size=64M,id=m1 "
|
|
|
|
"-numa node,nodeid=0,memdev=m0");
|
|
|
|
qs = qtest_init(cli);
|
2019-12-13 04:19:28 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Fail: Enable HMAT with -machine hmat=on
|
|
|
|
* before using any of hmat specific options
|
|
|
|
*/
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'node', 'nodeid': 1, 'memdev': \"m1\","
|
|
|
|
" 'initiator': 0 } }")));
|
|
|
|
g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'node', 'nodeid': 1, 'memdev': \"m1\" } }")));
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
|
|
|
|
" 'hierarchy': \"memory\", 'data-type': \"access-latency\","
|
|
|
|
" 'latency': 1 } }")));
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
|
|
|
|
" 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\","
|
|
|
|
" 'line': 8 } }")));
|
|
|
|
|
|
|
|
/* let machine initialization to complete and run */
|
|
|
|
g_assert_false(qmp_rsp_is_err(qtest_qmp(qs,
|
|
|
|
"{ 'execute': 'x-exit-preconfig' }")));
|
|
|
|
qtest_qmp_eventwait(qs, "RESUME");
|
|
|
|
|
|
|
|
qtest_quit(qs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pc_hmat_erange_cfg(const void *data)
|
|
|
|
{
|
2020-02-19 19:09:52 +03:00
|
|
|
QTestState *qs;
|
|
|
|
g_autofree char *cli = NULL;
|
|
|
|
|
|
|
|
cli = make_cli(data, "-nodefaults --preconfig -machine hmat=on "
|
|
|
|
"-smp 2,sockets=2 "
|
|
|
|
"-m 128M,slots=2,maxmem=1G "
|
|
|
|
"-object memory-backend-ram,size=64M,id=m0 "
|
|
|
|
"-object memory-backend-ram,size=64M,id=m1 "
|
|
|
|
"-numa node,nodeid=0,memdev=m0 "
|
|
|
|
"-numa node,nodeid=1,memdev=m1,initiator=0 "
|
|
|
|
"-numa cpu,node-id=0,socket-id=0 "
|
|
|
|
"-numa cpu,node-id=0,socket-id=1");
|
|
|
|
qs = qtest_init(cli);
|
2019-12-13 04:19:28 +03:00
|
|
|
|
|
|
|
/* Can't store the compressed latency */
|
|
|
|
g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
|
|
|
|
" 'hierarchy': \"memory\", 'data-type': \"access-latency\","
|
|
|
|
" 'latency': 1 } }"))); /* 1 ns */
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1,"
|
|
|
|
" 'hierarchy': \"memory\", 'data-type': \"access-latency\","
|
|
|
|
" 'latency': 65535 } }"))); /* 65535 ns */
|
|
|
|
|
|
|
|
/* Test the 0 input (bandwidth not provided) */
|
|
|
|
g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
|
|
|
|
" 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\","
|
|
|
|
" 'bandwidth': 0 } }"))); /* 0 MB/s */
|
|
|
|
/* Fail: bandwidth should be provided before memory side cache attributes */
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
|
|
|
|
" 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\","
|
|
|
|
" 'line': 8 } }")));
|
|
|
|
|
|
|
|
/* Can't store the compressed bandwidth */
|
|
|
|
g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
|
|
|
|
" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1,"
|
|
|
|
" 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\","
|
|
|
|
" 'bandwidth': 68718428160 } }"))); /* 65535 MB/s */
|
|
|
|
|
|
|
|
/* let machine initialization to complete and run */
|
|
|
|
g_assert_false(qmp_rsp_is_err(qtest_qmp(qs,
|
|
|
|
"{ 'execute': 'x-exit-preconfig' }")));
|
|
|
|
qtest_qmp_eventwait(qs, "RESUME");
|
|
|
|
|
|
|
|
qtest_quit(qs);
|
|
|
|
}
|
|
|
|
|
2017-05-03 15:56:55 +03:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2020-02-19 19:09:52 +03:00
|
|
|
g_autoptr(GString) args = g_string_new(NULL);
|
2017-05-03 15:56:55 +03:00
|
|
|
const char *arch = qtest_get_arch();
|
|
|
|
|
2020-02-19 19:09:53 +03:00
|
|
|
if (g_str_equal(arch, "ppc64")) {
|
|
|
|
g_string_append(args, " -object memory-backend-ram,id=ram,size=512M");
|
|
|
|
} else {
|
|
|
|
g_string_append(args, " -object memory-backend-ram,id=ram,size=128M");
|
|
|
|
}
|
|
|
|
|
2020-02-19 19:09:52 +03:00
|
|
|
if (g_str_equal(arch, "aarch64")) {
|
|
|
|
g_string_append(args, " -machine virt");
|
2017-05-03 15:56:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
g_test_init(&argc, &argv, NULL);
|
|
|
|
|
2020-02-19 19:09:53 +03:00
|
|
|
qtest_add_data_func("/numa/mon/cpus/default", args, test_def_cpu_split);
|
2017-05-03 15:56:55 +03:00
|
|
|
qtest_add_data_func("/numa/mon/cpus/explicit", args, test_mon_explicit);
|
|
|
|
qtest_add_data_func("/numa/mon/cpus/partial", args, test_mon_partial);
|
2017-05-10 14:29:56 +03:00
|
|
|
qtest_add_data_func("/numa/qmp/cpus/query-cpus", args, test_query_cpus);
|
2017-05-03 15:56:55 +03:00
|
|
|
|
2017-05-10 14:30:02 +03:00
|
|
|
if (!strcmp(arch, "i386") || !strcmp(arch, "x86_64")) {
|
|
|
|
qtest_add_data_func("/numa/pc/cpu/explicit", args, pc_numa_cpu);
|
2018-05-17 14:30:07 +03:00
|
|
|
qtest_add_data_func("/numa/pc/dynamic/cpu", args, pc_dynamic_cpu_cfg);
|
2019-12-13 04:19:28 +03:00
|
|
|
qtest_add_data_func("/numa/pc/hmat/build", args, pc_hmat_build_cfg);
|
|
|
|
qtest_add_data_func("/numa/pc/hmat/off", args, pc_hmat_off_cfg);
|
|
|
|
qtest_add_data_func("/numa/pc/hmat/erange", args, pc_hmat_erange_cfg);
|
2017-05-10 14:30:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(arch, "ppc64")) {
|
|
|
|
qtest_add_data_func("/numa/spapr/cpu/explicit", args, spapr_numa_cpu);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(arch, "aarch64")) {
|
|
|
|
qtest_add_data_func("/numa/aarch64/cpu/explicit", args,
|
|
|
|
aarch64_numa_cpu);
|
|
|
|
}
|
|
|
|
|
2017-05-03 15:56:55 +03:00
|
|
|
return g_test_run();
|
|
|
|
}
|