<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 Tue, Feb 8, 2022 at 9:24 PM Li Wang <<a href="mailto:liwang@redhat.com">liwang@redhat.com</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">Seems it trying to test without swap happen to guarantee less<br>
disturbing for the ’->ru_maxrss‘ counting.<br>
<br>
Therefore add mlock() to prevent that memory allocated by consume_mb<br>
from being paged to the swap area.<br>
<br>
Signed-off-by: Li Wang <<a href="mailto:liwang@redhat.com" target="_blank">liwang@redhat.com</a>><br>
---<br>
testcases/kernel/syscalls/getrusage/getrusage03.h | 1 +<br>
1 file changed, 1 insertion(+)<br>
<br>
diff --git a/testcases/kernel/syscalls/getrusage/getrusage03.h b/testcases/kernel/syscalls/getrusage/getrusage03.h<br>
index f1bbe9be5..d46fdff85 100644<br>
--- a/testcases/kernel/syscalls/getrusage/getrusage03.h<br>
+++ b/testcases/kernel/syscalls/getrusage/getrusage03.h<br>
@@ -18,6 +18,7 @@ static void consume_mb(int consume_nr)<br>
<br>
size = consume_nr * 1024 * 1024;<br>
ptr = SAFE_MALLOC(size);<br>
+ mlock(ptr, size);<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Hmm, seems using mlockall() will be better than mlock().</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Because that locks all pages mapped into the address space of the calling process. </div><div class="gmail_default" style="font-size:small">(includes code, data, stack segment, shared libraries, etc).</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">
memset(ptr, 0, size);<br>
<br>
SAFE_FILE_LINES_SCANF("/proc/self/status", "VmSwap: %lu", &vmswap_size);<br>
-- <br>
2.31.1<br>
<br>
<br>
-- <br>
Mailing list info: <a href="https://lists.linux.it/listinfo/ltp" rel="noreferrer" target="_blank">https://lists.linux.it/listinfo/ltp</a><br>
</blockquote></div><br clear="all"><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>