From: Martin Doucha <mdoucha@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] Fix tst_pollute_memory() safety margin for huge systems
Date: Wed, 27 Jan 2021 12:56:06 +0100 [thread overview]
Message-ID: <20210127115606.28985-1-mdoucha@suse.cz> (raw)
tst_pollute_memory() still has OOM issues on system with huge amounts of RAM.
Set safety margin to the largest value of:
- 2 * min_free_kbytes
- 128MB
- 4096 pages
- Free RAM / 128 (to account for memory allocation overhead)
Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
lib/tst_memutils.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/tst_memutils.c b/lib/tst_memutils.c
index dd09db490..7cdb3dbe0 100644
--- a/lib/tst_memutils.c
+++ b/lib/tst_memutils.c
@@ -20,8 +20,11 @@ void tst_pollute_memory(size_t maxsize, int fillchar)
struct sysinfo info;
SAFE_SYSINFO(&info);
- safety = MAX(4096 * SAFE_SYSCONF(_SC_PAGESIZE), 128 * 1024 * 1024);
+ SAFE_FILE_SCANF("/proc/sys/vm/min_free_kbytes", "%zd", &safety);
+ safety = MAX(2048 * safety, 128 * 1024 * 1024);
+ safety = MAX(safety, 4096 * SAFE_SYSCONF(_SC_PAGESIZE));
safety /= info.mem_unit;
+ safety = MAX(safety, info.freeram / 128);
if (info.freeswap > safety)
safety = 0;
--
2.29.2
next reply other threads:[~2021-01-27 11:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-27 11:56 Martin Doucha [this message]
2021-01-27 12:03 ` [LTP] [PATCH] Fix tst_pollute_memory() safety margin for huge systems Cyril Hrubis
2021-01-27 12:14 ` liuxp11
2021-01-27 12:28 ` Cyril Hrubis
2021-01-27 12:30 ` liuxp11
2021-01-27 13:05 ` Li Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210127115606.28985-1-mdoucha@suse.cz \
--to=mdoucha@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox