Re: [LTP] Question on hugemmap34

Wei Gao via ltp
2024-12-10T14:22:41Z

On Tue, Dec 10, 2024 at 02:25:06PM +0100, Jan Stancek wrote:
> On Tue, Dec 10, 2024 at 1:54 PM Jan Stancek <jstancek@redhat.com> wrote:
> >
> > On Tue, Dec 10, 2024 at 12:53 PM Wei Gao <wegao@suse.com> wrote:
> > >
> > > Hi ALL
> > >
> > > Is there any special config needed for this test case? Since the test failed with the following output on my test setup(opensuse15.5 with 6.12 kernel):
> > >
> > > tst_hugepage.c:84: TINFO: 1 hugepage(s) reserved
> > > tst_tmpdir.c:317: TINFO: Using /tmp/LTP_hugLSJb7r as tmpdir (btrfs filesystem)
> > > tst_test.c:1100: TINFO: Mounting none to /tmp/LTP_hugLSJb7r/hugetlbfs fstyp=hugetlbfs flags=0
> > > tst_test.c:1890: TINFO: LTP version: 20240930
> > > tst_test.c:1894: TINFO: Tested kernel: 6.12.3-lp155.11.g78b0030-vanilla #1 SMP Fri Dec 6 08:56:39 UTC 2024 (78b0030) ppc64le
> > > tst_test.c:1727: TINFO: Timeout per run is 0h 00m 30s
> > > tst_coredump.c:32: TINFO: Avoid dumping corefile for process(pid=6671)
> > > hugemmap34.c:88: TBROK: waitpid(0,0x7fffd8baa220,0) failed: ECHILD (10)
> >
> > There's missing exit() in do_child(), but that's not the only issue
> > with the test.
>
> Could you give this patch a try?
>
> diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap34.c
> b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap34.c
> index a7a88fbb2..818697be8 100644
> --- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap34.c
> +++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap34.c
> @@ -51,16 +51,23 @@ void do_child(void *stop_address)
> x = alloca(STACK_ALLOCATION_SIZE);
> *x = 1;
> } while ((void *)x >= stop_address);
> + exit(0);
> }
>
> static void run_test(void)
> {
> int pid, status;
> void *stack_address, *mmap_address, *heap_address, *map;
> + char tmp[128];
>
> stack_address = alloca(0);
> heap_address = sbrk(0);
>
> + tst_res(TINFO, "heap is at: %p", heap_address);
> + tst_res(TINFO, "stack is at: %p", stack_address);
> + sprintf(tmp, "cat /proc/%d/maps", getpid());
> + TST_EXP_PASS_SILENT(system(tmp));
> +
> /*
> * paranoia: start mapping two hugepages below the start of the stack,
> * in case the alignment would cause us to map over something if we
> @@ -70,6 +77,9 @@ static void run_test(void)
> do {
> map = mmap(mmap_address, hpage_size, PROT_READ|PROT_WRITE,
> MAP_SHARED | MAP_FIXED_NOREPLACE, fd, 0);
> + if (map == mmap_address)
> + break;
> +
> if (map == MAP_FAILED) {
> if (errno == ENOMEM) {
> tst_res(TCONF, "There is no enough
> memory in the system to do mmap");
> @@ -80,7 +90,12 @@ static void run_test(void)
> /*
> * if we get all the way down to the heap, stop trying
> */
> - } while (mmap_address <= heap_address);
> + } while (mmap_address > heap_address);
> +
> + if (map == MAP_FAILED)
> + tst_brk(TBROK, "failed to map hpage_size area before
> hitting heap");
> + tst_res(TINFO, "mapped at %p", mmap);
> +
> pid = SAFE_FORK();
> if (pid == 0)
> do_child(mmap_address);
>

Test will timeout if use default timeout so i do quick hack change for setup:
.forks_child = 1,
+ .max_runtime = 3600,

Test result:

make -C "/root/ltp/lib" -f "/root/ltp/lib/Makefile" all
make[1]: Entering directory '/root/ltp/lib'
GEN ltp-version.h
make[2]: Nothing to be done for 'all'.
make[2]: Nothing to be done for 'all'.
make[1]: Leaving directory '/root/ltp/lib'
hugemmap34.c:150:1: warning: missing initializer for field ‘needs_cmds’ of ‘struct tst_test’ [-Wmissing-field-initializers]
};
^
In file included from /root/ltp/testcases/kernel/mem/hugetlb/hugemmap/../lib/hugetlb.h:19:0,
from hugemmap34.c:24:
../../../../../include/tst_test.h:593:21: note: ‘needs_cmds’ declared here
const char *const *needs_cmds;
^~~~~~~~~~
CC testcases/kernel/mem/hugetlb/hugemmap/hugemmap34
tst_hugepage.c:84: TINFO: 1 hugepage(s) reserved
tst_tmpdir.c:317: TINFO: Using /tmp/LTP_hugkoiPEG as tmpdir (btrfs filesystem)
tst_test.c:1100: TINFO: Mounting none to /tmp/LTP_hugkoiPEG/hugetlbfs fstyp=hugetlbfs flags=0
tst_test.c:1890: TINFO: LTP version: 20240930
tst_test.c:1894: TINFO: Tested kernel: 6.12.3-lp155.11.g78b0030-vanilla #1 SMP Fri Dec 6 08:56:39 UTC 2024 (78b0030) ppc64le
tst_test.c:1727: TINFO: Timeout per run is 1h 00m 30s
hugemmap34.c:66: TINFO: heap is at: 0x1002af30000
hugemmap34.c:67: TINFO: stack is at: 0x7ffff97cab30
10000000-10040000 r-xp 00000000 00:29 11656 /root/ltp/testcases/kernel/mem/hugetlb/hugemmap/hugemmap34
10040000-10050000 r--p 00030000 00:29 11656 /root/ltp/testcases/kernel/mem/hugetlb/hugemmap/hugemmap34
10050000-10060000 rw-p 00040000 00:29 11656 /root/ltp/testcases/kernel/mem/hugetlb/hugemmap/hugemmap34
10060000-10070000 rw-p 00000000 00:00 0
1002af00000-1002af30000 rw-p 00000000 00:00 0 [heap]
7fff94b20000-7fff94d20000 r-xp 00000000 00:29 11464 /lib64/libc-2.31.so
7fff94d20000-7fff94d30000 r--p 001f0000 00:29 11464 /lib64/libc-2.31.so
7fff94d30000-7fff94d40000 rw-p 00200000 00:29 11464 /lib64/libc-2.31.so
7fff94d40000-7fff94d70000 r-xp 00000000 00:29 11482 /lib64/libpthread-2.31.so
7fff94d70000-7fff94d80000 r--p 00020000 00:29 11482 /lib64/libpthread-2.31.so
7fff94d80000-7fff94d90000 rw-p 00030000 00:29 11482 /lib64/libpthread-2.31.so
7fff94da0000-7fff94db0000 rw-s 00000000 00:17 9 /dev/shm/ltp_hugemmap34_7730 (deleted)
7fff94db0000-7fff94dd0000 r--p 00000000 00:00 0 [vvar]
7fff94dd0000-7fff94de0000 r-xp 00000000 00:00 0 [vdso]
7fff94de0000-7fff94e20000 r-xp 00000000 00:29 11457 /lib64/ld-2.31.so
7fff94e20000-7fff94e30000 r--p 00030000 00:29 11457 /lib64/ld-2.31.so
7fff94e30000-7fff94e40000 rw-p 00040000 00:29 11457 /lib64/ld-2.31.so
7ffff97a0000-7ffff97d0000 rw-p 00000000 00:00 0 [stack]
hugemmap34.c:97: TINFO: mapped at 0x7fff94c51e80
tst_coredump.c:32: TINFO: Avoid dumping corefile for process(pid=7752)
hugemmap34.c:105: TPASS: Child killed by SIGSEGV as expected

Summary:
passed 1
failed 0
broken 0
skipped 0
warnings 0