public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v1] memcontrol03: Using clean page cache to avoid dependency on IO rate
@ 2024-03-08  2:33 Wei Gao via ltp
  2024-03-14 11:24 ` Cyril Hrubis
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Wei Gao via ltp @ 2024-03-08  2:33 UTC (permalink / raw)
  To: ltp

Bad IO situation(storage bandwidth ~10MB/sec) will lead background
writeback has uncertain progress for dirty page. So system can not
reclaim enough memory for new process and finally lead a unexpected
OOM.

memcontrol03.c:218: TPASS: Expect: (A/B/E memory.current=0) ~= 0
memcontrol03.c:116: TPASS: Child 1918 killed by OOM
memcontrol03.c:224: TPASS: Expect: (A/B memory.current=52588544) ~= 52428800
memcontrol03.c:129: TFAIL: Expected child 1944 to exit(0), but instead killed by SIGKILL

Signed-off-by: Wei Gao <wegao@suse.com>
---
 testcases/kernel/controllers/memcg/memcontrol03.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/testcases/kernel/controllers/memcg/memcontrol03.c b/testcases/kernel/controllers/memcg/memcontrol03.c
index 9c6c808e0..9903ba82b 100644
--- a/testcases/kernel/controllers/memcg/memcontrol03.c
+++ b/testcases/kernel/controllers/memcg/memcontrol03.c
@@ -201,6 +201,7 @@ static void test_memcg_min(void)
 		sleep(1);
 	}
 
+	sync();
 	alloc_anon_in_child(trunk_cg[G], MB(148), 0);
 
 	SAFE_CG_SCANF(trunk_cg[B], "memory.current", "%ld", c);
@@ -217,6 +218,7 @@ static void test_memcg_min(void)
 	TST_EXP_EXPR(values_close(c[2], 0, 1),
 		     "(A/B/E memory.current=%ld) ~= 0", c[2]);
 
+	sync();
 	alloc_anon_in_child(trunk_cg[G], MB(170), 1);
 
 	SAFE_CG_SCANF(trunk_cg[B], "memory.current", "%ld", c);
-- 
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH v1] memcontrol03: Using clean page cache to avoid dependency on IO rate
  2024-03-08  2:33 [LTP] [PATCH v1] memcontrol03: Using clean page cache to avoid dependency on IO rate Wei Gao via ltp
@ 2024-03-14 11:24 ` Cyril Hrubis
  2024-03-14 15:46 ` Cyril Hrubis
  2024-03-15  3:31 ` [LTP] [PATCH v2] " Wei Gao via ltp
  2 siblings, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2024-03-14 11:24 UTC (permalink / raw)
  To: Wei Gao; +Cc: ltp

Hi!
> Bad IO situation(storage bandwidth ~10MB/sec) will lead background
> writeback has uncertain progress for dirty page. So system can not
> reclaim enough memory for new process and finally lead a unexpected
> OOM.
> 
> memcontrol03.c:218: TPASS: Expect: (A/B/E memory.current=0) ~= 0
> memcontrol03.c:116: TPASS: Child 1918 killed by OOM
> memcontrol03.c:224: TPASS: Expect: (A/B memory.current=52588544) ~= 52428800
> memcontrol03.c:129: TFAIL: Expected child 1944 to exit(0), but instead killed by SIGKILL

This is strange the order of messages here does not make any sense. the
last line in the log shouldn't be there at all, the test should have
ended with the "Expect: (A/B memory.current=52588544) ~= 52428800"

Can you please send the whole log?

> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
>  testcases/kernel/controllers/memcg/memcontrol03.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/testcases/kernel/controllers/memcg/memcontrol03.c b/testcases/kernel/controllers/memcg/memcontrol03.c
> index 9c6c808e0..9903ba82b 100644
> --- a/testcases/kernel/controllers/memcg/memcontrol03.c
> +++ b/testcases/kernel/controllers/memcg/memcontrol03.c
> @@ -201,6 +201,7 @@ static void test_memcg_min(void)
>  		sleep(1);
>  	}
>  
> +	sync();
>  	alloc_anon_in_child(trunk_cg[G], MB(148), 0);
>  
>  	SAFE_CG_SCANF(trunk_cg[B], "memory.current", "%ld", c);
> @@ -217,6 +218,7 @@ static void test_memcg_min(void)
>  	TST_EXP_EXPR(values_close(c[2], 0, 1),
>  		     "(A/B/E memory.current=%ld) ~= 0", c[2]);
>  
> +	sync();
>  	alloc_anon_in_child(trunk_cg[G], MB(170), 1);
>  
>  	SAFE_CG_SCANF(trunk_cg[B], "memory.current", "%ld", c);

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH v1] memcontrol03: Using clean page cache to avoid dependency on IO rate
  2024-03-08  2:33 [LTP] [PATCH v1] memcontrol03: Using clean page cache to avoid dependency on IO rate Wei Gao via ltp
  2024-03-14 11:24 ` Cyril Hrubis
@ 2024-03-14 15:46 ` Cyril Hrubis
  2024-03-15  3:31 ` [LTP] [PATCH v2] " Wei Gao via ltp
  2 siblings, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2024-03-14 15:46 UTC (permalink / raw)
  To: Wei Gao; +Cc: ltp

Hi!
> Bad IO situation(storage bandwidth ~10MB/sec) will lead background
> writeback has uncertain progress for dirty page. So system can not
> reclaim enough memory for new process and finally lead a unexpected
> OOM.
> 
> memcontrol03.c:218: TPASS: Expect: (A/B/E memory.current=0) ~= 0
> memcontrol03.c:116: TPASS: Child 1918 killed by OOM
> memcontrol03.c:224: TPASS: Expect: (A/B memory.current=52588544) ~= 52428800
> memcontrol03.c:129: TFAIL: Expected child 1944 to exit(0), but instead killed by SIGKILL

So I've read the corresponding bug:

https://bugzilla.suse.com/show_bug.cgi?id=1218178

And now I understand what this is supposed to fix. Hover doing sync() is
a too big hammer, there is no need to sync the whole system, we just
need to make sure that the pages from the file we wrote into are written
to a pernament storage, so we likely just need:

diff --git a/testcases/kernel/controllers/memcg/memcontrol03.c b/testcases/kernel/controllers/memcg/memcontrol03.c
index e927dfd19..6d9c490b5 100644
--- a/testcases/kernel/controllers/memcg/memcontrol03.c
+++ b/testcases/kernel/controllers/memcg/memcontrol03.c
@@ -144,6 +144,7 @@ static void alloc_pagecache_in_child(const struct tst_cg_group *const cg,
        tst_res(TINFO, "Child %d in %s: Allocating pagecache: %"PRIdPTR,
                getpid(), tst_cg_group_name(cg), size);
        alloc_pagecache(fd, size);
+       SAFE_FSYNC(fd);

        TST_CHECKPOINT_WAKE(CHILD_IDLE);
        TST_CHECKPOINT_WAIT(TEST_DONE);

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [LTP] [PATCH v2] memcontrol03: Using clean page cache to avoid dependency on IO rate
  2024-03-08  2:33 [LTP] [PATCH v1] memcontrol03: Using clean page cache to avoid dependency on IO rate Wei Gao via ltp
  2024-03-14 11:24 ` Cyril Hrubis
  2024-03-14 15:46 ` Cyril Hrubis
@ 2024-03-15  3:31 ` Wei Gao via ltp
  2024-03-15  9:17   ` Petr Vorel
  2 siblings, 1 reply; 6+ messages in thread
From: Wei Gao via ltp @ 2024-03-15  3:31 UTC (permalink / raw)
  To: ltp

Bad IO situation(storage bandwidth ~10MB/sec) will lead background
writeback has uncertain progress for dirty page. So system can not
reclaim enough memory for new process and finally lead a unexpected
OOM.

memcontrol03.c:218: TPASS: Expect: (A/B/E memory.current=0) ~= 0
memcontrol03.c:116: TPASS: Child 1918 killed by OOM
memcontrol03.c:224: TPASS: Expect: (A/B memory.current=52588544) ~= 52428800
memcontrol03.c:129: TFAIL: Expected child 1944 to exit(0), but instead killed by SIGKILL

Signed-off-by: Wei Gao <wegao@suse.com>
---
 testcases/kernel/controllers/memcg/memcontrol03.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/testcases/kernel/controllers/memcg/memcontrol03.c b/testcases/kernel/controllers/memcg/memcontrol03.c
index 9c6c808e0..e2fc85cc8 100644
--- a/testcases/kernel/controllers/memcg/memcontrol03.c
+++ b/testcases/kernel/controllers/memcg/memcontrol03.c
@@ -144,6 +144,7 @@ static void alloc_pagecache_in_child(const struct tst_cg_group *const cg,
 	tst_res(TINFO, "Child %d in %s: Allocating pagecache: %"PRIdPTR,
 		getpid(), tst_cg_group_name(cg), size);
 	alloc_pagecache(fd, size);
+	SAFE_FSYNC(fd);
 
 	TST_CHECKPOINT_WAKE(CHILD_IDLE);
 	TST_CHECKPOINT_WAIT(TEST_DONE);
-- 
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH v2] memcontrol03: Using clean page cache to avoid dependency on IO rate
  2024-03-15  3:31 ` [LTP] [PATCH v2] " Wei Gao via ltp
