From: Li Wang <liwang@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] getrusage03: mlock the memory area in consume_mb
Date: Tue, 8 Feb 2022 21:24:14 +0800 [thread overview]
Message-ID: <20220208132414.2852202-1-liwang@redhat.com> (raw)
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next reply other threads:[~2022-02-08 13:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-08 13:24 Li Wang [this message]
2022-02-08 13:36 ` [LTP] [PATCH] getrusage03: mlock the memory area in consume_mb Li Wang
2022-02-09 8:52 ` [LTP] [PATCH v2] getrusage03: mlock all address space for process calling consume_mb Li Wang
2022-02-16 9:54 ` Cyril Hrubis
2022-02-17 6:59 ` Li Wang
2022-02-17 15:19 ` Cyril Hrubis
2022-02-21 1:57 ` Li Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220208132414.2852202-1-liwang@redhat.com \
--to=liwang@redhat.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox