From: Qiliang Yuan <odys.yuan@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>, Shuah Khan <shuah@kernel.org>,
Zi Yan <ziy@nvidia.com>
Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, Qiliang Yuan <odys.yuan@gmail.com>
Subject: [PATCH v2 1/2] selftests/mm: track the modules run_vmtests.sh loads
Date: Sat, 17 Oct 2026 23:07:12 +0800 [thread overview]
Message-ID: <20261017-bug-selftests-mm-run-vmtests-xfs-modprobe-v2-1-cbb36b014322@gmail.com> (raw)
In-Reply-To: <20261017-bug-selftests-mm-run-vmtests-xfs-modprobe-v2-0-cbb36b014322@gmail.com>
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
next prev parent reply other threads:[~2026-10-17 15:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2026-10-28 8:02 ` [PATCH v2 1/2] selftests/mm: track the modules run_vmtests.sh loads 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
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=20261017-bug-selftests-mm-run-vmtests-xfs-modprobe-v2-1-cbb36b014322@gmail.com \
--to=odys.yuan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=shuah@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=ziy@nvidia.com \
/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
all inboxes | Powered by JetHome®