[LTP] [RFC][PATCH 0/2] Add safe_get_nodemap()

Petr Vorel pvorel@suse.cz
Fri Mar 28 12:43:09 CET 2025


Hi,

not a huge improvement, but because all tst_get_nodemap() are in the
setup (and only ksm06.c allows input parameter) we could have struct
tst_test member which would call safe_get_nodemap().

e.g.:

.nodemap = (const struct tst_path_val) {
		.type = TST_NUMA_MEM
		.required = 2,
},

safe_get_nodemap(tst_test->nodemap->type,
	tst_test->nodemap->required * getpagesize() / 1024);

This would not work for non - page sized nodes, e.g.:
nodes = tst_get_nodemap(TST_NUMA_MEM, 2 * PAGES_ALLOCATED * page_size / 1024);

=> extra member would need to be added:

.nodemap = (const struct tst_path_val) {
		.type = TST_NUMA_MEM
		.required = 2,
		.size = PAGES_ALLOCATED, // default == 1
},

would call:

safe_get_nodemap(tst_test->nodemap->type,
	tst_test->nodemap->required * tst_test->nodemap->size * getpagesize() / 1024,
	tst_test->nodemap->required);

Petr Vorel (2):
  libs: Add safe_get_nodemap()
  Use safe_get_nodemap()

 include/tst_numa.h                            | 41 ++++++++++++++++++-
 libs/numa/tst_numa.c                          | 14 +++++++
 testcases/kernel/mem/ksm/ksm06.c              |  4 +-
 .../syscalls/get_mempolicy/get_mempolicy01.c  |  4 +-
 .../syscalls/get_mempolicy/get_mempolicy02.c  |  4 +-
 testcases/kernel/syscalls/mbind/mbind02.c     |  4 +-
 testcases/kernel/syscalls/mbind/mbind03.c     |  4 +-
 testcases/kernel/syscalls/mbind/mbind04.c     |  4 +-
 .../syscalls/set_mempolicy/set_mempolicy01.c  |  4 +-
 .../syscalls/set_mempolicy/set_mempolicy02.c  |  4 +-
 .../syscalls/set_mempolicy/set_mempolicy03.c  |  4 +-
 .../syscalls/set_mempolicy/set_mempolicy04.c  |  4 +-
 12 files changed, 63 insertions(+), 32 deletions(-)

-- 
2.49.0



More information about the ltp mailing list