[LTP] [PATCH v1] mmap21.c: Test for new MAP_DROPPABLE flag for mmap

Wei Gao wegao@suse.com
Fri Jan 3 14:54:29 CET 2025


On Tue, Dec 31, 2024 at 06:04:54PM +0800, Li Wang wrote:
> On Sat, Dec 28, 2024 at 9:32 PM Wei Gao via ltp <ltp@lists.linux.it> wrote:
> 
> > +
> > +       int *shared_var = SAFE_MMAP(NULL, sizeof(int), PROT_READ |
> > PROT_WRITE,
> > +                       MAP_SHARED | MAP_ANONYMOUS, -1, 0);
> > +
> > +       *shared_var = 0;
> > +
> > +       child = SAFE_FORK();
> > +       if (!child) {
> > +               for (;;) {
> > +                       *(char *)malloc(page_size) = 'B';
> > +                       if ((*shared_var) == 1)
> > +                               exit(0);
> >
> 
> If the parent process crashes, hangs, or fails to detect reclaimed
> pages, the child process will run indefinitely, potentially consuming
> system resources.
> 
> If it runs too long, add a timeout mechanism to terminate the child process.

After limit the test to an CGroup and set the memory.max = 256M(base your suggestion),
i suppose we do not need this timeout mechanism, since after i test in my env, when
the child run for ~3s, the system will trigger oom_memcg and kill the child.
What's your opinion?

> 
> This max_runtime is useless if we run the test on a large RAM system
> which likely takes too long to simulate the memory pressure.
> 
> We could limit the test to an CGroup and set the memory.max
> to 256MB, which can complete the mem hog quickly to finish.
> 
> 
> 
> > +};
> > --
> > 2.35.3
> >
> >
> > --
> > Mailing list info: https://lists.linux.it/listinfo/ltp
> >
> >
> 
> -- 
> Regards,
> Li Wang


More information about the ltp mailing list