memcg/memcontrol05: add cgroup v2 task migration charge accounting test
PATCH v2 1/1 memcg/memcontrol05: add cgroup v2 task migration charge accounting test
Verify that in cgroup v2, memory charges remain pinned to the cgroup that allocated them when a task migrates, and that new allocations after migration are charged to the destination cgroup.
---
v1 -> v2:
- Replace MAP_POPULATE with explicit page-touching via touch_pages()
- Add .min_mem_avail = 80 (MB) to skip test under low memory
- Add blank line after declarations in test_memcg_task_migration()
- Use double backticks for identifiers and paths in RST block
- Document why .needs_root = 1 is required in test description
Link to v1: https://lore.kernel.org/ltp/[email protected]/
--- runtest/controllers | 1 + testcases/kernel/controllers/memcg/.gitignore | 1 + .../kernel/controllers/memcg/memcontrol05.c | 175 ++++++++++++++++++ 3 files changed, 177 insertions(+) create mode 100644 testcases/kernel/controllers/memcg/memcontrol05.c
runtest/controllers +1 -0
@@ -24,6 +24,7 @@ memcontrol01 memcontrol01 memcontrol02 memcontrol02 memcontrol03 memcontrol03 memcontrol04 memcontrol04 +memcontrol05 memcontrol05 cgroup_fj_function_debug cgroup_fj_function.sh debug cgroup_fj_function_cpuset cgroup_fj_function.sh cpuset
testcases/kernel/controllers/memcg/.gitignore +1 -0
@@ -9,3 +9,4 @@ memcontrol01 memcontrol02 memcontrol03 memcontrol04 +memcontrol05
testcases/kernel/controllers/memcg/memcontrol05.c new file +175 -0
175 lines not on this page · raw message
Signature · 5 lines
2.55.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Pavithra,
testcases/kernel/controllers/memcg/memcontrol05.c line 42
Quoted 5 lines · Pavithra
memcg/memcontrol05: add cgroup v2 task migration charge accounting test
testcases/kernel/controllers/memcg/memcontrol05.c new file +3
-0+#define ALLOC_SIZE MB(60) +#define ALLOC_SIZE2 MB(20) +#define MIN_MEM_AVAIL 80
[Medium] Could MIN_MEM_AVAIL include headroom above the two mappings? The worker keeps both mappings resident simultaneously, so a host with exactly 80 MiB available passes the framework check but still needs memory for page tables and other process and kernel allocations. The worker can be OOM-killed while touching the mappings, producing a timeout or TBROK instead of testing charge accounting.
testcases/kernel/controllers/memcg/memcontrol05.c line 132
Quoted 4 lines
testcases/kernel/controllers/memcg/memcontrol05.c new file +4
-0+SAFE_CG_SCANF (group_b,"memory.current" ,"%ld" , &after_migrate); +TST_EXP_EXPR (after_migrate <= baseline_b + (long )MB (4 ), +"group_b memory.current (%ld) not increased after migration (baseline=%ld)" , + after_migrate, baseline_b);
[Medium] Could this also read and verify group_a/memory.current after the migration? The stated invariant is that existing charges remain pinned to group_a, but this checks only that group_b did not gain them. A regression that drops those charges during migration leaves group_b within the allowed range and reports TPASS despite violating the invariant.
Verdict - Needs revision
---
Note:
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp