[LTP] [PATCH v10 0/1] cpuset_memory_spread: rewrite as a C test using the LTP cgroup library
Changwei Zou
changwei.zou@canonical.com
Thu Nov 12 11:20:49 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 exists only in the cgroup v1 cpuset controller, so
the test checks for the control file in setup() and is skipped (TCONF) when
cpuset is mounted on the 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 v10 (addresses Petr's v9 review):
- Drop .needs_cgroup_ver = TST_CG_V1; the setup() SAFE_CG_HAS() check on
cpuset.memory_spread_page already skips (TCONF) on a v2 hierarchy.
- Restore TST_TEST_TCONF(NUMA_ERROR_MSG) (the v7 switch to a literal
string was wrong).
v9:
https://lore.kernel.org/ltp/20261105005506.76889-1-changwei.zou@canonical.com/
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 | 213 +++++++++++
.../cpuset_memory_spread_testset.sh | 362 ------------------
7 files changed, 222 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