<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 22, 2020 at 10:31 PM Cyril Hrubis <<a href="mailto:chrubis@suse.cz" target="_blank">chrubis@suse.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail_default" style="font-size:small">...</span><br>
> +static void run(void)<br>
> +{<br>
> + ...<br>
> +<br>
> + if (tst_hugepages == test.request_hugepages)<br>
> + TEST(do_hpage_test);<br>
> + else<br>
> + ...<br>
> + ...<br>
> +}<br>
<br>
I guess that it would be more instructive to check the value in the test<br>
setup() here, because most of the test would just check if tst_hugepages<br>
has been set to expected value.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Yes, that will fit most situations.</div></div><div class="gmail_default"><br></div><div class="gmail_default" style="font-size:small"></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<span class="gmail_default" style="font-size:small">...</span><br>
> + if (access(PATH_HUGEPAGES, F_OK)) {<br>
> + tst_res(TCONF, "Huge page is not supported.");<br>
<br>
I guess that this is something the test has to decide, i.e. I wouldn't<br>
print anything here.<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">OK.</div><div class="gmail_default" style="font-size:small"></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> + tst_hugepages = 0;<br>
> + goto out;<br>
> + }<br>
> +<br>
> + tst_hugepages = hpages;<br>
> +<br>
> + SAFE_FILE_PRINTF("/proc/sys/vm/drop_caches", "3");<br>
<br>
Shouldn't we drop the caches only if MemAvailable is not present in<br>
/proc/meminfo?<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Yes, that's right theoretically. But the reason I moved it here is that the huge page reserving easily failed on a small RAM(1~2GB) system because of too much caches. </div></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 (FILE_LINES_SCANF("/proc/meminfo",<br>
> + "MemAvailable: %ld", &mem_avail)) {<br>
> + /*<br>
> + * Using "MemFree:" on kernel that doesn't have<br>
> + * "MemAvailable:" in Meminfo<br>
> + */<br>
> + tst_res(TINFO, "MemAvailable: not found in /proc/meminfo");<br>
> +<br>
> + mem_avail = SAFE_READ_MEMINFO("MemFree:");<br>
> + }<br>
> +<br>
> + max_hpages = mem_avail / SAFE_READ_MEMINFO("Hugepagesize:");<br>
> +<br>
> + if (hpages > max_hpages) {<br>
> + tst_res(TINFO, "Requested number(%d) of hugepages is too large, "<br>
> + "limiting to 80%% of the max hugepage count %ld",<br>
> + hpages, max_hpages);<br>
> + tst_hugepages = max_hpages * 0.8;<br>
<br>
Why 80%?<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">I choose(base on personal experience) this number to try again, to satisfy some test which does not need precise hpages can still run. </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Or, maybe let's remove this part, and limit LTP to make use of a precise number(the at least) of hpage in each test?</div><div class="gmail_default" style="font-size:small"></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Also I guess that we should check here that max_hpages * 0.8 > 1,<br>
otherwise there is no reason to continue.<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">Agreed.</div><div class="gmail_default" style="font-size:small"></div></div>-- <br><div dir="ltr"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>