[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <d1f86fdb7b1eb4cc4daef09e35fc8a1795657f89.1643206612.git.karolinadrobnik@gmail.com>
Date: Thu, 27 Jan 2022 14:21:33 +0100
From: Karolina Drobnik <karolinadrobnik@...il.com>
To: linux-mm@...ck.org
Cc: akpm@...ux-foundation.org, mike.rapoport@...il.com,
linux-kernel@...r.kernel.org,
Karolina Drobnik <karolinadrobnik@...il.com>
Subject: [PATCH 15/16] memblock tests: Add memblock_add_node test
Add a simple test for NUMA-aware variant of memblock_add function.
Signed-off-by: Karolina Drobnik <karolinadrobnik@...il.com>
---
tools/testing/memblock/tests/basic_api.c | 34 ++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/tools/testing/memblock/tests/basic_api.c b/tools/testing/memblock/tests/basic_api.c
index 96af80bf9df9..02eb88358a58 100644
--- a/tools/testing/memblock/tests/basic_api.c
+++ b/tools/testing/memblock/tests/basic_api.c
@@ -55,6 +55,39 @@ static int memblock_add_simple_check(void)
return 0;
}
+/*
+ * A simple test that adds a memory block of a specified base address, size
+ * NUMA node and memory flags to the collection of available memory regions.
+ * It checks if the new entry, region counter and total memory size have
+ * expected values.
+ */
+static int memblock_add_node_simple_check(void)
+{
+ struct memblock_region *rgn;
+
+ rgn = &memblock.memory.regions[0];
+
+ struct region r = {
+ .base = SZ_1M,
+ .size = SZ_16M
+ };
+
+ reset_memblock();
+ memblock_add_node(r.base, r.size, 1, MEMBLOCK_HOTPLUG);
+
+ assert(rgn->base == r.base);
+ assert(rgn->size == r.size);
+#ifdef CONFIG_NUMA
+ assert(rgn->nid == 1);
+#endif
+ assert(rgn->flags == MEMBLOCK_HOTPLUG);
+
+ assert(memblock.memory.cnt == 1);
+ assert(memblock.memory.total_size == r.size);
+
+ return 0;
+}
+
/*
* A test that tries to add two memory blocks that don't overlap with one another.
* It checks if two correctly initialized entries were added to the collection
@@ -230,6 +263,7 @@ static int memblock_add_twice_check(void)
static int memblock_add_checks(void)
{
memblock_add_simple_check();
+ memblock_add_node_simple_check();
memblock_add_disjoint_check();
memblock_add_overlap_top_check();
memblock_add_overlap_bottom_check();
--
2.30.2
Powered by blists - more mailing lists