[LTP] Question on hugemmap34
Jan Stancek
jstancek@redhat.com
Tue Dec 10 14:25:06 CET 2024
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);
More information about the ltp
mailing list