[LTP] [PATCH v9 0/1] cpuset_memory_spread: rewrite as a C test using the LTP cgroup library
Changwei Zou
changwei.zou@canonical.com
Thu Nov 5 01:55:04 CET 2026
The cpuset_memory_spread test (from 2009) was split between a shell script
that mounted /dev/cpuset by hand and a C helper (cpuset_mem_hog) driven over
a FIFO and SIGUSR1/SIGUSR2. It checked the cpuset.memory_spread_page policy
by comparing the global per-node FilePages counters in
/sys/devices/system/node/nodeX/meminfo, which also account for unrelated
page-cache activity, so on large or busy NUMA machines the empirical
thresholds became unreliable and the test failed spuriously.
This series rewrites it as a single C test on the new LTP test API, the LTP
cgroup library (tst_cgroup.h) and the NUMA helpers from tse_numa.h, dropping
the shell script, the FIFO/signal handshake and the manual /dev/cpuset
management.
For each case the test pins itself to the local node, sets cpuset.mems and
cpuset.memory_spread_page, faults a file-backed shared mapping and uses
tse_nodemap_count_pages() (get_mempolicy(2)) to learn the NUMA node of each
of the mapping's pages. Only the test mapping's own pages are counted, so
unrelated page-cache activity can no longer perturb the result.
cpuset.memory_spread_page only exists in the cgroup v1 cpuset controller, so
the test requires a v1 cpuset hierarchy (.needs_cgroup_ver = TST_CG_V1) and
is skipped (TCONF) on a unified (v2) hierarchy. The patch also registers
cpuset.memory_spread_page in the LTP cgroup library's cpuset file table so
it can be driven through the SAFE_CG_* helpers.
Tested on a 2-node NUMA machine with a v1 cpuset hierarchy: all six subtests
pass.
Changes in v9 (addresses Cyril's v8 review):
- Use tse_numa.h instead of the deprecated numa_helper.h: node discovery
and per-node free-memory filtering via tse_get_nodemap(), and page
accounting via tse_numa_map()/tse_numa_fault()/tse_nodemap_count_pages().
This also drops the move_pages(2) syscall (counting now uses
get_mempolicy(2)) and the write_node_cpusets() dependency; the task is
pinned to the local node with numa_run_on_node().
- struct tcase: use const char *mems / const char *expect instead of
int[2] arrays with a -1 sentinel.
- Move the tmpfs/ramfs explanation out of the struct into the top-level
test doc comment.
- Makefile: link libltpnuma (LTPLIBS = numa) instead of pulling in the
kernel test lib.
v8:
https://lore.kernel.org/ltp/20261104071908.128726-1-changwei.zou@canonical.com/
v7:
https://lore.kernel.org/ltp/20261104002400.56841-1-changwei.zou@canonical.com/
Changwei Zou (1):
cpuset_memory_spread: rewrite as a C test using the LTP cgroup library
lib/tst_cgroup.c | 1 +
runtest/controllers | 2 +-
.../kernel/controllers/cpuset/.gitignore | 2 +-
.../cpuset/cpuset_memory_spread_test/Makefile | 7 +-
.../cpuset_mem_hog.c | 126 ------
.../cpuset_memory_spread01.c | 214 +++++++++++
.../cpuset_memory_spread_testset.sh | 362 ------------------
7 files changed, 223 insertions(+), 491 deletions(-)
delete mode 100644 testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_mem_hog.c
create mode 100644 testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread01.c
delete mode 100755 testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread_testset.sh
--
2.43.0
More information about the ltp
mailing list