[LTP] [PATCH v4] mmap22.c: Test for new MAP_DROPPABLE flag for mmap

Li Wang liwang@redhat.com
Wed May 14 14:44:00 CEST 2025


Jan Stancek <jstancek@redhat.com> wrote:

> > > I'll have a closer look and try manually. At first glance at test, I
> > > suspect compiler
> > > doing something clever for:
> > >                 for (;;)
> > >                         *(char *)malloc(page_size) = 'B';
> >
> > Probably,  -O2 is the default in LTP compiling.
> >
> > Or, you could also try disabling KSM when testing mmap22.c to see if it helps.
>
> In case of my VM, it looks like it's able to swap faster than what's
> needed to drop the allocation.
> With this I get PASS right away:
>
> diff --git a/testcases/kernel/syscalls/mmap/mmap22.c
> b/testcases/kernel/syscalls/mmap/mmap22.c
> index 0e589dfab..56fe412d1 100644
> --- a/testcases/kernel/syscalls/mmap/mmap22.c
> +++ b/testcases/kernel/syscalls/mmap/mmap22.c
> @@ -32,6 +32,7 @@ static void test_mmap(void)
>
>         cg_child = tst_cg_group_mk(tst_cg, "child");
>         SAFE_CG_PRINTF(tst_cg, "memory.max", "%d", MEM_LIMIT);
> +       SAFE_CG_PRINTF(tst_cg, "memory.swap.max", "%d", 1);

Why not set it to 0 to disable it completely?

I guess we need to do it separately for both Cgroup v1 and v2.
  - Cgroup-v1: set it to MEM_LIMIT.
  - Cgroup-v2: set it to 0.
FYI: https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/mem/oom/oom03.c#L33

Anyway, testing will be much faster with this patch.

--
Regards,
Li Wang



More information about the ltp mailing list