[LTP] [PATCH v1] mmapstress06: Rate limit page-dirtying loop to prevent MemCG OOM-kills
Cyril Hrubis
chrubis@suse.cz
Tue Sep 1 10:47:47 CEST 2026
Hi!
> > diff --git a/testcases/kernel/mem/mmapstress/mmapstress06.c b/testcases/kernel/mem/mmapstress/mmapstress06.c
> > index 4e6023399..2c0c6fb02 100644
> > --- a/testcases/kernel/mem/mmapstress/mmapstress06.c
> > +++ b/testcases/kernel/mem/mmapstress/mmapstress06.c
> > @@ -59,8 +59,9 @@ static void run_test(void)
> >
> > for (size_t i = 0; i < map_size; i += page_size) {
> > mmapaddr[i] = 'a';
> > - if ((i % (2 * 1024 * 1024)) == 0)
> > - usleep(1000);
> > +
> > + if (i >= mem_limit && !(i % (2 * 1024 * 1024)))
> > + usleep(100000);
> > }
> >
> > The testrun increses to 6s from 1s but it makes the OOM very unlikely to
> > happen.
> Thanks for your suggestion.
> I have tested above solution in our openqa setup but still encounter failure, 3 test cases
> still failure with oom after run 100 cases. Maybe slow down dirty loop
> is still too late?
AFAIK the swapping does not start until we are over the limit, so
slowing it down before we reach the limit is not going to change
anything. For v2 cgroup we can also set a soft limit memory.high to
slightly smaller number than memory.max, whith that the kernel would
start the swapping once memory.high was reached.
Something as:
if (!TST_CG_VER_IS_V1(cg_child, memory))
SAFE_CG_PRINT(cg_child, "memory.high", "%lu", mem_limit - mem_limit/8);
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list