[LTP] [PATCH 04/13] testcases/kernel/mem: Move get_a_numa_node()
Cyril Hrubis
chrubis@suse.cz
Wed Dec 18 19:45:09 CET 2024
Move get_a_numa_node() from the library to the ksm_common.h since the
function is used only by the ksm testcases.
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
testcases/kernel/mem/include/mem.h | 3 ---
testcases/kernel/mem/ksm/ksm_common.h | 35 +++++++++++++++++++++++++++
testcases/kernel/mem/lib/mem.c | 33 -------------------------
3 files changed, 35 insertions(+), 36 deletions(-)
diff --git a/testcases/kernel/mem/include/mem.h b/testcases/kernel/mem/include/mem.h
index 7251a8839..35a1f0834 100644
--- a/testcases/kernel/mem/include/mem.h
+++ b/testcases/kernel/mem/include/mem.h
@@ -68,9 +68,6 @@ void write_memcg(void);
/* cpuset/memcg - include/tst_cgroup.h */
void write_cpusets(const struct tst_cg_group *cg, long nd);
-/* shared */
-unsigned int get_a_numa_node(void);
-
void update_shm_size(size_t *shm_size);
#endif
diff --git a/testcases/kernel/mem/ksm/ksm_common.h b/testcases/kernel/mem/ksm/ksm_common.h
index 489d34ae0..43ea8f8c2 100644
--- a/testcases/kernel/mem/ksm/ksm_common.h
+++ b/testcases/kernel/mem/ksm/ksm_common.h
@@ -11,6 +11,7 @@
#define KSM_COMMON_H__
#include "tst_test.h"
+#include "numa_helper.h"
#define DEFAULT_MEMSIZE 128
@@ -33,4 +34,38 @@ static inline void parse_ksm_options(char *str_size, int *size,
tst_brk(TBROK, "the remainder of division of size by unit is not zero.");
}
+/* Warning: *DO NOT* use this function in child */
+static inline unsigned int get_a_numa_node(void)
+{
+ unsigned int nd1, nd2;
+ int ret;
+
+ ret = get_allowed_nodes(0, 2, &nd1, &nd2);
+ switch (ret) {
+ case 0:
+ break;
+ case -3:
+ tst_brk(TCONF, "requires a NUMA system.");
+ default:
+ tst_brk(TBROK | TERRNO, "1st get_allowed_nodes");
+ }
+
+ ret = get_allowed_nodes(NH_MEMS | NH_CPUS, 1, &nd1);
+ switch (ret) {
+ case 0:
+ tst_res(TINFO, "get node%u.", nd1);
+ return nd1;
+ case -3:
+ tst_brk(TCONF, "requires a NUMA system that has "
+ "at least one node with both memory and CPU "
+ "available.");
+ default:
+ tst_brk(TBROK | TERRNO, "2nd get_allowed_nodes");
+ }
+
+ /* not reached */
+ abort();
+}
+
+
#endif /* KSM_COMMON_H__ */
diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
index 16eb39cba..06271f5d3 100644
--- a/testcases/kernel/mem/lib/mem.c
+++ b/testcases/kernel/mem/lib/mem.c
@@ -593,39 +593,6 @@ void write_cpusets(const struct tst_cg_group *cg, long nd)
/* shared */
-/* Warning: *DO NOT* use this function in child */
-unsigned int get_a_numa_node(void)
-{
- unsigned int nd1, nd2;
- int ret;
-
- ret = get_allowed_nodes(0, 2, &nd1, &nd2);
- switch (ret) {
- case 0:
- break;
- case -3:
- tst_brk(TCONF, "requires a NUMA system.");
- default:
- tst_brk(TBROK | TERRNO, "1st get_allowed_nodes");
- }
-
- ret = get_allowed_nodes(NH_MEMS | NH_CPUS, 1, &nd1);
- switch (ret) {
- case 0:
- tst_res(TINFO, "get node%u.", nd1);
- return nd1;
- case -3:
- tst_brk(TCONF, "requires a NUMA system that has "
- "at least one node with both memory and CPU "
- "available.");
- default:
- tst_brk(TBROK | TERRNO, "2nd get_allowed_nodes");
- }
-
- /* not reached */
- abort();
-}
-
void update_shm_size(size_t * shm_size)
{
size_t shmmax;
--
2.45.2
More information about the ltp
mailing list