[LTP] [PATCH v1] swapon01.c: Apply a margin to avoid oom

Li Wang liwang@redhat.com
Fri Mar 15 06:56:43 CET 2024


On Fri, Mar 15, 2024 at 1:24 PM Wei Gao <wegao@suse.com> wrote:


> > >> How to disable OOM and also let swap action happen at the same time
> for
> > >> cgroup V2?
> > >>
> > >
> > > The Cgroup v2 does not provide a way to disable OOM inside directly.
> > >
> > > If we want to avoid OOM happening, just have to manage OOM behavior
> > > in cgroup v2 by setting appropriate values for 'memory.max',
> 'memory.high',
> > > and using 'memory.oom.group' to determine whether the OOM killer should
> > > target individual processes or the whole Cgroup.
> > >
> > > After looking back at this case again, I guess the main reason is that
> the
> > > swapfile is too small to bear the memory load, one direct method is
> like
> > > you to enlarge the 'memory.max' value, but that still does not resolve
> > > problems eventually.
> > >
> > > One possible solution is crate a bit larger swapfile for the test, and
> > > unlimited
> > > the swap out size. Can you try this patch on your system?
> This not work.
>

Interesting, how about resizing the swapfile size to larger?
can you try that.



> > >
> > > --- a/testcases/kernel/syscalls/swapon/swapon01.c
> > > +++ b/testcases/kernel/syscalls/swapon/swapon01.c
> > > @@ -38,10 +38,14 @@ static void verify_swapon(void)
> > >  static void setup(void)
> > >  {
> > >         is_swap_supported(SWAP_FILE);
> > > -       make_swapfile(SWAP_FILE, 10, 0);
> > > +       make_swapfile(SWAP_FILE, 1024, 0);
> > >
> > >         SAFE_CG_PRINTF(tst_cg, "cgroup.procs", "%d", getpid());
> > >         SAFE_CG_PRINTF(tst_cg, "memory.max", "%lu", TESTMEM);
> > > +       if (TST_CG_VER_IS_V1(tst_cg, "memory"))
> > > +               SAFE_CG_PRINTF(tst_cg, "memory.swap.max", "%lu", ~0UL);
> > > +       else
> > > +               SAFE_CG_PRINT(tst_cg, "memory.swap.max", "max");
> > >  }
> > >
> > >  static struct tst_test test = {
> > >
> >
> > If this still does not work as expected, then we need plus additional
> > policy to shrink the pollute memory size.
> >
> > -       tst_pollute_memory(TESTMEM, 0x41);
> > +       tst_pollute_memory(TESTMEM * 9/10, 0x41);
> This works.
>

Can you post more info about the test output?

One concern I have is that the swap is not being triggered
with shrinking the pollute memory.

And also it'd be great to have `free -h` `cat /proc/meminfo` `lscpu` `uname
-r` info.


-- 
Regards,
Li Wang


More information about the ltp mailing list