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 <[email protected]> > --- > 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. -- Cheers, David

