All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] lib: memutils: don't pollute entire system memory to avoid OoM
@ 2021-06-24 13:22 Krzysztof Kozlowski
  2021-06-24 13:33 ` Martin Doucha
  2021-09-08 13:37   ` Cyril Hrubis
  0 siblings, 2 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2021-06-24 13:22 UTC (permalink / raw)
  To: ltp

On big memory systems, e.g. 196 GB RAM machine, the ioctl_sg01 test was
failing because of OoM killer during memory pollution:

    tst_test.c:1311: TINFO: Timeout per run is 0h 05m 00s
    ioctl_sg01.c:81: TINFO: Found SCSI device /dev/sg2
    tst_test.c:1357: TINFO: If you are running on slow machine, try exporting LTP_TIMEOUT_MUL > 1
    tst_test.c:1359: TBROK: Test killed! (timeout?)

In dmesg:

    [76477.661067] LTP: starting cve-2018-1000204 (ioctl_sg01)
    [76578.062209] ioctl_sg01 invoked oom-killer: gfp_mask=0x100dca(GFP_HIGHUSER_MOVABLE|__GFP_ZERO), order=0, oom_score_adj=0
    ...
    [76578.062335] Mem-Info:
    [76578.062340] active_anon:63 inactive_anon:49016768 isolated_anon:0
                    active_file:253 inactive_file:117 isolated_file:0
                    unevictable:4871 dirty:4 writeback:0
                    slab_reclaimable:18451 slab_unreclaimable:56355
                    mapped:2478 shmem:310 pagetables:96625 bounce:0
                    free:121136 free_pcp:0 free_cma:0
    ...
    [76578.062527] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0-1,global_oom,task_memcg=/user.slice/user-1000.slice/session-40.scope,task=ioctl_sg01,pid=446171,uid=0
    [76578.062539] Out of memory: Killed process 446171 (ioctl_sg01) total-vm:195955840kB, anon-rss:195941256kB, file-rss:1416kB, shmem-rss:0kB, UID:0 pgtables:383496kB oom_score_adj:0
    [76581.046078] oom_reaper: reaped process 446171 (ioctl_sg01), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB

It seems leaving hard-coded 128 MB free memory works for small or medium
systems, but for such bigger machine it creates significant memory
pressure triggering the out of memory reaper.

The memory pressure usually is defined by ratio between free and total
memory, so adjust the safety/spare memory similarly to keep always 0.5%
of memory free.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 lib/tst_memutils.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/tst_memutils.c b/lib/tst_memutils.c
index dd09db4902b0..abf382d41b20 100644
--- a/lib/tst_memutils.c
+++ b/lib/tst_memutils.c
@@ -21,6 +21,7 @@ void tst_pollute_memory(size_t maxsize, int fillchar)
 
 	SAFE_SYSINFO(&info);
 	safety = MAX(4096 * SAFE_SYSCONF(_SC_PAGESIZE), 128 * 1024 * 1024);
+	safety = MAX(safety, (info.freeram / 200));
 	safety /= info.mem_unit;
 
 	if (info.freeswap > safety)
-- 
2.27.0


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

end of thread, other threads:[~2021-09-08 14:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-24 13:22 [LTP] [PATCH] lib: memutils: don't pollute entire system memory to avoid OoM Krzysztof Kozlowski
2021-06-24 13:33 ` Martin Doucha
2021-06-24 14:00   ` Li Wang
2021-06-24 14:13     ` Martin Doucha
2021-06-24 15:07   ` Krzysztof Kozlowski
2021-06-24 15:34     ` Krzysztof Kozlowski
2021-06-24 15:46       ` Krzysztof Kozlowski
2021-09-08 13:37 ` Cyril Hrubis
2021-09-08 13:37   ` Cyril Hrubis
2021-09-08 13:54     ` Martin Doucha
2021-09-08 13:54       ` Martin Doucha
2021-09-08 14:17         ` Cyril Hrubis
2021-09-08 14:17           ` Cyril Hrubis
2021-09-08 14:19             ` Krzysztof Kozlowski
2021-09-08 14:19               ` Krzysztof Kozlowski
2021-09-08 14:32                 ` Cyril Hrubis
2021-09-08 14:32                   ` 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.