<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">
+<br>
+static void setup(void)<br>
+{<br>
+ if (tst_hugepages < 1)<br>
+ tst_brk(TCONF, "Not enough hugepages for testing.");<br></blockquote><div><br></div><div><br></div><div><div class="gmail_default" style="font-size:small">If we needs at least 1 huge page for testing, the TST_NEEDS will</div><div class="gmail_default" style="font-size:small">be more useful than TST_REQUEST, and do not need to double</div><div class="gmail_default" style="font-size:small">check the hpage numbers anymore.</div><br></div><div><br></div><div><div class="gmail_default" style="font-size:small">TST_REQUEST:</div> It will try the best to reserve available huge pages and return the number<br> of available hugepages in tst_hugepages, which may be 0 if hugepages are<br> not supported at all.<br><br>TST_NEEDS:<br> This is an enforced requirement, LTP should strictly do hpages applying and<br> guarantee the 'HugePages_Free' no less than pages which makes that test can<br> use these specified numbers correctly. Otherwise, test exits with TCONF if<br> the attempt to reserve hugepages fails or reserves less than requested.<br><div class="gmail_default" style="font-size:small"></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">See: <a href="https://github.com/linux-test-project/ltp/blob/master/doc/c-test-api.txt#L2009">https://github.com/linux-test-project/ltp/blob/master/doc/c-test-api.txt#L2009</a></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>
+ hpage_size = SAFE_READ_MEMINFO("Hugepagesize:")*1024;<br>
+}<br>
+<br>
+static void cleanup(void)<br>
+{<br>
+ if (fd >= 0)<br>
+ SAFE_CLOSE(fd);<br>
+ umount2(Hopt, MNT_DETACH);<br>
+}<br>
+<br>
+static struct tst_test test = {<br>
+ .needs_root = 1,<br>
+ .needs_tmpdir = 1,<br>
+ .options = (struct tst_option[]) {<br>
+ {"v", &verbose, "Turns on verbose mode"},<br>
+ {"H:", &Hopt, "Location of hugetlbfs, i.e. -H /var/hugetlbfs"},<br>
+ {"s:", &nr_opt, "Set the number of the been allocated hugepages"},<br>
+ {}<br>
+ },<br>
+ .setup = setup,<br>
+ .cleanup = cleanup,<br>
+ .test_all = run_test,<br>
+ .hugepages = {1, TST_REQUEST},<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">^ TST_NEEDS</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></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>