All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] tst_pollute_memory(): Set minimal safety margin to 64MB
@ 2021-01-18 16:32 Martin Doucha
  2021-01-19 12:43 ` Cyril Hrubis
  0 siblings, 1 reply; 9+ messages in thread
From: Martin Doucha @ 2021-01-18 16:32 UTC (permalink / raw)
  To: ltp

4096 pages amounts to 16MB on x86_64 or 256MB on PPC64. 16MB is not enough
to avoid OOM killer on some systems so set the safety margin to either 64MB
or 4096 pages, whichever is higher.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---

Here's my proposed fix for the OOM issues with ioctl_sg01. I can't reproduce
the issue on my x86_64 VMs/machines so please confirm that it works.

Don't forget to run `make clean` after applying this patch because ioctl_sg01
will not be rebuilt automatically due to weak dependency on libltp.a.

 lib/tst_memutils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/tst_memutils.c b/lib/tst_memutils.c
index f134d90c9..c20c94a00 100644
--- a/lib/tst_memutils.c
+++ b/lib/tst_memutils.c
@@ -20,7 +20,8 @@ void tst_pollute_memory(size_t maxsize, int fillchar)
 	struct sysinfo info;
 
 	SAFE_SYSINFO(&info);
-	safety = 4096 * SAFE_SYSCONF(_SC_PAGESIZE) / info.mem_unit;
+	safety = MAX(4096 * SAFE_SYSCONF(_SC_PAGESIZE), 64 * 1024 * 1024);
+	safety /= info.mem_unit;
 
 	if (info.freeswap > safety)
 		safety = 0;
-- 
2.29.2


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

end of thread, other threads:[~2021-01-21  9:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-18 16:32 [LTP] [PATCH] tst_pollute_memory(): Set minimal safety margin to 64MB Martin Doucha
2021-01-19 12:43 ` Cyril Hrubis
2021-01-20 14:47   ` Naresh Kamboju
2021-01-20 14:54     ` Cyril Hrubis
2021-01-20 14:58       ` Naresh Kamboju
2021-01-20 15:06         ` Cyril Hrubis
2021-01-20 17:04           ` Naresh Kamboju
2021-01-20 17:07             ` Martin Doucha
2021-01-21  9:45             ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.