From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Dev Jain <dev.jain@arm.com>,
Jaeyeon Lee <jaeyeon.lee.dev@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Shuah Khan <shuah@kernel.org>
Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftests/mm: khugepaged: skip swap tests when swap is unavailable
Date: Thu, 16 Jul 2026 13:20:45 +0200 [thread overview]
Message-ID: <0c278b69-3ecd-4ec3-b418-dea84e043732@kernel.org> (raw)
In-Reply-To: <6c474ce7-8f1d-4e85-8587-8a60983cec03@arm.com>
On 7/15/26 16:47, Dev Jain wrote:
>
>
> On 15/07/26 7:39 pm, David Hildenbrand (Arm) wrote:
>> On 7/15/26 15:34, Jaeyeon Lee wrote:
>>> The collapse_swapin_single_pte and collapse_max_ptes_swap tests use
>>> MADV_PAGEOUT to swap out pages before verifying khugepaged collapse
>>> behavior. On systems without swap configured, MADV_PAGEOUT succeeds
>>> but the pages are not actually swapped out, so check_swap() returns
>>> false and the tests report a failure.
>>>
>>> These tests cannot run meaningfully without swap, so a missing swap
>>> area is an environment limitation rather than a test failure. Detect
>>> the absence of swap via /proc/swaps and skip the affected tests
>>> instead of failing them.
>>>
>>> Signed-off-by: Jaeyeon Lee <jaeyeon.lee.dev@gmail.com>
>>> ---
>>> tools/testing/selftests/mm/khugepaged.c | 25 +++++++++++++++++++++++++
>>> 1 file changed, 25 insertions(+)
>>>
>>> diff --git a/tools/testing/selftests/mm/khugepaged.c b/tools/testing/selftests/mm/khugepaged.c
>>> index 10e8dedcb087..f9b4ebe733ce 100644
>>> --- a/tools/testing/selftests/mm/khugepaged.c
>>> +++ b/tools/testing/selftests/mm/khugepaged.c
>>> @@ -100,6 +100,22 @@ static void skip(const char *msg)
>>> exit_status = KSFT_SKIP;
>>> }
>>>
>>> +static bool swap_available(void)
>>> +{
>>> + char buf[256];
>>> + bool ret;
>>> + FILE *fp = fopen("/proc/swaps", "r");
>>> +
>>> + if (!fp)
>>> + return false;
>>> +
>>> + fgets(buf, sizeof(buf), fp);
>>> + ret = !!fgets(buf, sizeof(buf), fp);
>>> +
>>> + fclose(fp);
>>> + return ret;
>>> +}
>>> +
>>
>> That doesn't mean that swapout will succeed.
>>
>> Take a look at cow.c where we use pagemap_is_swapped() after MADV_PAGEOUT.
>
> That suffers from the reverse problem - in case of a real swap bug, cow.c
> will skip the test and anyone running the test won't bother.
Yes, because there could be other reasons why MADV_PAGEOUT would not be
successful (speculative page references, out of swap space).
>
> I think this patch idea is reasonable, we need a way to say "swap definitely
> won't succeed because there is no swap device, so skip" vs "swap failed,
> need to dig in!" .
I would not pack a "let's test if swapping in the system even works" into a
khugeapged test.
I think we can reasonably assume here "swap subsystem is not completely broken".
And if we want to check for that, have a separate test that stresses swapping,
if available.
--
Cheers,
David
next prev parent reply other threads:[~2026-07-16 11:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 13:34 Jaeyeon Lee
2026-07-15 14:09 ` David Hildenbrand (Arm)
2026-07-15 14:47 ` Dev Jain
2026-07-16 11:20 ` David Hildenbrand (Arm) [this message]
2026-07-16 13:45 ` Jaeyeon Lee
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=0c278b69-3ecd-4ec3-b418-dea84e043732@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=dev.jain@arm.com \
--cc=jaeyeon.lee.dev@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shuah@kernel.org \
/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
Powered by JetHome