<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Richard,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Richard Palethorpe <<a href="mailto:rpalethorpe@suse.de" target="_blank">rpalethorpe@suse.de</a>> wrote:</div></div><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> --- a/testcases/kernel/syscalls/madvise/madvise06.c<br>
> +++ b/testcases/kernel/syscalls/madvise/madvise06.c<br>
> @@ -164,7 +164,7 @@ static int get_page_fault_num(void)<br>
>  <br>
>  static void test_advice_willneed(void)<br>
>  {<br>
> -     int loops = 50, res;<br>
> +     int loops = 100, res;<br>
>       char *target;<br>
>       long swapcached_start, swapcached;<br>
>       int page_fault_num_1, page_fault_num_2;<br>
> @@ -202,23 +202,32 @@ static void test_advice_willneed(void)<br>
>               "%s than %ld Kb were moved to the swap cache",<br>
>               res ? "more" : "less", PASS_THRESHOLD_KB);<br>
>  <br>
> -<br>
> -     TEST(madvise(target, PASS_THRESHOLD, MADV_WILLNEED));<br>
> +     loops = 100;<br>
> +     SAFE_FILE_LINES_SCANF("/proc/meminfo", "SwapCached: %ld", &swapcached_start);<br>
> +     TEST(madvise(target, pg_sz, MADV_WILLNEED));<br>
>       if (TST_RET == -1)<br>
>               tst_brk(TBROK | TTERRNO, "madvise failed");<br>
> +     do {<br>
> +             loops--;<br>
> +             usleep(100000);<br>
> +             if (stat_refresh_sup)<br>
> +                     SAFE_FILE_PRINTF("/proc/sys/vm/stat_refresh", "1");<br>
> +             SAFE_FILE_LINES_SCANF("/proc/meminfo", "SwapCached: %ld",<br>
> +                             &swapcached);<br>
> +     } while (swapcached < swapcached_start + pg_sz/1024 && loops > 0);<br>
>  <br>
>       page_fault_num_1 = get_page_fault_num();<br>
>       tst_res(TINFO, "PageFault(madvice / no mem access): %d",<br>
>                       page_fault_num_1);<br>
> -     dirty_pages(target, PASS_THRESHOLD);<br>
> +     dirty_pages(target, pg_sz);<br>
<br>
Adding the loop makes sense to me. However I don't understand why you<br>
have also switched from PASS_THRESHOLD to only a single page?<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">In the test, we use two checks combined to confirm the bug reproduces:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">  1. swap cached increasing less than PASS_THRESHOLD_KB</div><div class="gmail_default" style="font-size:small">  2. page_fault number large than expected</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">The 2. case is more easily get failed on kind of platforms and hard</div><div class="gmail_default" style="font-size:small">to count an average value for tolerating. So maybe we just reduce</div><div class="gmail_default" style="font-size:small">the page to one that would not affect the final result. Because we</div><div class="gmail_default" style="font-size:small">rely on both checks happening simultaneously then assume a bug.</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>
I guess calling MADV_WILLNEED on a single page is the least realistic<br>
scenario.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Okay, perhaps it's a step backward:).</div></div><div class="gmail_default" style="font-size:small"><br></div><div><div class="gmail_default" style="font-size:small">I was just thinking it is a regression test and if 1 page works to reproduce</div><div class="gmail_default" style="font-size:small">that (but more chunks of memory easily cause false positive), why not.</div></div><div class="gmail_default" style="font-size:small"><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 there is an issue with <span class="gmail_default" style="font-size:small"></span>PASS_THRESHOLD perhaps we could scale it based<br>
on page size?<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">This sounds acceptable too.</div><br></div><div><div class="gmail_default" style="font-size:small">How many pages do you think are proper, 100 or more?</div><div class="gmail_default" style="font-size:small">and, loosen the faulted-out numbers to 1/10 pages?</div></div><div><br></div></div><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>