[LTP] [PATCH v8] mremap07.c: New test for mremap() with MREMAP_DONTUNMAP

Li Wang wangli.ahau@gmail.com
Tue Apr 21 11:11:00 CEST 2026


Wei Gao <wegao@suse.com> wrote:

> On Mon, Apr 20, 2026 at 06:12:19PM +0800, Li Wang wrote:
> > Hi Wei,
> >
> > This is an excellent test design, but still few places need
> > refactoring in my opinion.
> >
> > Wei Gao via ltp <ltp@lists.linux.it> wrote:
> >
> > > --- a/configure.ac
> > > +++ b/configure.ac
> > > @@ -46,6 +46,7 @@ AC_CHECK_DECLS([MADV_MERGEABLE],,,[#include <sys/mman.h>])
> > >  AC_CHECK_DECLS([NFTA_CHAIN_ID, NFTA_VERDICT_CHAIN_ID],,,[#include <linux/netfilter/nf_tables.h>])
> > >  AC_CHECK_DECLS([PR_CAPBSET_DROP, PR_CAPBSET_READ],,,[#include <sys/prctl.h>])
> > >  AC_CHECK_DECLS([SEM_STAT_ANY],,,[#include <sys/sem.h>])
> > > +AC_CHECK_DECLS([MREMAP_DONTUNMAP],,,[#include <linux/mman.h>])
> >
> > I didn't go through all the previous discussion, but can we define
> > MREMAP_DONTUNMAP in the lapi/mmap.h then remove the .min_kver
> > and TST_TEST_TCONF?
>
> To handle older kernels without using .min_kver and TST_TEST_TCONF,
> we'd need to implement extra logic. Would it look something like the following?
>
> -       if (new_remap_addr == MAP_FAILED)
> +       if (new_remap_addr == MAP_FAILED) {
> +               if (errno == EINVAL)
> +                       tst_brk(TCONF | TERRNO, "mremap() with MREMAP_DONTUNMAP not supported");
> +
>                 tst_brk(TBROK | TERRNO, "mremap failed");
> +       }

Yes, that's usually how it should be. Could you post the complete code
snippet verifying this function?

Reference what you did in the past:
    b697cf0bd4ea275053288f18c093551e99571ea0


-- 
Regards,
Li Wang


More information about the ltp mailing list