@ 2024-03-15  9:17   ` Petr Vorel
  2024-03-15  9:28     ` Petr Vorel
  0 siblings, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2024-03-15  9:17 UTC (permalink / raw)
  To: Wei Gao; +Cc: ltp

Hi Wei,

> Bad IO situation(storage bandwidth ~10MB/sec) will lead background
> writeback has uncertain progress for dirty page. So system can not
> reclaim enough memory for new process and finally lead a unexpected
> OOM.

Use fsync() to make sure that the pages from the file we wrote into are written
to a permanent storage.

> memcontrol03.c:218: TPASS: Expect: (A/B/E memory.current=0) ~= 0
> memcontrol03.c:116: TPASS: Child 1918 killed by OOM
> memcontrol03.c:224: TPASS: Expect: (A/B memory.current=52588544) ~= 52428800
> memcontrol03.c:129: TFAIL: Expected child 1944 to exit(0), but instead killed by SIGKILL

Suggested-by: Cyril Hrubis <chrubis@suse.cz>
(Please do this yourself next time)

Reviewed-by: Petr Vorel <pvorel@suse.cz>
Fixes: https://bugzilla.suse.com/show_bug.cgi?id=1218178

Kind regards,
Petr

> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
>  testcases/kernel/controllers/memcg/memcontrol03.c | 1 +
>  1 file changed, 1 insertion(+)

> diff --git a/testcases/kernel/controllers/memcg/memcontrol03.c b/testcases/kernel/controllers/memcg/memcontrol03.c
> index 9c6c808e0..e2fc85cc8 100644
> --- a/testcases/kernel/controllers/memcg/memcontrol03.c
> +++ b/testcases/kernel/controllers/memcg/memcontrol03.c
> @@ -144,6 +144,7 @@ static void alloc_pagecache_in_child(const struct tst_cg_group *const cg,
>  	tst_res(TINFO, "Child %d in %s: Allocating pagecache: %"PRIdPTR,
>  		getpid(), tst_cg_group_name(cg), size);
>  	alloc_pagecache(fd, size);
> +	SAFE_FSYNC(fd);

>  	TST_CHECKPOINT_WAKE(CHILD_IDLE);
>  	TST_CHECKPOINT_WAIT(TEST_DONE);

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH v2] memcontrol03: Using clean page cache to avoid dependency on IO rate
  2024-03-15  9:17   ` Petr Vorel
@ 2024-03-15  9:28     ` Petr Vorel
  0 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2024-03-15  9:28 UTC (permalink / raw)
  To: Wei Gao, ltp

Hi Wei,

thanks, merged!

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-03-15  9:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-08  2:33 [LTP] [PATCH v1] memcontrol03: Using clean page cache to avoid dependency on IO rate Wei Gao via ltp
2024-03-14 11:24 ` Cyril Hrubis
2024-03-14 15:46 ` Cyril Hrubis
2024-03-15  3:31 ` [LTP] [PATCH v2] " Wei Gao via ltp
2024-03-15  9:17   ` Petr Vorel
2024-03-15  9:28     ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox