mm: memcg kselftests fixes
Subsystems (4)
Roman Gushchin
maintainercover mm: memcg kselftests fixes
I'm resending two memcg kselftests fixes, which I first posted in 2019 [1], however they didn't go anywhere. I've rechecked them and they're are both still actual, even though there were new regressions introduced since that, so not all tests are passing now. I know that David Vernet (cc'ed) is working on fixing (some of) them, so hopefully he'll post more fixes soon.
I believe it's better for such patches to go through mm and cgroup trees (and mailing lists), where there are better chances for them to be properly reviewed, so adding corresponding entries to the MAINTAINERS file to make it obvious.
1: https://lore.kernel.org/lkml/[email protected]/T/
Roman Gushchin (4):
kselftests: memcg: update the oom group leaf events test
kselftests: memcg: speed up the memory.high test
MAINTAINERS: add corresponding kselftests to cgroup entry
MAINTAINERS: add corresponding kselftests to memcg entry
MAINTAINERS | 3 +++ tools/testing/selftests/cgroup/test_memcontrol.c | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-)
Signature · 1 line
2.35.1
Roman Gushchin
maintainerPATCH 1/4 kselftests: memcg: update the oom group leaf events test
Commit 9852ae3fe529 ("mm, memcg: consider subtrees in memory.events") made memory.events recursive: all events are propagated upwards by the tree. It was a change in semantics.
It broke the oom group leaf events test: it assumes that after an OOM the oom_kill counter is zero on parent's level.
Let's adjust the test: it should have similar expectations for the child and parent levels.
The test passes after this fix.
--- tools/testing/selftests/cgroup/test_memcontrol.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/cgroup/test_memcontrol.c +3 -2
@@ -1079,7 +1079,8 @@ static int test_memcg_sock(const char *root)/* * This test disables swapping and tries to allocate anonymous memory * up to OOM with memory.group.oom set. Then it checks that all -* processes in the leaf (but not the parent) were killed. +* processes in the leaf were killed. It also checks that oom_events +* were propagated to the parent level. */ static int test_memcg_oom_group_leaf_events (const char *root) {
@@ -1122,7 +1123,7 @@ static int test_memcg_oom_group_leaf_events(const char *root)if (cg_read_key_long (child,"memory.events" ,"oom_kill " ) <=0 ) goto cleanup; -if (cg_read_key_long (parent,"memory.events" ,"oom_kill " ) !=0 ) +if (cg_read_key_long (parent,"memory.events" ,"oom_kill " ) <=0 ) goto cleanup; ret =KSFT_PASS ;
Signature · 1 line
2.35.1
Re: [PATCH 1/4] kselftests: memcg: update the oom group leaf events test
Quoted 3 lines · Roman Gushchin
Commit
9852ae3fe529("mm, memcg: consider subtrees in memory.events") made memory.events recursive: all events are propagated upwards by the tree. It was a change in semantics.
In one of our offline discussions you mentioned that we may want to consider having the test take mount options into account. If we decide to go that route we should probably have this testcase take memory_localevents into account as well. If so, I'm happy to take care of that in a follow-on patch after this is merged as I already have a patch locally that reads and parses /proc/mounts to detect these mount options.
Quoted 42 lines
It broke the oom group leaf events test: it assumes that after an OOM the
oom_killcounter is zero on parent's level.Let's adjust the test: it should have similar expectations for the child and parent levels.
The test passes after this fix.
Signed-off-by Roman Gushchin <[email protected]>Cc Chris Down <[email protected]>Cc Johannes Weiner <[email protected]>--- tools/testing/selftests/cgroup/test_memcontrol.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)tools/testing/selftests/cgroup/test_memcontrol.c +3
-2@@ -1079,7 +1079,8 @@ static int test_memcg_sock(const char *root)/* * This test disables swapping and tries to allocate anonymous memory * up to OOM with memory.group.oom set. Then it checks that all -* processes in the leaf (but not the parent) were killed. +* processes in the leaf were killed. It also checks that oom_events +* were propagated to the parent level. */ static int test_memcg_oom_group_leaf_events (const char *root) {@@ -1122,7 +1123,7 @@ static int test_memcg_oom_group_leaf_events(const char *root)if (cg_read_key_long (child,"memory.events" ,"oom_kill " ) <=0 ) goto cleanup; -if (cg_read_key_long (parent,"memory.events" ,"oom_kill " ) !=0 ) +if (cg_read_key_long (parent,"memory.events" ,"oom_kill " ) <=0 ) goto cleanup; ret =KSFT_PASS ;Signature · 1 line
2.35.1
Looks good, thanks.
Roman Gushchin
maintainerRe: [PATCH 1/4] kselftests: memcg: update the oom group leaf events test
Quoted 8 lines · David Vernet
Quoted 3 lines · Roman Gushchin
Commit
9852ae3fe529("mm, memcg: consider subtrees in memory.events") made memory.events recursive: all events are propagated upwards by the tree. It was a change in semantics.
Quoted 6 lines
In one of our offline discussions you mentioned that we may want to consider having the test take mount options into account. If we decide to go that route we should probably have this testcase take
memory_localeventsinto account as well. If so, I'm happy to take care of that in a follow-on patch after this is merged as I already have a patch locally that reads and parses/proc/mountsto detect these mount options.
It would be great, thank you!
Quoted 4 lines
Quoted 4 lines
tools/testing/selftests/cgroup/test_memcontrol.c +1
-1-if (cg_read_key_long (parent,"memory.events" ,"oom_kill " ) !=0 ) +if (cg_read_key_long (parent,"memory.events" ,"oom_kill " ) <=0 ) goto cleanup;
Quoted 8 lines
Quoted 4 lines
ret = KSFT_PASS;Signature · 1 line
2.35.1Looks good, thanks.
Reviewed-by David Vernet <[email protected]>
Thanks!
Roman Gushchin
maintainerPATCH 2/4 kselftests: memcg: speed up the memory.high test
In reply to Roman GushchinAfter commit 0e4b01df8659 ("mm, memcg: throttle allocators when failing reclaim over memory.high") allocating memory over memory.high became very time consuming. But it's exactly what the memory.high test from cgroup kselftests is doing: it tries to allocate 100M with 30M memory.high value. It takes forever to complete.
In order to keep it passing (or failing) in a reasonable amount of time let's try to allocate only a little over 30M: 31M to be precise.
With this change test_memcontrol finishes in a reasonable amount of time:
$ time ./test_memcontrol ok 1 test_memcg_subtree_control ok 2 test_memcg_current ok 3 test_memcg_min ok 4 test_memcg_low ok 5 test_memcg_high ok 6 test_memcg_max ok 7 test_memcg_oom_events ok 8 test_memcg_swap_max ok 9 test_memcg_sock ok 10 test_memcg_oom_group_leaf_events ok 11 test_memcg_oom_group_parent_events ok 12 test_memcg_oom_group_score_events
real 0m2.273s
user 0m0.064s
sys 0m0.739s
--- tools/testing/selftests/cgroup/test_memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/cgroup/test_memcontrol.c +1 -1
@@ -607,7 +607,7 @@ static int test_memcg_high(const char *root)if (cg_write (memcg,"memory.high" ,"30M" )) goto cleanup; -if (cg_run (memcg, alloc_anon, (void *)MB (100 ))) +if (cg_run (memcg, alloc_anon, (void *)MB (31 ))) goto cleanup;if (!cg_run (memcg, alloc_pagecache_50M_check,NULL ))
Signature · 1 line
2.35.1
Re: [PATCH 2/4] kselftests: memcg: speed up the memory.high test
Quoted 52 lines · Roman Gushchin
After commit
0e4b01df8659("mm, memcg: throttle allocators when failing reclaim over memory.high") allocating memory over memory.high became very time consuming. But it's exactly what the memory.high test from cgroup kselftests is doing: it tries to allocate 100M with 30M memory.high value. It takes forever to complete.In order to keep it passing (or failing) in a reasonable amount of time let's try to allocate only a little over 30M: 31M to be precise.
With this change
test_memcontrolfinishes in a reasonable amount of time:$ time ./test_memcontrol ok 1 test_memcg_subtree_control ok 2 test_memcg_current ok 3 test_memcg_min ok 4 test_memcg_low ok 5 test_memcg_high ok 6 test_memcg_max ok 7 test_memcg_oom_events ok 8 test_memcg_swap_max ok 9 test_memcg_sock ok 10 test_memcg_oom_group_leaf_events ok 11 test_memcg_oom_group_parent_events ok 12 test_memcg_oom_group_score_eventsreal 0m2.273s
user 0m0.064s
sys 0m0.739sSigned-off-by Roman Gushchin <[email protected]>Cc Chris Down <[email protected]>Cc Johannes Weiner <[email protected]>--- tools/testing/selftests/cgroup/test_memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/cgroup/test_memcontrol.c +1
-1@@ -607,7 +607,7 @@ static int test_memcg_high(const char *root)if (cg_write (memcg,"memory.high" ,"30M" )) goto cleanup; -if (cg_run (memcg, alloc_anon, (void *)MB (100 ))) +if (cg_run (memcg, alloc_anon, (void *)MB (31 ))) goto cleanup;if (!cg_run (memcg, alloc_pagecache_50M_check,NULL ))Signature · 1 line
2.35.1
Thanks for re-sending this. Looks good.
Roman Gushchin
maintainerPATCH 3/4 MAINTAINERS: add corresponding kselftests to cgroup entry
In reply to Roman GushchinList cgroup kselftests in the cgroup MAINTAINERS entry. These are tests covering core, freezer and cgroup.kill functionality.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -4996,6 +4996,7 @@ F: Documentation/admin-guide/cgroup-v1/ F: Documentation/admin-guide/cgroup-v2.rst F: include/linux/cgroup* F: kernel/cgroup/ +F: tools/testing/selftests/cgroup/ CONTROL GROUP - BLOCK IO CONTROLLER (BLKIO) M: Tejun Heo <[email protected]>
Signature · 1 line
2.35.1
Re: [PATCH 3/4] MAINTAINERS: add corresponding kselftests to cgroup entry
Quoted 9 lines · Roman Gushchin
List cgroup kselftests in the cgroup
MAINTAINERSentry. These are tests covering core, freezer and cgroup.kill functionality.Signed-off-by Roman Gushchin <[email protected]>Cc Tejun Heo <[email protected]>Cc Zefan Li <[email protected]>Cc Johannes Weiner <[email protected]>
I suppose this can go with the rest through -mm? Please let me know if I should pick it up.
Thanks.
Signature · 1 line
tejun
Roman Gushchin
maintainerRe: [PATCH 3/4] MAINTAINERS: add corresponding kselftests to cgroup entry
Quoted 14 lines · Tejun Heo
Quoted 9 lines · Roman Gushchin
List cgroup kselftests in the cgroup
MAINTAINERSentry. These are tests covering core, freezer and cgroup.kill functionality.Signed-off-by Roman Gushchin <[email protected]>Cc Tejun Heo <[email protected]>Cc Zefan Li <[email protected]>Cc Johannes Weiner <[email protected]>
Quoted 3 lines
Acked-by Tejun Heo <[email protected]>I suppose this can go with the rest through -mm? Please let me know if I should pick it up.
Yep, Andrew picked it up already.
Thanks!
Roman Gushchin
maintainerPATCH 4/4 MAINTAINERS: add corresponding kselftests to memcg entry
In reply to Roman GushchinList memory control and kernel memory control kselftests in the memory resource controller entry.
--- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
@@ -5030,6 +5030,8 @@ L: [email protected] S: Maintained F: mm/memcontrol.c F: mm/swap_cgroup.c +F: tools/testing/selftests/cgroup/test_kmem.c +F: tools/testing/selftests/cgroup/test_memcontrol.c CORETEMP HARDWARE MONITORING DRIVER M: Fenghua Yu <[email protected]>
Signature · 1 line
2.35.1