Skip to contentSkip to conversation

Add process_madvise01 test

PATCH In review Andrea Cervesato 4 participants 8 messages Aug 29, 2023 – Sep 1, 2023

lore
Share & tools
lore
#0 lore raw

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
index 119710d63..64907ff53 100644
@@ -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
new file mode 100644
index 000000000..93d2640f7
@@ -0,0 +1 @@
+/process_madvise01
testcases/kernel/syscalls/process_madvise/Makefile new file +7 -0
new file mode 100644
index 000000000..ad5b66061
@@ -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
#1 lore raw

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
#2 lore raw

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
#3 lore raw

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 using MADV_PAGEOUT process_madvise01.c:62: TFAIL: Expect: Most of the memory has been swapped out: 0kB out of 1024kB

Summary:

Quoted 8 lines
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?

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
#4 lore raw
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 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

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_SWAP in the kernel .config
2) /proc/meminfo SwapFree: > $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
#5 lore raw

Hi!

Quoted 1 line

BTW I wonder if we should add 'vmstat' or 'cat /proc/meminfo' to ver_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
#6 lore raw

Hi!

Quoted 4 lines · Cyril Hrubis

Hi!

Quoted 1 line

BTW I wonder if we should add 'vmstat' or 'cat /proc/meminfo' to ver_linux.

cat /proc/meminfo sounds 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
#7 lore raw

Hi!

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

BTW I wonder if we should add 'vmstat' or 'cat /proc/meminfo' to ver_linux.

cat /proc/meminfo sounds 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.

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