Add process_madvise01 test
PATCH v3 1/1 Add process_madvise01 test
From: Andrea Cervesato <[email protected]>
This test checks process_madvise support for MADV_PAGEOUT. It tests if memory pages have been swapped out by looking at smaps information after reclaiming memory using MADV_PAGEOUT.
This test supports kernel 5.10 or later.
Implements: https://github.com/linux-test-project/ltp/issues/909
--- runtest/syscalls | 2 + .../syscalls/process_madvise/.gitignore | 1 + .../kernel/syscalls/process_madvise/Makefile | 7 + .../process_madvise/process_madvise.h | 101 ++++++++++++++ .../process_madvise/process_madvise01.c | 126 ++++++++++++++++++ 5 files changed, 237 insertions(+) create mode 100644 testcases/kernel/syscalls/process_madvise/.gitignore create mode 100644 testcases/kernel/syscalls/process_madvise/Makefile create mode 100644 testcases/kernel/syscalls/process_madvise/process_madvise.h create mode 100644 testcases/kernel/syscalls/process_madvise/process_madvise01.c
runtest/syscalls +2 -0
@@ -1046,6 +1046,8 @@ process_vm_readv03 process_vm_readv03 process_vm_writev01 process_vm01 process_vm_writev02 process_vm_writev02 +process_madvise01 process_madvise01 + prot_hsymlinks prot_hsymlinks dirtyc0w dirtyc0w dirtyc0w_shmem dirtyc0w_shmem
testcases/kernel/syscalls/process_madvise/.gitignore new file +1 -0
@@ -0,0 +1 @@ +/process_madvise01
testcases/kernel/syscalls/process_madvise/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2023 Linux Test Project, Inc. + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/process_madvise/process_madvise.h new file +101 -0
101 lines not on this page · raw message
testcases/kernel/syscalls/process_madvise/process_madvise01.c new file +126 -0
126 lines not on this page · raw message
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
testcases/kernel/syscalls/process_madvise/process_madvise01.c line 64
Quoted 3 lines
testcases/kernel/syscalls/process_madvise/process_madvise01.c new file +3
-0+ TST_EXP_EXPR(map_before.swap < map_after.swap, + "Most of the memory has been swapped out: %dkB out of %dkB", + map_after.swap,
Although it's unlikely that map_before.swap will be non-zero we should print the difference here, so I've changed this part to:
map_after.swap - map_before.swap
And pushed, thanks.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
HI Andrea, Cyril,
Quoted 11 lines
Hi!
testcases/kernel/syscalls/process_madvise/process_madvise01.c line 64
Quoted 3 lines
testcases/kernel/syscalls/process_madvise/process_madvise01.c new file +3
-0+ TST_EXP_EXPR(map_before.swap < map_after.swap, + "Most of the memory has been swapped out: %dkB out of %dkB", + map_after.swap,Although it's unlikely that map_before.swap will be non-zero we should print the difference here, so I've changed this part to:
map_after.swap - map_before.swap
And pushed, thanks.
FYI this new test is failing on current openSUSE Tumbleweed (kernel 6.4.12-1):
tst_test.c:1559: TINFO: Timeout per run is 0h 00m 30s
process_madvise01.c:38: TINFO: Allocate memory: 1048576 bytes process_madvise01.c:99: TINFO: Reclaim memory using MADV_PAGEOUT process_madvise01.c:62: TFAIL: Expect: Most of the memory has been swapped out: 0kB out of 1024kB
Summary:
passed 0 failed 1 broken 0 skipped 0
warnings 0
Test works well on current Debian unstable with kernel 6.4.11. Could you please have a look if it's a test or a kernel bug?
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 19 lines
Quoted 10 lines
testcases/kernel/syscalls/process_madvise/process_madvise01.c line 64
Quoted 3 lines
testcases/kernel/syscalls/process_madvise/process_madvise01.c new file +3
-0+ TST_EXP_EXPR(map_before.swap < map_after.swap, + "Most of the memory has been swapped out: %dkB out of %dkB", + map_after.swap,Although it's unlikely that map_before.swap will be non-zero we should print the difference here, so I've changed this part to:
map_after.swap - map_before.swap
And pushed, thanks.
FYI this new test is failing on current openSUSE Tumbleweed (kernel 6.4.12-1):
tst_test.c:1559: TINFO: Timeout per run is 0h 00m 30s
process_madvise01.c:38: TINFO: Allocate memory: 1048576 bytes process_madvise01.c:99: TINFO: Reclaim memory usingMADV_PAGEOUTprocess_madvise01.c:62: TFAIL: Expect: Most of the memory has been swapped out: 0kB out of 1024kBSummary:
Quoted 8 lines
passed 0 failed 1 broken 0 skipped 0warnings 0
Test works well on current Debian unstable with kernel 6.4.11. Could you please have a look if it's a test or a kernel bug?
Does the machine where it fails even have any swap?
I suppose that we should check for:
1) CONFIG_SWAP in the kernel .config
2) /proc/meminfo SwapFree: > $pagesize kB
I guess that the madvise kicks off the kernel swapper, but it may take some time for the memory to be actually swapped.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 26 lines
Hi!
Quoted 24 lines
Quoted 10 lines
testcases/kernel/syscalls/process_madvise/process_madvise01.c line 64
Quoted 3 lines
testcases/kernel/syscalls/process_madvise/process_madvise01.c new file +3
-0+ TST_EXP_EXPR(map_before.swap < map_after.swap, + "Most of the memory has been swapped out: %dkB out of %dkB", + map_after.swap,Although it's unlikely that map_before.swap will be non-zero we should print the difference here, so I've changed this part to:
map_after.swap - map_before.swap
And pushed, thanks.
FYI this new test is failing on current openSUSE Tumbleweed (kernel 6.4.12-1):
tst_test.c:1559: TINFO: Timeout per run is 0h 00m 30s
process_madvise01.c:38: TINFO: Allocate memory: 1048576 bytes process_madvise01.c:99: TINFO: Reclaim memory usingMADV_PAGEOUTprocess_madvise01.c:62: TFAIL: Expect: Most of the memory has been swapped out: 0kB out of 1024kBSummary:
passed 0 failed 1 broken 0 skipped 0warnings 0
Quoted 4 lines
Quoted 2 lines
Test works well on current Debian unstable with kernel 6.4.11. Could you please have a look if it's a test or a kernel bug?
Does the machine where it fails even have any swap?
I has CONFIG_SWAP=y, but vmstat reports si and so as 0. Therefore machine probably does not have any swap.
Quoted 4 lines
I suppose that we should check for:
1)
CONFIG_SWAPin the kernel .config
2)/proc/meminfoSwapFree: > $pagesize kB
+1.
Quoted 2 lines
I guess that the madvise kicks off the kernel swapper, but it may take some time for the memory to be actually swapped.
Sounds reasonable.
BTW I wonder if we should add 'vmstat' or 'cat /proc/meminfo' to ver_linux.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 1 line
BTW I wonder if we should add 'vmstat' or 'cat
/proc/meminfo' tover_linux.
cat /proc/meminfo sounds like a good idea.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 4 lines · Cyril Hrubis
Hi!
Quoted 1 line
BTW I wonder if we should add 'vmstat' or 'cat
/proc/meminfo' tover_linux.cat
/proc/meminfosounds like a good idea.
Maybe do we need a flag in tst_test to check if swap is available or not? Something similar to .min_mem_avail.
Andrea Cervesato
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
BTW I wonder if we should add 'vmstat' or 'cat
/proc/meminfo' tover_linux.cat
/proc/meminfosounds like a good idea.Maybe do we need a flag in
tst_testto check if swap is available or not? Something similar to .min_mem_avail.
Sounds reasonable to me, that way we would get the information propagated into metadata as well. Feel free to send a patch.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp