[LTP] [PATCH] getrusage03: mlock the memory area in consume_mb

Li Wang liwang@redhat.com
Tue Feb 8 14:24:14 CET 2022


Seems it trying to test without swap happen to guarantee less
disturbing for the ’->ru_maxrss‘ counting.

Therefore add mlock() to prevent that memory allocated by consume_mb
from being paged to the swap area.

Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/syscalls/getrusage/getrusage03.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/testcases/kernel/syscalls/getrusage/getrusage03.h b/testcases/kernel/syscalls/getrusage/getrusage03.h
index f1bbe9be5..d46fdff85 100644
--- a/testcases/kernel/syscalls/getrusage/getrusage03.h
+++ b/testcases/kernel/syscalls/getrusage/getrusage03.h
@@ -18,6 +18,7 @@ static void consume_mb(int consume_nr)
 
 	size = consume_nr * 1024 * 1024;
 	ptr = SAFE_MALLOC(size);
+	mlock(ptr, size);
 	memset(ptr, 0, size);
 
 	SAFE_FILE_LINES_SCANF("/proc/self/status", "VmSwap: %lu", &vmswap_size);
-- 
2.31.1



More information about the ltp mailing list