<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Tarun Sahu <<a href="mailto:tsahu@linux.ibm.com">tsahu@linux.ibm.com</a>> wrote:<br></div></div><div class="gmail_quote"><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+static void run_test(void)<br>
+{<br>
+       int status;<br>
+       void *syncarea;<br>
+       volatile unsigned int *p;<br>
+       volatile unsigned int *trigger, *child_readback;<br>
+       int parent_readback;<br>
+       pid_t pid;<br>
+       struct sigaction sa = {<br>
+               .sa_sigaction = sigchld_handler,<br>
+               .sa_flags = SA_SIGINFO,<br>
+       };<br>
+<br>
+       /* Get a shared normal page for synchronization */<br>
+       if (verbose)<br>
+               tst_res(TINFO, "Mapping synchronization area..");<br>
+       syncarea = SAFE_MMAP(NULL, getpagesize(), PROT_READ|PROT_WRITE,<br>
+                       MAP_SHARED|MAP_ANONYMOUS, -1, 0);<br>
+       if (verbose)<br>
+               tst_res(TINFO, "done");<br>
+<br>
+       trigger = syncarea;<br>
+       *trigger = 0;<br>
+<br>
+       child_readback = trigger + 1;<br>
+       *child_readback = 0;<br>
+<br>
+       fd = SAFE_OPEN(hfile, O_RDWR | O_CREAT, 0600);<br>
+       SAFE_UNLINK(hfile);<br>
+<br>
+       if (verbose)<br>
+               tst_res(TINFO, "Mapping hugepage area...");<br>
+       p = SAFE_MMAP(NULL, hpage_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);<br></blockquote><div><br></div><div><br></div><div><div class="gmail_default" style="font-size:small">After roughly looking at those hpage testcases, almost each one</div><div class="gmail_default" style="font-size:small">requests the huge memory via mapping a file on hugetlbfs, which</div><div class="gmail_default" style="font-size:small">can work but quite don't have to.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">We can absolutely simplify them via `MAP_HUGETLB` to get expected</div><div class="gmail_default" style="font-size:small">size of huge memory for use.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Reference how hugemamp06.c does:</div><div class="gmail_default" style="font-size:small"><a href="https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/mem/hugetlb/hugemmap/hugemmap06.c#L71">https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/mem/hugetlb/hugemmap/hugemmap06.c#L71<br></a></div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+static void setup(void)<br>
+{<br>
+       int free_pages = SAFE_READ_MEMINFO("HugePages_Free:");<br>
+<br>
+       if (tst_hugepages < 2 || free_pages < 2)<br>
+               tst_brk(TCONF, "Not enough hugepages for testing.");<br></blockquote><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+       if (!Hopt)<br>
+               Hopt = tst_get_tmpdir();<br>
+       SAFE_MOUNT("none", Hopt, "hugetlbfs", 0, NULL);<br>
+<br>
+       snprintf(hfile, sizeof(hfile), "%s/ltp_hugetlbfile%d", Hopt, getpid());<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">If we go using MAP_HUGETLB above, those lines can be removed.</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+       hpage_size = SAFE_READ_MEMINFO("Hugepagesize:")*1024;<br>
+}<br></blockquote><div><br></div><div> </div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>