Message ID | 20220208132414.2852202-1-liwang@redhat.com |
---|---|
State | Superseded |
Headers | show |
Series | getrusage03: mlock the memory area in consume_mb | expand |
On Tue, Feb 8, 2022 at 9:24 PM Li Wang <liwang@redhat.com> wrote: > 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); > Hmm, seems using mlockall() will be better than mlock(). Because that locks all pages mapped into the address space of the calling process. (includes code, data, stack segment, shared libraries, etc). > 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 >
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);
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(+)