* [PATCH v2 0/2] selftests/mm: run the XFS-backed THP tests when xfs is a module
@ 2026-10-17 15:07 Qiliang Yuan
2026-10-17 15:07 ` [PATCH v2 1/2] selftests/mm: track the modules run_vmtests.sh loads Qiliang Yuan
2026-10-17 15:07 ` [PATCH v2 2/2] selftests/mm: load xfs before checking for it in run_vmtests.sh Qiliang Yuan
0 siblings, 2 replies; 5+ messages in thread
From: Qiliang Yuan @ 2026-10-17 15:07 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Shuah Khan, Zi Yan
Cc: linux-mm, linux-kselftest, linux-kernel, Qiliang Yuan
run_vmtests.sh only creates the XFS that "khugepaged all:file" and the
pagecache folio split cases of split_huge_page_test need when xfs is
already registered, so with xfs built as a module and not loaded yet
those tests are all skipped.
Patch 1 adds load_module(), which records the modules the script loads
and unloads them again before it exits, and moves hwpoison_inject over
to it. Patch 2 loads xfs through it.
Signed-off-by: Qiliang Yuan <odys.yuan@gmail.com>
---
V1 -> V2:
- Add load_module() and unload what the script loaded on exit (Zi Yan)
- Unload xfs again after the run (Zi Yan)
- Rebase onto mainline
v1: https://lore.kernel.org/r/20261016-bug-selftests-mm-run-vmtests-xfs-modprobe-v1-1-b97dfc79e97a@gmail.com
---
Qiliang Yuan (2):
selftests/mm: track the modules run_vmtests.sh loads
selftests/mm: load xfs before checking for it in run_vmtests.sh
tools/testing/selftests/mm/run_vmtests.sh | 33 ++++++++++++++++++++++---------
1 file changed, 24 insertions(+), 9 deletions(-)
---
base-commit: 90201351a862182bdabfc1ad1c97b1e1b6ed5931
change-id: 20261016-bug-selftests-mm-run-vmtests-xfs-modprobe-de0697d4c4e9
Best regards,
--
Qiliang Yuan <odys.yuan@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] selftests/mm: track the modules run_vmtests.sh loads
2026-10-17 15:07 [PATCH v2 0/2] selftests/mm: run the XFS-backed THP tests when xfs is a module Qiliang Yuan
@ 2026-10-17 15:07 ` Qiliang Yuan
2026-10-28 8:02 ` Jose A. Perez de Azpillaga
2026-10-17 15:07 ` [PATCH v2 2/2] selftests/mm: load xfs before checking for it in run_vmtests.sh Qiliang Yuan
1 sibling, 1 reply; 5+ messages in thread
From: Qiliang Yuan @ 2026-10-17 15:07 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Shuah Khan, Zi Yan
Cc: linux-mm, linux-kselftest, linux-kernel, Qiliang Yuan
run_vmtests.sh loads hwpoison_inject for the memory-failure test when it
is not there yet, remembers that in a variable local to run_test() and
unloads the module right after the test.
The thp tests need xfs loaded in the same way, and repeating the load,
the bookkeeping and the unload for every module that some test needs
does not scale.
Add load_module(), which loads a module unless it is already present
and records it, and unload every recorded module, in reverse order,
before the script exits. Use it for hwpoison_inject.
Signed-off-by: Qiliang Yuan <odys.yuan@gmail.com>
---
tools/testing/selftests/mm/run_vmtests.sh | 31 +++++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
index d09f9f6a384ee..56f5416681da7 100755
--- a/tools/testing/selftests/mm/run_vmtests.sh
+++ b/tools/testing/selftests/mm/run_vmtests.sh
@@ -177,11 +177,30 @@ pretty_name() {
echo "$*" | sed -e 's/^\(bash \)\?\.\///'
}
+# Modules this script loaded, unloaded again before it exits
+LOADED_MODULES=()
+
+# Usage: load_module [module]
+load_module() {
+ if [ -d "/sys/module/$1" ]; then
+ return 0
+ fi
+ modprobe -q "$1" || return 1
+ LOADED_MODULES+=("$1")
+}
+
+unload_modules() {
+ local i
+
+ for (( i = ${#LOADED_MODULES[@]} - 1; i >= 0; i-- )); do
+ modprobe -r -q "${LOADED_MODULES[i]}"
+ done
+}
+
# Usage: run_test [test binary] [arbitrary test arguments...]
run_test() {
if test_selected ${CATEGORY}; then
local skip=0
- local LOADED_HWPOISON_INJECT_MOD=0
# On memory constrainted systems some tests can fail to allocate hugepages.
# perform some cleanup before the test for a higher success rate.
@@ -207,8 +226,7 @@ run_test() {
| tap_prefix
skip=1
else
- modprobe hwpoison_inject > /dev/null 2>&1
- LOADED_HWPOISON_INJECT_MOD=1
+ load_module hwpoison_inject
if [ ! -d "$HWPOISON_DIR" ]; then
echo "hwpoison debugfs interface not present" \
| tap_prefix
@@ -231,11 +249,6 @@ run_test() {
local ret=${PIPESTATUS[0]}
fi
- # Unload hwpoison_inject if we loaded it
- if [ "${LOADED_HWPOISON_INJECT_MOD}" = "1" ]; then
- modprobe -r hwpoison_inject > /dev/null 2>&1
- fi
-
count_total=$(( count_total + 1 ))
if [ $ret -eq 0 ]; then
count_pass=$(( count_pass + 1 ))
@@ -465,4 +478,6 @@ CATEGORY="memory-failure" run_test ./memory-failure
echo "SUMMARY: PASS=${count_pass} SKIP=${count_skip} FAIL=${count_fail}" | tap_prefix
echo "1..${count_total}" | tap_output
+unload_modules
+
exit $exitcode
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] selftests/mm: load xfs before checking for it in run_vmtests.sh
2026-10-17 15:07 [PATCH v2 0/2] selftests/mm: run the XFS-backed THP tests when xfs is a module Qiliang Yuan
2026-10-17 15:07 ` [PATCH v2 1/2] selftests/mm: track the modules run_vmtests.sh loads Qiliang Yuan
@ 2026-10-17 15:07 ` Qiliang Yuan
2026-10-28 8:13 ` Jose A. Perez de Azpillaga
1 sibling, 1 reply; 5+ messages in thread
From: Qiliang Yuan @ 2026-10-17 15:07 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Shuah Khan, Zi Yan
Cc: linux-mm, linux-kselftest, linux-kernel, Qiliang Yuan
run_vmtests.sh creates a loop-mounted XFS for "khugepaged all:file" and
for the pagecache folio split cases of split_huge_page_test, since
tmpfs does not give them large pagecache folios.
It only does so when xfs already shows up in /proc/filesystems. When
xfs is built as a module that is not loaded yet, the check fails, no
XFS is created, "khugepaged all:file" is reported as skipped and every
pagecache folio split case of split_huge_page_test is skipped with "No
large pagecache folio generated".
Load xfs with load_module() when it is not registered yet, so that it
is unloaded again once the script is done. "run_vmtests.sh -t thp" with
xfs built as a module and not loaded:
before after
skipped tests 1 0
skipped split_huge_page_test cases 43 0
xfs loaded after the run no no
Fixes: fc4d182316bd ("mm: huge_memory: enable debugfs to split huge pages to any order")
Signed-off-by: Qiliang Yuan <odys.yuan@gmail.com>
---
tools/testing/selftests/mm/run_vmtests.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
index 56f5416681da7..ba77fae5df4f2 100755
--- a/tools/testing/selftests/mm/run_vmtests.sh
+++ b/tools/testing/selftests/mm/run_vmtests.sh
@@ -428,7 +428,7 @@ CATEGORY="thp" run_test ./khugepaged -c 4 mthp_khugepaged:anon
# Try to create XFS if not provided
if [ -z "${SPLIT_HUGE_PAGE_TEST_XFS_PATH}" ]; then
if test_selected "thp"; then
- if grep xfs /proc/filesystems &>/dev/null; then
+ if grep -q xfs /proc/filesystems || load_module xfs; then
XFS_IMG=$(mktemp /tmp/xfs_img_XXXXXX)
SPLIT_HUGE_PAGE_TEST_XFS_PATH=$(mktemp -d /tmp/xfs_dir_XXXXXX)
truncate -s 314572800 ${XFS_IMG}
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] selftests/mm: track the modules run_vmtests.sh loads
2026-10-17 15:07 ` [PATCH v2 1/2] selftests/mm: track the modules run_vmtests.sh loads Qiliang Yuan
@ 2026-10-28 8:02 ` Jose A. Perez de Azpillaga
0 siblings, 0 replies; 5+ messages in thread
From: Jose A. Perez de Azpillaga @ 2026-10-28 8:02 UTC (permalink / raw)
To: Qiliang Yuan, Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Shuah Khan, Zi Yan
Cc: linux-mm, linux-kselftest, linux-kernel
On 10/17/26 5:07 PM, Qiliang Yuan wrote:
[snip]
> +# Usage: load_module [module]
> +load_module() {
> + if [ -d "/sys/module/$1" ]; then
> + return 0
> + fi
nice, this also stops it from unloading a hwpoison_inject it didn't load.
tested it on x86_64 in qemu with lockdep and DEBUG_VM, with
hwpoison_inject as a module. LGTM so:
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Tested-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
--
cheers,
jose a. p-a
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] selftests/mm: load xfs before checking for it in run_vmtests.sh
2026-10-17 15:07 ` [PATCH v2 2/2] selftests/mm: load xfs before checking for it in run_vmtests.sh Qiliang Yuan
@ 2026-10-28 8:13 ` Jose A. Perez de Azpillaga
0 siblings, 0 replies; 5+ messages in thread
From: Jose A. Perez de Azpillaga @ 2026-10-28 8:13 UTC (permalink / raw)
To: Qiliang Yuan, Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Shuah Khan, Zi Yan
Cc: linux-mm, linux-kselftest, linux-kernel
On 10/17/26 5:07 PM, Qiliang Yuan wrote:
> run_vmtests.sh creates a loop-mounted XFS for "khugepaged all:file" and
> for the pagecache folio split cases of split_huge_page_test, since
> tmpfs does not give them large pagecache folios.
>
> It only does so when xfs already shows up in /proc/filesystems. When
> xfs is built as a module that is not loaded yet, the check fails, no
> XFS is created, "khugepaged all:file" is reported as skipped and every
> pagecache folio split case of split_huge_page_test is skipped with "No
> large pagecache folio generated".
>
> Load xfs with load_module() when it is not registered yet, so that it
> is unloaded again once the script is done. "run_vmtests.sh -t thp" with
> xfs built as a module and not loaded:
>
> before after
> skipped tests 1 0
> skipped split_huge_page_test cases 43 0
> xfs loaded after the run no no
>
> Fixes: fc4d182316bd ("mm: huge_memory: enable debugfs to split huge pages to any order")
> Signed-off-by: Qiliang Yuan <odys.yuan@gmail.com>
> ---
> tools/testing/selftests/mm/run_vmtests.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
> index 56f5416681da7..ba77fae5df4f2 100755
> --- a/tools/testing/selftests/mm/run_vmtests.sh
> +++ b/tools/testing/selftests/mm/run_vmtests.sh
> @@ -428,7 +428,7 @@ CATEGORY="thp" run_test ./khugepaged -c 4 mthp_khugepaged:anon
> # Try to create XFS if not provided
> if [ -z "${SPLIT_HUGE_PAGE_TEST_XFS_PATH}" ]; then
> if test_selected "thp"; then
> - if grep xfs /proc/filesystems &>/dev/null; then
> + if grep -q xfs /proc/filesystems || load_module xfs; then
doesn't this also match selinuxfs? with SELinux on, xfs is still loaded
after the run. would grep -qw be enough?
also, needs a rebase, 6593a15af108 ("selftests/mm: skip khugepaged file
tests if mkfs.xfs is unavailable") reworked these lines.
--
cheers,
jose a. p-a
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-28 8:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-17 15:07 [PATCH v2 0/2] selftests/mm: run the XFS-backed THP tests when xfs is a module Qiliang Yuan
2026-10-17 15:07 ` [PATCH v2 1/2] selftests/mm: track the modules run_vmtests.sh loads Qiliang Yuan
2026-10-28 8:02 ` Jose A. Perez de Azpillaga
2026-10-17 15:07 ` [PATCH v2 2/2] selftests/mm: load xfs before checking for it in run_vmtests.sh Qiliang Yuan
2026-10-28 8:13 ` Jose A. Perez de Azpillaga
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®