[LTP] [PATCH v7 0/1] cpuset_memory_spread: rewrite as a C test using the LTP cgroup library

Changwei Zou changwei.zou@canonical.com
Wed Nov 4 01:23:59 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 and the
LTP cgroup library (tst_cgroup.h), dropping the shell script, the
FIFO/signal handshake and the manual /dev/cpuset management. It now accounts
for only DATAFILE's own page-cache pages via move_pages(2) (NULL node array,
so nothing is migrated), 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 v7:
  - Rewritten from the shell+helper pair into a single C test using the
    LTP cgroup library (per maintainer feedback).

v6:
https://lore.kernel.org/ltp/20260905125041.27985-1-changwei.zou@canonical.com/T/#t

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 |   2 +-
 .../cpuset_mem_hog.c                          | 126 ------
 .../cpuset_memory_spread01.c                  | 394 ++++++++++++++++++
 .../cpuset_memory_spread_testset.sh           | 362 ----------------
 7 files changed, 398 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