* [PATCH 0/4] memcontrol selftests fixups
@ 2022-05-18 15:40 Michal Koutný
2022-05-18 15:40 ` [PATCH 1/4] selftests: memcg: Fix compilation Michal Koutný
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Michal Koutný @ 2022-05-18 15:40 UTC (permalink / raw)
To: cgroups, linux-mm
Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt,
linux-kernel, linux-kselftest, Richard Palethorpe
Hello.
I'm just flushing the simple patches to make memcontrol selftests check the
events behavior we had consensus about (test_memcg_low fails). (I've dropped to
goto macros for now.)
(test_memcg_reclaim, test_memcg_swap_max fail for me now but it's present
even before the refactoring.)
The only bigger change is adjustment of the protected values to make tests
succeed with the given tolerance.
It's based on mm-stable [1] commit e240ac52f7da. AFAIC, the fixup and partial
reverts may be folded into respective commits.
Let me know if it should be (re)based on something else.
Thanks,
Michal
[1] https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/log/tools/testing/selftests/cgroup?h=mm-stable
Michal Koutný (4):
selftests: memcg: Fix compilation
selftests: memcg: Expect no low events in unprotected sibling
selftests: memcg: Adjust expected reclaim values of protected cgroups
selftests: memcg: Remove protection from top level memcg
.../selftests/cgroup/test_memcontrol.c | 59 +++++++++----------
1 file changed, 29 insertions(+), 30 deletions(-)
--
2.35.3
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 1/4] selftests: memcg: Fix compilation 2022-05-18 15:40 [PATCH 0/4] memcontrol selftests fixups Michal Koutný @ 2022-05-18 15:40 ` Michal Koutný 2022-05-18 15:40 ` [PATCH 2/4] selftests: memcg: Expect no low events in unprotected sibling Michal Koutný ` (3 subsequent siblings) 4 siblings, 0 replies; 10+ messages in thread From: Michal Koutný @ 2022-05-18 15:40 UTC (permalink / raw) To: cgroups, linux-mm Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt, linux-kernel, linux-kselftest, Richard Palethorpe This fixes mis-applied changes from commit 72b1e03aa725 ("cgroup: account for memory_localevents in test_memcg_oom_group_leaf_events()"). Signed-off-by: Michal Koutný <mkoutny@suse.com> --- .../selftests/cgroup/test_memcontrol.c | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c index 6ab94317c87b..4958b42201a9 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -1241,7 +1241,16 @@ 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) + parent_oom_events = cg_read_key_long( + parent, "memory.events", "oom_kill "); + /* + * If memory_localevents is not enabled (the default), the parent should + * count OOM events in its children groups. Otherwise, it should not + * have observed any events. + */ + if (has_localevents && parent_oom_events != 0) + goto cleanup; + else if (!has_localevents && parent_oom_events <= 0) goto cleanup; ret = KSFT_PASS; @@ -1349,20 +1358,14 @@ static int test_memcg_oom_group_score_events(const char *root) if (!cg_run(memcg, alloc_anon, (void *)MB(100))) goto cleanup; - parent_oom_events = cg_read_key_long( - parent, "memory.events", "oom_kill "); - /* - * If memory_localevents is not enabled (the default), the parent should - * count OOM events in its children groups. Otherwise, it should not - * have observed any events. - */ - if ((has_localevents && parent_oom_events == 0) || - parent_oom_events > 0) - ret = KSFT_PASS; + if (cg_read_key_long(memcg, "memory.events", "oom_kill ") != 3) + FAIL(cleanup); if (kill(safe_pid, SIGKILL)) goto cleanup; + ret = KSFT_PASS; + cleanup: if (memcg) cg_destroy(memcg); -- 2.35.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/4] selftests: memcg: Expect no low events in unprotected sibling 2022-05-18 15:40 [PATCH 0/4] memcontrol selftests fixups Michal Koutný 2022-05-18 15:40 ` [PATCH 1/4] selftests: memcg: Fix compilation Michal Koutný @ 2022-05-18 15:40 ` Michal Koutný 2022-05-18 15:40 ` [PATCH 3/4] selftests: memcg: Adjust expected reclaim values of protected cgroups Michal Koutný ` (2 subsequent siblings) 4 siblings, 0 replies; 10+ messages in thread From: Michal Koutný @ 2022-05-18 15:40 UTC (permalink / raw) To: cgroups, linux-mm Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt, linux-kernel, linux-kselftest, Richard Palethorpe This is effectively a revert of commit cdc69458a5f3 ("cgroup: account for memory_recursiveprot in test_memcg_low()"). The case test_memcg_low will fail with memory_recursiveprot until resolved in reclaim code. However, this patch preserves the existing helpers and variables for later uses. Signed-off-by: Michal Koutný <mkoutny@suse.com> --- tools/testing/selftests/cgroup/test_memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c index 4958b42201a9..eba252fa64ac 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -528,7 +528,7 @@ static int test_memcg_low(const char *root) } for (i = 0; i < ARRAY_SIZE(children); i++) { - int no_low_events_index = has_recursiveprot ? 2 : 1; + int no_low_events_index = 1; oom = cg_read_key_long(children[i], "memory.events", "oom "); low = cg_read_key_long(children[i], "memory.events", "low "); -- 2.35.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/4] selftests: memcg: Adjust expected reclaim values of protected cgroups 2022-05-18 15:40 [PATCH 0/4] memcontrol selftests fixups Michal Koutný 2022-05-18 15:40 ` [PATCH 1/4] selftests: memcg: Fix compilation Michal Koutný 2022-05-18 15:40 ` [PATCH 2/4] selftests: memcg: Expect no low events in unprotected sibling Michal Koutný @ 2022-05-18 15:40 ` Michal Koutný 2022-05-18 15:40 ` [PATCH 4/4] selftests: memcg: Remove protection from top level memcg Michal Koutný 2022-05-18 16:27 ` [PATCH 0/4] memcontrol selftests fixups Michal Koutný 4 siblings, 0 replies; 10+ messages in thread From: Michal Koutný @ 2022-05-18 15:40 UTC (permalink / raw) To: cgroups, linux-mm Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt, linux-kernel, linux-kselftest, Richard Palethorpe The numbers are not easy to derive in a closed form (certainly mere protections ratios do not apply), therefore use a simulation to obtain expected numbers. The new values make the protection tests succeed more precisely. % run as: octave-cli script % % Input configurations % ------------------- % E parent effective protection % n nominal protection of siblings set at the givel level % c current consumption -,,- % example from testcase (values in GB) E = 50 / 1024; n = [75 25 0 500 ] / 1024; c = [50 50 50 0] / 1024; % Reclaim parameters % ------------------ % Minimal reclaim amount (GB) cluster = 32*4 / 2**20; % Reclaim coefficient (think as 0.5^sc->priority) alpha = .1 % Simulation parameters % --------------------- epsilon = 1e-7; timeout = 1000; % Simulation loop % --------------------- % Simulation assumes siblings consumed the initial amount of memory (w/out % reclaim) and then the reclaim starts, all memory is reclaimable, i.e. treated % same. It simulates only non-low reclaim and assumes all memory.min = 0. ch = []; eh = []; rh = []; for t = 1:timeout % low_usage u = min(c, n); siblings = sum(u); % effective_protection() protected = min(n, c); % start with nominal e = protected * min(1, E / siblings); % normalize overcommit % recursive protection unclaimed = max(0, E - siblings); parent_overuse = sum(c) - siblings; if (unclaimed > 0 && parent_overuse > 0) overuse = max(0, c - protected); e += unclaimed * (overuse / parent_overuse); endif % get_scan_count() r = alpha * c; % assume all memory is in a single LRU list % commit 1bc63fb1272b ("mm, memcg: make scan aggression always exclude protection") sz = max(e, c); r .*= (1 - (e+epsilon) ./ (sz+epsilon)); % uncomment to debug prints % e, c, r % nothing to reclaim, reached equilibrium if max(r) < epsilon break; endif % SWAP_CLUSTER_MAX r = max(r, (r > epsilon) .* cluster); % XXX here I do parallel reclaim of all siblings % in reality reclaim is serialized and each sibling recalculates own residual c = max(c - r, 0); ch = [ch ; c]; eh = [eh ; e]; rh = [rh ; r]; endfor t c, e Signed-off-by: Michal Koutný <mkoutny@suse.com> --- .../selftests/cgroup/test_memcontrol.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c index eba252fa64ac..9ffacf024bbd 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -260,9 +260,9 @@ static int cg_test_proc_killed(const char *cgroup) * memory pressure in it. * * A/B memory.current ~= 50M - * A/B/C memory.current ~= 33M - * A/B/D memory.current ~= 17M - * A/B/F memory.current ~= 0 + * A/B/C memory.current ~= 29M + * A/B/D memory.current ~= 21M + * A/B/E memory.current ~= 0 * * After that it tries to allocate more than there is * unprotected memory in A available, and checks @@ -365,10 +365,10 @@ static int test_memcg_min(const char *root) for (i = 0; i < ARRAY_SIZE(children); i++) c[i] = cg_read_long(children[i], "memory.current"); - if (!values_close(c[0], MB(33), 10)) + if (!values_close(c[0], MB(29), 10)) goto cleanup; - if (!values_close(c[1], MB(17), 10)) + if (!values_close(c[1], MB(21), 10)) goto cleanup; if (c[3] != 0) @@ -417,9 +417,9 @@ static int test_memcg_min(const char *root) * * Then it checks actual memory usages and expects that: * A/B memory.current ~= 50M - * A/B/ memory.current ~= 33M - * A/B/D memory.current ~= 17M - * A/B/F memory.current ~= 0 + * A/B/ memory.current ~= 29M + * A/B/D memory.current ~= 21M + * A/B/E memory.current ~= 0 * * After that it tries to allocate more than there is * unprotected memory in A available, @@ -512,10 +512,10 @@ static int test_memcg_low(const char *root) for (i = 0; i < ARRAY_SIZE(children); i++) c[i] = cg_read_long(children[i], "memory.current"); - if (!values_close(c[0], MB(33), 10)) + if (!values_close(c[0], MB(29), 10)) goto cleanup; - if (!values_close(c[1], MB(17), 10)) + if (!values_close(c[1], MB(21), 10)) goto cleanup; if (c[3] != 0) -- 2.35.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/4] selftests: memcg: Remove protection from top level memcg 2022-05-18 15:40 [PATCH 0/4] memcontrol selftests fixups Michal Koutný ` (2 preceding siblings ...) 2022-05-18 15:40 ` [PATCH 3/4] selftests: memcg: Adjust expected reclaim values of protected cgroups Michal Koutný @ 2022-05-18 15:40 ` Michal Koutný 2022-05-18 16:27 ` [PATCH 0/4] memcontrol selftests fixups Michal Koutný 4 siblings, 0 replies; 10+ messages in thread From: Michal Koutný @ 2022-05-18 15:40 UTC (permalink / raw) To: cgroups, linux-mm Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt, linux-kernel, linux-kselftest, Richard Palethorpe The reclaim is triggered by memory limit in a subtree, therefore the testcase does not need configured protection against external reclaim. Also, correct/deduplicate respective comments Signed-off-by: Michal Koutný <mkoutny@suse.com> --- tools/testing/selftests/cgroup/test_memcontrol.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c index 9ffacf024bbd..9d370aafd799 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -247,7 +247,7 @@ static int cg_test_proc_killed(const char *cgroup) /* * First, this test creates the following hierarchy: - * A memory.min = 50M, memory.max = 200M + * A memory.min = 0, memory.max = 200M * A/B memory.min = 50M, memory.current = 50M * A/B/C memory.min = 75M, memory.current = 50M * A/B/D memory.min = 25M, memory.current = 50M @@ -257,7 +257,7 @@ static int cg_test_proc_killed(const char *cgroup) * Usages are pagecache, but the test keeps a running * process in every leaf cgroup. * Then it creates A/G and creates a significant - * memory pressure in it. + * memory pressure in A. * * A/B memory.current ~= 50M * A/B/C memory.current ~= 29M @@ -335,8 +335,6 @@ static int test_memcg_min(const char *root) (void *)(long)fd); } - if (cg_write(parent[0], "memory.min", "50M")) - goto cleanup; if (cg_write(parent[1], "memory.min", "50M")) goto cleanup; if (cg_write(children[0], "memory.min", "75M")) @@ -404,8 +402,8 @@ static int test_memcg_min(const char *root) /* * First, this test creates the following hierarchy: - * A memory.low = 50M, memory.max = 200M - * A/B memory.low = 50M, memory.current = 50M + * A memory.low = 0, memory.max = 200M + * A/B memory.low = 50M, memory.current = ... * A/B/C memory.low = 75M, memory.current = 50M * A/B/D memory.low = 25M, memory.current = 50M * A/B/E memory.low = 0, memory.current = 50M @@ -490,8 +488,6 @@ static int test_memcg_low(const char *root) goto cleanup; } - if (cg_write(parent[0], "memory.low", "50M")) - goto cleanup; if (cg_write(parent[1], "memory.low", "50M")) goto cleanup; if (cg_write(children[0], "memory.low", "75M")) -- 2.35.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 0/4] memcontrol selftests fixups 2022-05-18 15:40 [PATCH 0/4] memcontrol selftests fixups Michal Koutný ` (3 preceding siblings ...) 2022-05-18 15:40 ` [PATCH 4/4] selftests: memcg: Remove protection from top level memcg Michal Koutný @ 2022-05-18 16:27 ` Michal Koutný 4 siblings, 0 replies; 10+ messages in thread From: Michal Koutný @ 2022-05-18 16:27 UTC (permalink / raw) To: cgroups, linux-mm Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt, linux-kernel, linux-kselftest, Richard Palethorpe Apologies for spam due to botched sending. Please disregard this (old) series. The replacement should come in https://lore.kernel.org/r/20220518161859.21565-1-mkoutny@suse.com (That one is also not 100% correct, it's missing a Subject: therefore may not be pass through some filters.) The 1st patch of that v2 series is at https://lore.kernel.org/r/20220518161859.21565-2-mkoutny@suse.com/ And I copy the cover letter here to be sure (and not to spam even more). ---->---- Subject: [PATCH v2 0/5] memcontrol selftests fixups Hello. I'm just flushing the patches to make memcontrol selftests check the events behavior we had consensus about (test_memcg_low fails). (test_memcg_reclaim, test_memcg_swap_max fail for me now but it's present even before the refactoring.) The two bigger changes are: - adjustment of the protected values to make tests succeed with the given tolerance, - both test_memcg_low and test_memcg_min check protection of memory in populated cgroups (actually as per Documentation/admin-guide/cgroup-v2.rst memory.min should not apply to empty cgroups, which is not the case currently. Therefore I unified tests with the populated case in order to to bring more broken tests). Thanks, Michal Changes from v1 (https://lore.kernel.org/r/20220513171811.730-1-mkoutny@suse.com/) - fixed mis-rebase in compilation fix patch, - added review, ack tags from v1, - applied feedback from v1 (Octave script in git tree), - added one more patch extracting common parts, - rebased on mm-stable bbe832b9db2e. ----<---- ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/5] Fix bugs in memcontroller cgroup tests
@ 2022-05-12 17:44 David Vernet
2022-05-13 17:18 ` [PATCH 0/4] memcontrol selftests fixups Michal Koutný
0 siblings, 1 reply; 10+ messages in thread
From: David Vernet @ 2022-05-12 17:44 UTC (permalink / raw)
To: Michal Koutný
Cc: akpm, tj, roman.gushchin, linux-kernel, linux-mm, cgroups, hannes,
mhocko, shakeelb, kernel-team
On Thu, May 12, 2022 at 10:30:18AM -0700, David Vernet wrote:
> Hi Michal,
>
> On Thu, May 12, 2022 at 07:04:10PM +0200, Michal Koutný wrote:
> > Are the Roman's patches merged anywhere? (I ran into some issues when I
> > was rebasing your (David's) series on top of master.) I'd like to put
> > all sensible patches in one series or stack on existing branch (if
> > there's any).
>
> Roman's patches are present on master on the linux-mm tree. See
> b7dbfd6553d..a131b1ed12c6.
>
> > For possible v3 of this series, I did:
> > - dropped the patch that allows non-zero memory.events:low for a sibling with
> > memory.low=0 when mounted with memory_recursiveprot (the case needs more
> > discussion),
>
> Ack, and thanks for keeping us steered in the right direction here. I don't
> see this in the patch set you linked, but I agree this commit should be
> reverted and the reclaim logic instead fixed.
>
> > - added few more cleanups, convenience for debugging,
>
> Are you referring to the FAIL() macro you added? I would love to Ack that,
> but unfortunately checkpatch.pl will probably yell at you for having a goto
> in that macro, per the point about avoiding macros that affect control flow
> [0].
>
> I tried to do the same thing when sending out my patch set and had to
> revert it before sending it to upstream.
>
> Thanks,
> David
>
> [0] https://github.com/Werkov/linux/commit/a076339cc4825af2f22f58c1347a572b104b8221
Sorry, I meant to link this:
https://www.kernel.org/doc/html/latest/process/coding-style.html#macros-enums-and-rtl
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 0/4] memcontrol selftests fixups 2022-05-12 17:44 [PATCH v2 0/5] Fix bugs in memcontroller cgroup tests David Vernet @ 2022-05-13 17:18 ` Michal Koutný 2022-05-13 17:18 ` [PATCH 1/4] selftests: memcg: Fix compilation Michal Koutný 0 siblings, 1 reply; 10+ messages in thread From: Michal Koutný @ 2022-05-13 17:18 UTC (permalink / raw) To: void Cc: akpm, cgroups, hannes, kernel-team, linux-kernel, linux-mm, mhocko, mkoutny, roman.gushchin, shakeelb, tj, Richard Palethorpe Hello. I'm just flushing the simple patches to make memcontrol selftests check the events behavior we had consensus about (test_memcg_low fails). (I've dropped to goto macros for now.) (test_memcg_reclaim, test_memcg_swap_max fail for me now but it's present even before the refactoring.) The only bigger change is adjustment of the protected values to make tests succeed with the given tolerance. It's based on mm-stable [1] commit e240ac52f7da. AFAIC, the fixup and partial reverts may be folded into respective commits. Let me know if it should be (re)based on something else. Thanks, Michal [1] https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/log/tools/testing/selftests/cgroup?h=mm-stable Michal Koutný (4): selftests: memcg: Fix compilation selftests: memcg: Expect no low events in unprotected sibling selftests: memcg: Adjust expected reclaim values of protected cgroups selftests: memcg: Remove protection from top level memcg .../selftests/cgroup/test_memcontrol.c | 59 +++++++++---------- 1 file changed, 29 insertions(+), 30 deletions(-) -- 2.35.3 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/4] selftests: memcg: Fix compilation 2022-05-13 17:18 ` [PATCH 0/4] memcontrol selftests fixups Michal Koutný @ 2022-05-13 17:18 ` Michal Koutný 2022-05-13 17:40 ` David Vernet 2022-05-13 18:53 ` Roman Gushchin 0 siblings, 2 replies; 10+ messages in thread From: Michal Koutný @ 2022-05-13 17:18 UTC (permalink / raw) To: void Cc: akpm, cgroups, hannes, kernel-team, linux-kernel, linux-mm, mhocko, mkoutny, roman.gushchin, shakeelb, tj, Richard Palethorpe This fixes mis-applied changes from commit 72b1e03aa725 ("cgroup: account for memory_localevents in test_memcg_oom_group_leaf_events()"). Signed-off-by: Michal Koutný <mkoutny@suse.com> --- .../selftests/cgroup/test_memcontrol.c | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c index 6ab94317c87b..4958b42201a9 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -1241,7 +1241,16 @@ 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) + parent_oom_events = cg_read_key_long( + parent, "memory.events", "oom_kill "); + /* + * If memory_localevents is not enabled (the default), the parent should + * count OOM events in its children groups. Otherwise, it should not + * have observed any events. + */ + if (has_localevents && parent_oom_events != 0) + goto cleanup; + else if (!has_localevents && parent_oom_events <= 0) goto cleanup; ret = KSFT_PASS; @@ -1349,20 +1358,14 @@ static int test_memcg_oom_group_score_events(const char *root) if (!cg_run(memcg, alloc_anon, (void *)MB(100))) goto cleanup; - parent_oom_events = cg_read_key_long( - parent, "memory.events", "oom_kill "); - /* - * If memory_localevents is not enabled (the default), the parent should - * count OOM events in its children groups. Otherwise, it should not - * have observed any events. - */ - if ((has_localevents && parent_oom_events == 0) || - parent_oom_events > 0) - ret = KSFT_PASS; + if (cg_read_key_long(memcg, "memory.events", "oom_kill ") != 3) + FAIL(cleanup); if (kill(safe_pid, SIGKILL)) goto cleanup; + ret = KSFT_PASS; + cleanup: if (memcg) cg_destroy(memcg); -- 2.35.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/4] selftests: memcg: Fix compilation 2022-05-13 17:18 ` [PATCH 1/4] selftests: memcg: Fix compilation Michal Koutný @ 2022-05-13 17:40 ` David Vernet 2022-05-13 18:53 ` Roman Gushchin 1 sibling, 0 replies; 10+ messages in thread From: David Vernet @ 2022-05-13 17:40 UTC (permalink / raw) To: Michal Koutný Cc: akpm, cgroups, hannes, kernel-team, linux-kernel, linux-mm, mhocko, roman.gushchin, shakeelb, tj, Richard Palethorpe On Fri, May 13, 2022 at 07:18:08PM +0200, Michal Koutný wrote: > This fixes mis-applied changes from commit 72b1e03aa725 ("cgroup: > account for memory_localevents in test_memcg_oom_group_leaf_events()"). > > Signed-off-by: Michal Koutný <mkoutny@suse.com> > --- > .../selftests/cgroup/test_memcontrol.c | 25 +++++++++++-------- > 1 file changed, 14 insertions(+), 11 deletions(-) > > diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c > index 6ab94317c87b..4958b42201a9 100644 > --- a/tools/testing/selftests/cgroup/test_memcontrol.c > +++ b/tools/testing/selftests/cgroup/test_memcontrol.c > @@ -1241,7 +1241,16 @@ 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) > + parent_oom_events = cg_read_key_long( > + parent, "memory.events", "oom_kill "); > + /* > + * If memory_localevents is not enabled (the default), the parent should > + * count OOM events in its children groups. Otherwise, it should not > + * have observed any events. > + */ > + if (has_localevents && parent_oom_events != 0) > + goto cleanup; > + else if (!has_localevents && parent_oom_events <= 0) > goto cleanup; > > ret = KSFT_PASS; > @@ -1349,20 +1358,14 @@ static int test_memcg_oom_group_score_events(const char *root) > if (!cg_run(memcg, alloc_anon, (void *)MB(100))) > goto cleanup; > > - parent_oom_events = cg_read_key_long( > - parent, "memory.events", "oom_kill "); > - /* > - * If memory_localevents is not enabled (the default), the parent should > - * count OOM events in its children groups. Otherwise, it should not > - * have observed any events. > - */ > - if ((has_localevents && parent_oom_events == 0) || > - parent_oom_events > 0) > - ret = KSFT_PASS; > + if (cg_read_key_long(memcg, "memory.events", "oom_kill ") != 3) > + FAIL(cleanup); > > if (kill(safe_pid, SIGKILL)) > goto cleanup; > > + ret = KSFT_PASS; > + > cleanup: > if (memcg) > cg_destroy(memcg); > -- > 2.35.3 > Thanks for the fix, Michal. Reviewed-by: David Vernet <void@manifault.com> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/4] selftests: memcg: Fix compilation 2022-05-13 17:18 ` [PATCH 1/4] selftests: memcg: Fix compilation Michal Koutný 2022-05-13 17:40 ` David Vernet @ 2022-05-13 18:53 ` Roman Gushchin 2022-05-13 19:09 ` Roman Gushchin 1 sibling, 1 reply; 10+ messages in thread From: Roman Gushchin @ 2022-05-13 18:53 UTC (permalink / raw) To: Michal Koutný Cc: void, akpm, cgroups, hannes, kernel-team, linux-kernel, linux-mm, mhocko, shakeelb, tj, Richard Palethorpe On Fri, May 13, 2022 at 07:18:08PM +0200, Michal Koutny wrote: > This fixes mis-applied changes from commit 72b1e03aa725 ("cgroup: > account for memory_localevents in test_memcg_oom_group_leaf_events()"). > > Signed-off-by: Michal Koutný <mkoutny@suse.com> > --- > .../selftests/cgroup/test_memcontrol.c | 25 +++++++++++-------- > 1 file changed, 14 insertions(+), 11 deletions(-) > > diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c > index 6ab94317c87b..4958b42201a9 100644 > --- a/tools/testing/selftests/cgroup/test_memcontrol.c > +++ b/tools/testing/selftests/cgroup/test_memcontrol.c > @@ -1241,7 +1241,16 @@ 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) > + parent_oom_events = cg_read_key_long( > + parent, "memory.events", "oom_kill "); > + /* > + * If memory_localevents is not enabled (the default), the parent should > + * count OOM events in its children groups. Otherwise, it should not > + * have observed any events. > + */ > + if (has_localevents && parent_oom_events != 0) > + goto cleanup; > + else if (!has_localevents && parent_oom_events <= 0) > goto cleanup; > > ret = KSFT_PASS; > @@ -1349,20 +1358,14 @@ static int test_memcg_oom_group_score_events(const char *root) > if (!cg_run(memcg, alloc_anon, (void *)MB(100))) > goto cleanup; > > - parent_oom_events = cg_read_key_long( > - parent, "memory.events", "oom_kill "); > - /* > - * If memory_localevents is not enabled (the default), the parent should > - * count OOM events in its children groups. Otherwise, it should not > - * have observed any events. > - */ > - if ((has_localevents && parent_oom_events == 0) || > - parent_oom_events > 0) > - ret = KSFT_PASS; > + if (cg_read_key_long(memcg, "memory.events", "oom_kill ") != 3) > + FAIL(cleanup); > > if (kill(safe_pid, SIGKILL)) > goto cleanup; > > + ret = KSFT_PASS; > + > cleanup: > if (memcg) > cg_destroy(memcg); > -- > 2.35.3 > My bad. Acked-by: Roman Gushchin <roman.gushchin@linux.dev> Thanks! ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/4] selftests: memcg: Fix compilation 2022-05-13 18:53 ` Roman Gushchin @ 2022-05-13 19:09 ` Roman Gushchin 0 siblings, 0 replies; 10+ messages in thread From: Roman Gushchin @ 2022-05-13 19:09 UTC (permalink / raw) To: Michal Koutný Cc: void, akpm, cgroups, hannes, kernel-team, linux-kernel, linux-mm, mhocko, shakeelb, tj, Richard Palethorpe On Fri, May 13, 2022 at 11:53:26AM -0700, Roman Gushchin wrote: > On Fri, May 13, 2022 at 07:18:08PM +0200, Michal Koutny wrote: > > This fixes mis-applied changes from commit 72b1e03aa725 ("cgroup: > > account for memory_localevents in test_memcg_oom_group_leaf_events()"). > > > > Signed-off-by: Michal Koutný <mkoutny@suse.com> > > --- > > .../selftests/cgroup/test_memcontrol.c | 25 +++++++++++-------- > > 1 file changed, 14 insertions(+), 11 deletions(-) > > > > diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c > > index 6ab94317c87b..4958b42201a9 100644 > > --- a/tools/testing/selftests/cgroup/test_memcontrol.c > > +++ b/tools/testing/selftests/cgroup/test_memcontrol.c > > @@ -1241,7 +1241,16 @@ 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) > > + parent_oom_events = cg_read_key_long( > > + parent, "memory.events", "oom_kill "); > > + /* > > + * If memory_localevents is not enabled (the default), the parent should > > + * count OOM events in its children groups. Otherwise, it should not > > + * have observed any events. > > + */ > > + if (has_localevents && parent_oom_events != 0) > > + goto cleanup; > > + else if (!has_localevents && parent_oom_events <= 0) > > goto cleanup; > > > > ret = KSFT_PASS; > > @@ -1349,20 +1358,14 @@ static int test_memcg_oom_group_score_events(const char *root) > > if (!cg_run(memcg, alloc_anon, (void *)MB(100))) > > goto cleanup; > > > > - parent_oom_events = cg_read_key_long( > > - parent, "memory.events", "oom_kill "); > > - /* > > - * If memory_localevents is not enabled (the default), the parent should > > - * count OOM events in its children groups. Otherwise, it should not > > - * have observed any events. > > - */ > > - if ((has_localevents && parent_oom_events == 0) || > > - parent_oom_events > 0) > > - ret = KSFT_PASS; > > + if (cg_read_key_long(memcg, "memory.events", "oom_kill ") != 3) > > + FAIL(cleanup); > > > > if (kill(safe_pid, SIGKILL)) > > goto cleanup; > > > > + ret = KSFT_PASS; > > + > > cleanup: > > if (memcg) > > cg_destroy(memcg); > > -- > > 2.35.3 > > > > My bad. Actually not, as pointed by David. Seems like it's git fault. The original patch looks correct. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-05-18 16:27 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-05-18 15:40 [PATCH 0/4] memcontrol selftests fixups Michal Koutný 2022-05-18 15:40 ` [PATCH 1/4] selftests: memcg: Fix compilation Michal Koutný 2022-05-18 15:40 ` [PATCH 2/4] selftests: memcg: Expect no low events in unprotected sibling Michal Koutný 2022-05-18 15:40 ` [PATCH 3/4] selftests: memcg: Adjust expected reclaim values of protected cgroups Michal Koutný 2022-05-18 15:40 ` [PATCH 4/4] selftests: memcg: Remove protection from top level memcg Michal Koutný 2022-05-18 16:27 ` [PATCH 0/4] memcontrol selftests fixups Michal Koutný -- strict thread matches above, loose matches on Subject: below -- 2022-05-12 17:44 [PATCH v2 0/5] Fix bugs in memcontroller cgroup tests David Vernet 2022-05-13 17:18 ` [PATCH 0/4] memcontrol selftests fixups Michal Koutný 2022-05-13 17:18 ` [PATCH 1/4] selftests: memcg: Fix compilation Michal Koutný 2022-05-13 17:40 ` David Vernet 2022-05-13 18:53 ` Roman Gushchin 2022-05-13 19:09 ` Roman Gushchin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).