[LTP] [PATCH v3 0/3] Add CPU cgroup v2 tests ported from kselftest
Shaojie Sun <[email protected]> Fri, 31 Jul 2026 11:13:40 +0800
| Newsgroups | it.linux.lists.ltp |
|---|---|
| Message-ID | <[email protected]> |
--===============1999574326== Content-Type: text/plain; charset=y Content-Transfer-Encoding: 8bit This series ports the CPU cgroup v2 tests from the kernel selftests (tools/testing/selftests/cgroup/test_cpu.c) to LTP, including tests for subtree control, cpu.stat, nice, weight, and cpu.max. The LTP tree already contains kselftest conversions for memcg (memcontrol01-04), ported by Richard Palethorpe. This series follows the same pattern to complete the CPU cgroup coverage. Regarding the concern about kselftest conversion: the CPU cgroup interfaces tested here (cpu.stat, cpu.weight, cpu.max) are stable kernel ABIs that change very rarely. LTP's cgroup infrastructure provides advantages over the raw kselftest helpers — automatic v1/v2 detection, safe file operations with proper error handling, automatic cleanup, and integration with the LTP test result framework. Bringing these tests into LTP also gives them broader CI coverage, as many distributions run LTP but not kselftest. Richard Palethorpe is listed in the copyright because the test structure and common helper (cgroup_cpu_common.h) are modeled after his memcontrol kselftest conversions (memcontrol01-04). The CPU cgroup tests themselves were written by the patch author. Patch 1 adds the necessary cgroup file entries (cpu.stat, cpu.weight) to the LTP cgroup library. Patch 2 adds the test source files and build infrastructure. Patch 3 registers the new tests in runtest/controllers. v3: - Removed unnecessary braces around single-statement if blocks in cleanup() functions in cgroup_cpu02.c and cgroup_cpu03.c - Added blank lines after declarations in test functions in cgroup_cpu02.c and cgroup_cpu03.c v2: - Changed hog_cpus_timed() to use tst_brk() instead of returning -1 - Removed unused status variables, use NULL for SAFE_WAITPID - Added copyright lines for the author in new files - Fixed doc block formatting: use :kselftest: references and blank lines before bullet lists for reST rendering - Removed redundant .needs_cgroup_nsdelegate = 0 initializers - Removed unused USEC_PER_SEC from cgroup_cpu04.c - Removed unnecessary drain writes in cleanup paths - Replaced literal .tcnt values with ARRAY_SIZE(test_list) and function pointer tables - Removed .timeout = 30 default value from cgroup_cpu05.c - Added errno = 0 before nice() call in cgroup_cpu03.c - Added .needs_kconfigs check for CONFIG_CFS_BANDWIDTH=y in cgroup_cpu05.c - Added .needs_root = 1 to cgroup_cpu02.c for consistency - Changed doc comment from /*\ to /* in cgroup_cpu_common.h since it is a helper header, not a test Shaojie Sun (3): tst_cgroup: add cpu.stat and cpu.weight to cgroup file table cgroup: add CPU cgroup v2 tests ported from kselftest runtest/controllers: add CPU cgroup v2 test entries lib/tst_cgroup.c | 2 + runtest/controllers | 5 + testcases/kernel/controllers/cpu/.gitignore | 5 + testcases/kernel/controllers/cpu/Makefile | 9 + .../kernel/controllers/cpu/cgroup_cpu01.c | 64 ++++ .../kernel/controllers/cpu/cgroup_cpu02.c | 103 ++++++ .../kernel/controllers/cpu/cgroup_cpu03.c | 115 ++++++ .../kernel/controllers/cpu/cgroup_cpu04.c | 332 ++++++++++++++++++ .../kernel/controllers/cpu/cgroup_cpu05.c | 176 ++++++++++ .../controllers/cpu/cgroup_cpu_common.h | 131 +++++++ 10 files changed, 942 insertions(+) create mode 100644 testcases/kernel/controllers/cpu/.gitignore create mode 100644 testcases/kernel/controllers/cpu/Makefile create mode 100644 testcases/kernel/controllers/cpu/cgroup_cpu01.c create mode 100644 testcases/kernel/controllers/cpu/cgroup_cpu02.c create mode 100644 testcases/kernel/controllers/cpu/cgroup_cpu03.c create mode 100644 testcases/kernel/controllers/cpu/cgroup_cpu04.c create mode 100644 testcases/kernel/controllers/cpu/cgroup_cpu05.c create mode 100644 testcases/kernel/controllers/cpu/cgroup_cpu_common.h --===============1999574326== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- Mailing list info: https://lists.linux.it/listinfo/ltp --===============1999574326==--