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

Changwei Zou changwei.zou@canonical.com
Wed Nov 4 08:19:07 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 v8 (addresses the v7 review):
  - Doc comment: use :manpage:`move_pages(2)` instead of ``move_pages()``.
  - Drop the local node_cpus() helper; bind the task's CPUs with the
    existing write_node_cpusets() from numa_helper.h.
  - Read DATAFILE with SAFE_READ() instead of a raw read() loop.
  - Replace the repeated do_spread_test() calls in .test_all with a
    struct tcase array driven via .test + .tcnt. CPUs now stay on the
    local node for every case and only cpuset.mems varies, restoring the
    original non-local memory-node allocation check (cases 3 and 4).
  - Check tst_fill_file()'s return value and TBROK on failure.
  - Pass a literal string to TST_TEST_TCONF() without leading indentation.

v7:
https://lore.kernel.org/ltp/20261104002400.56841-1-changwei.zou@canonical.com/

v6:
https://lore.kernel.org/ltp/20260905125041.27985-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 |   2 +-
 .../cpuset_mem_hog.c                          | 126 ------
 .../cpuset_memory_spread01.c                  | 355 +++++++++++++++++
 .../cpuset_memory_spread_testset.sh           | 362 ------------------
 7 files changed, 359 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