+ selftests-mm-khugepaged-skip-swap-tests-when-no-swap-available.patch added to mm-new branch
Andrew Morton <[email protected]> Tue, 04 Aug 2026 12:38:37 -0700
| Newsgroups | org.kernel.vger.mm-commits |
|---|---|
| Message-ID | <[email protected]> |
The patch titled
Subject: selftests/mm: khugepaged: skip swap tests when no swap available
has been added to the -mm mm-new branch. Its filename is
selftests-mm-khugepaged-skip-swap-tests-when-no-swap-available.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-mm-khugepaged-skip-swap-tests-when-no-swap-available.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Alexander Gordeev <[email protected]>
Subject: selftests/mm: khugepaged: skip swap tests when no swap available
Date: Tue, 4 Aug 2026 14:53:51 +0200
When no swap is configured, swap-related tests fail because
madvise(MADV_PAGEOUT) does not swap out pages. Add a helper function to
detect swap availability and skip these tests.
Link: https://lore.kernel.org/[email protected]
Signed-off-by: Alexander Gordeev <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Lorenzo Stoakes <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
---
tools/testing/selftests/mm/khugepaged.c | 33 ++++++++++++++++++++++
1 file changed, 33 insertions(+)
--- a/tools/testing/selftests/mm/khugepaged.c~selftests-mm-khugepaged-skip-swap-tests-when-no-swap-available
+++ a/tools/testing/selftests/mm/khugepaged.c
@@ -216,6 +216,25 @@ err_out:
return swap;
}
+static bool is_swap_available(unsigned long size)
+{
+ unsigned long swap_total = 0;
+ char buffer[256];
+ FILE *fp;
+
+ fp = fopen("/proc/meminfo", "r");
+ if (!fp)
+ return false;
+
+ while (fgets(buffer, sizeof(buffer), fp)) {
+ if (sscanf(buffer, "SwapTotal: %lu kB", &swap_total) == 1)
+ break;
+ }
+ fclose(fp);
+
+ return swap_total >= (size / 1024);
+}
+
static void *alloc_mapping(int nr)
{
void *p;
@@ -734,6 +753,13 @@ static void collapse_swapin_single_pte(s
{
void *p;
+ if (!is_swap_available(page_size)) {
+ ksft_print_msg("No swap available...");
+ skip("Skip");
+ ksft_test_result_skip("%s\n", __func__);
+ return;
+ }
+
p = ops->setup_area(1);
ops->fault(p, 0, hpage_pmd_size);
@@ -760,6 +786,13 @@ static void collapse_max_ptes_swap(struc
int max_ptes_swap = thp_read_num("khugepaged/max_ptes_swap");
void *p;
+ if (!is_swap_available((max_ptes_swap + 1) * page_size)) {
+ ksft_print_msg("No swap available...");
+ skip("Skip");
+ ksft_test_result_skip("%s\n", __func__);
+ return;
+ }
+
p = ops->setup_area(1);
ops->fault(p, 0, hpage_pmd_size);
_
Patches currently in -mm which might be from [email protected] are
mm-use-proper-pte-accessor-in-move_ptes.patch
selftests-mm-khugepaged-skip-swap-tests-when-no-swap-available.patch