Re: [PATCH v2 05/53] selftests/mm: merge map_hugetlb into hugepage-mmap

Mike Rapoport
2026-04-25T09:29:16Z

On Fri, Apr 24, 2026 at 01:16:46PM -0400, Luiz Capitulino wrote:
> On 2026-04-18 06:54, Mike Rapoport wrote:
> > From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
> >
> > Both tests create a hugettlb mapping, fill it with data and verify the
> > data, the only difference is that one uses file-backed memory and another
> > one uses anonymous memory.
> >
> > Merge both tests into a single file.
> >
> > Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> > ---
> > tools/testing/selftests/mm/Makefile | 1 -
> > tools/testing/selftests/mm/hugepage-mmap.c | 112 ++++++++++++++++-----
> > tools/testing/selftests/mm/map_hugetlb.c | 88 ----------------
> > tools/testing/selftests/mm/run_vmtests.sh | 1 -
> > 4 files changed, 85 insertions(+), 117 deletions(-)
> > delete mode 100644 tools/testing/selftests/mm/map_hugetlb.c
> >
> > diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile
> > index cd24596cdd27..cbda989f6b6a 100644
> > --- a/tools/testing/selftests/mm/Makefile
> > +++ b/tools/testing/selftests/mm/Makefile
> > @@ -70,7 +70,6 @@ TEST_GEN_FILES += hugepage-vmemmap
> > TEST_GEN_FILES += khugepaged
> > TEST_GEN_FILES += madv_populate
> > TEST_GEN_FILES += map_fixed_noreplace
> > -TEST_GEN_FILES += map_hugetlb
> > TEST_GEN_FILES += map_populate
> > ifneq (,$(filter $(ARCH),arm64 riscv riscv64 x86 x86_64 loongarch32 loongarch64))
> > TEST_GEN_FILES += memfd_secret
> > diff --git a/tools/testing/selftests/mm/hugepage-mmap.c b/tools/testing/selftests/mm/hugepage-mmap.c
> > index d543419de040..f4fcc7c45875 100644
> > --- a/tools/testing/selftests/mm/hugepage-mmap.c
> > +++ b/tools/testing/selftests/mm/hugepage-mmap.c
> > @@ -15,6 +15,7 @@
> > #include <unistd.h>
> > #include <sys/mman.h>
> > #include <fcntl.h>
> > +#include "vm_util.h"
> > #include "kselftest.h"
> > #define LENGTH (256UL*1024*1024)
> > @@ -25,54 +26,111 @@ static void check_bytes(char *addr)
> > ksft_print_msg("First hex is %x\n", *((unsigned int *)addr));
> > }
> > -static void write_bytes(char *addr)
> > +static void write_bytes(char *addr, size_t length)
> > {
> > unsigned long i;
> > - for (i = 0; i < LENGTH; i++)
> > + for (i = 0; i < length; i++)
> > *(addr + i) = (char)i;
> > }
> > -static int read_bytes(char *addr)
> > +static bool verify_bytes(char *addr, size_t length)
> > {
> > unsigned long i;
> > check_bytes(addr);
> > - for (i = 0; i < LENGTH; i++)
> > - if (*(addr + i) != (char)i) {
> > - ksft_print_msg("Error: Mismatch at %lu\n", i);
> > - return 1;
> > - }
> > - return 0;
> > + for (i = 0; i < length; i++)
> > + if (*(addr + i) != (char)i)
> > + return false;
>
> Is there a good reason to drop the ksft_print_msg() call?

Probably not :)

> It looks like a good debugging information. I'd also add the address to
> it.

Sure.

--
Sincerely yours,
Mike.