[LTP] [PATCH] mmap_24-1: Change vm.max_map_count if needed

Li Wang liwang@redhat.com
Fri May 9 06:03:15 CEST 2025


On Thu, May 8, 2025 at 1:53 AM Petr Vorel <pvorel@suse.cz> wrote:

> Hi Martin,
>
> > If vm.max_map_count system parameter is too high, mmap24-1 may get
> > killed by OOM. Set the parameter to a reasonable low value so that
> > mmap() quickly fails as expected.
>
> LGTM.
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>
> The only thing which bothers me is that writing /proc/sys/vm/max_map_count
> requires root. But I'm not sure if it's worth to add more code to check
> UID 0.
>
> @Li @Cyril: WDYT?
>

There are many ways to avoid OOM (e.g., overcommit_memory, oom_score_adj,
ulimit, etc.). However, the purpose of the mmap_24-1.c test is to exhaust
the virtual
address space and trigger ENOMEM.

Limiting vm.max_map_count may prevent OOM, but it changes the failure cause
to
hitting the map count limit, not actual address space exhaustion, which might
be away
from the test's intent.

I guess using setrlimit(RLIMIT_AS, ...) is more appropriate here, as it
enforces address
space limits while preserving the original test goal.

-- 
Regards,
Li Wang


More information about the ltp mailing list