Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Muhammad Usama Anjum <usama.anjum@arm.com>
To: Kiryl Shutsemau <kirill@shutemov.name>,
	akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org,
	nico.pache@linux.dev
Cc: usama.anjum@arm.com, baolin.wang@linux.alibaba.com,
	baohua@kernel.org, dev.jain@arm.com, hughd@google.com,
	lance.yang@linux.dev, liam@infradead.org, mhocko@suse.com,
	rppt@kernel.org, ryan.roberts@arm.com, shuah@kernel.org,
	surenb@google.com, usama.arif@linux.dev, vbabka@kernel.org,
	ziy@nvidia.com, agordeev@linux.ibm.com, linux-mm@kvack.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	kas@kernel.org
Subject: Re: [PATCH v2 00/17] selftests/mm: improve khugepaged coverage
Date: Tue, 11 Aug 2026 12:40:51 +0100	[thread overview]
Message-ID: <e1364571-376a-40c1-937c-40f68b06b09d@arm.com> (raw)
In-Reply-To: <20260807113647.3744609-1-kirill@shutemov.name>

On 07/08/2026 12:36 pm, Kiryl Shutsemau wrote:
> From: "Kiryl Shutsemau (Meta)" <kas@kernel.org>
> 
> mTHP collapse went in for 7.2 with no functional selftest coverage. Every
> khugepaged collapse case is PMD-shaped, down to the detection: it reads
> smaps AnonHugePages, which cannot see anything below the PMD order.
> 
> I am also reworking khugepaged's collapse mechanism, and that wants a suite
> worth trusting before the mechanism changes underneath it. Nothing here
> depends on the rework: everything passes on an unmodified kernel and
> documents what khugepaged already does.
> 
> This version sits on top of Baolin's anon mTHP collapse selftests [1], now
> in mm-new. His mthp_khugepaged context and per-order detection are what the
> new cases need, so they go in there rather than bringing their own.
> 
> Four existing cases fail on the environment rather than on the kernel:
> 
>  - The collapse wait is a fixed three seconds, whatever a huge page costs
>    to build. Scale it with the PMD size.
> 
>  - collapse_compound_extreme wants a 512M folio from the fault path. Skip
>    it where the PMD is that large.
> 
>  - The page cache caps folio order below the PMD order where a PMD is 512M,
>    so nothing can hold a PMD-sized page cache folio. Skip the shmem and
>    file cases there.
> 
>  - The swap cases ask a best-effort MADV_PAGEOUT for an exact swap count.
>    Ask again before calling it a failure.
> 
> This is why the suite now runs on arm64 with 64K pages.
> 
> Then the new coverage:
> 
>  - Folio-order helpers in vm_util, and folio_order_check to validate them
>    against the kernel before any collapse test trusts them.
> 
>  - Four order-parameterized anon collapse cases, plus mixed sources by
>    source order, at every supported order by default.
> 
>  - A shared-source write race: a co-sharer writing throughout a collapse
>    and the collapsing side must not see each other's pages.
> 
>  - khugepaged_full_pass(), which steps the daemon one scan at a time
>    through the sysfs wake path, and khugepaged_sync_check to hold it to
>    exactly one attributed collapse per step.
> 
>  - khugepaged_race, racing faults, MADV_DONTNEED, pins, fork and mremap
>    against collapse, checked by content and by KASAN and lockdep.
> 
> Tested on mm-new (8086604be973), with KASAN, lockdep, DEBUG_VM and
> page_table_check, in 16G guests:
> 
>   x86-64 4K     190 pass, 1 skip, 0 fail
>   arm64 64K     228 pass, 5 skip, 0 fail
> 
> The skips are structural: mixed sources declines at the smallest order, and
> at 64K collapse_compound_extreme and the shmem components skip as above.
I've tested them on arm64 vm and more tests are passing instead of getting
skipped. Hence:

Tested-by: Muhammad Usama Anjum <usama.anjum@arm.com>

> 
> Changes since v1:
> 
>  - Rebased onto [1] (Baolin Wang), which this overlapped and which is in
>    mm-new now, so this applies on top of it. This series' own -o mode is
>    gone in favour of his context.
>  - A plain ./khugepaged and ./khugepaged_race now run everything they can:
>    every supported order, and every mode, occupancy and pressure axis.  The
>    options only narrow that down (Mike Rapoport).
>  - The fixes to existing cases come first, then the infrastructure and the
>    new tests, each next to what it validates (Mike Rapoport).
>  - The completion barrier helper comes before the tests that use it, so no
>    case carries a throwaway implementation of it (Mike Rapoport).
>  - Changelogs and comments rewritten to be read rather than parsed
>    (Mike Rapoport).
>  - One new patch: retry the swapout, which is what made
>    collapse_max_ptes_swap flaky at 64K.
>  - Dropped the swap-skip patch, an equivalent has landed
>    (Alexander Gordeev).
>  - Review fixes: masked failures, system state left behind on bail-out
>    paths, arguments taken on trust (Sashiko).
> 
> [1] https://lore.kernel.org/all/cover.1785985999.git.baolin.wang@linux.alibaba.com
> 
> Kiryl Shutsemau (Meta) (17):
>   selftests/mm: skip collapse_compound_extreme where the PMD is too
>     large
>   selftests/mm: scale khugepaged's collapse wait with the PMD size
>   selftests/mm: skip khugepaged page cache cases without a PMD folio
>   selftests/mm: retry the swapout the khugepaged swap cases rely on
>   selftests/mm: move is_backed_by_folio() into vm_util
>   selftests/mm: add folio-order check for address ranges
>   selftests/mm: add folio-order detection self-check
>   selftests/mm: add khugepaged completion barrier helper
>   selftests/mm: add order-parameterized khugepaged collapse cases
>   selftests/mm: parameterize the mixed-source collapse case by source
>     order
>   selftests/mm: cover a shared-source collapse write race
>   selftests/mm: run every supported collapse order by default
>   selftests/mm: verify synchronous khugepaged driving is attributable
>   selftests/mm: add khugepaged race harness
>   selftests/mm: race collapse of windows with holes
>   selftests/mm: add memory-pressure threads to the khugepaged race
>     harness
>   selftests/mm: zap whole PTE tables in the khugepaged race harness
> 
>  tools/testing/selftests/mm/Makefile           |   3 +
>  .../testing/selftests/mm/folio_order_check.c  | 137 +++++
>  tools/testing/selftests/mm/hmm-tests.c        |   1 -
>  .../testing/selftests/mm/hugepage_settings.c  |  72 ++-
>  .../testing/selftests/mm/hugepage_settings.h  |   3 +
>  tools/testing/selftests/mm/khugepaged.c       | 466 +++++++++++++-
>  tools/testing/selftests/mm/khugepaged_race.c  | 571 ++++++++++++++++++
>  .../selftests/mm/khugepaged_sync_check.c      | 217 +++++++
>  tools/testing/selftests/mm/run_vmtests.sh     |   8 +-
>  .../selftests/mm/split_huge_page_test.c       |  62 --
>  tools/testing/selftests/mm/vm_util.c          | 145 +++++
>  tools/testing/selftests/mm/vm_util.h          |  10 +
>  12 files changed, 1599 insertions(+), 96 deletions(-)
>  create mode 100644 tools/testing/selftests/mm/folio_order_check.c
>  create mode 100644 tools/testing/selftests/mm/khugepaged_race.c
>  create mode 100644 tools/testing/selftests/mm/khugepaged_sync_check.c
> 
> 
> base-commit: 8086604be9733378461a5534c39cb72635226b23

-- 
Thanks,
Usama



      parent reply	other threads:[~2026-08-11 11:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07 11:36 [PATCH v2 00/17] selftests/mm: improve khugepaged coverage Kiryl Shutsemau
2026-08-07 11:36 ` [PATCH v2 01/17] selftests/mm: skip collapse_compound_extreme where the PMD is too large Kiryl Shutsemau
2026-08-07 11:36 ` [PATCH v2 02/17] selftests/mm: scale khugepaged's collapse wait with the PMD size Kiryl Shutsemau
2026-08-07 11:36 ` [PATCH v2 03/17] selftests/mm: skip khugepaged page cache cases without a PMD folio Kiryl Shutsemau
2026-08-07 11:36 ` [PATCH v2 04/17] selftests/mm: retry the swapout the khugepaged swap cases rely on Kiryl Shutsemau
2026-08-07 11:36 ` [PATCH v2 05/17] selftests/mm: move is_backed_by_folio() into vm_util Kiryl Shutsemau
2026-08-07 11:36 ` [PATCH v2 06/17] selftests/mm: add folio-order check for address ranges Kiryl Shutsemau
2026-08-07 11:36 ` [PATCH v2 07/17] selftests/mm: add folio-order detection self-check Kiryl Shutsemau
2026-08-07 11:36 ` [PATCH v2 08/17] selftests/mm: add khugepaged completion barrier helper Kiryl Shutsemau
2026-08-07 11:36 ` [PATCH v2 09/17] selftests/mm: add order-parameterized khugepaged collapse cases Kiryl Shutsemau
2026-08-07 11:36 ` [PATCH v2 10/17] selftests/mm: parameterize the mixed-source collapse case by source order Kiryl Shutsemau
2026-08-07 11:36 ` [PATCH v2 11/17] selftests/mm: cover a shared-source collapse write race Kiryl Shutsemau
2026-08-07 11:36 ` [PATCH v2 12/17] selftests/mm: run every supported collapse order by default Kiryl Shutsemau
2026-08-07 11:36 ` [PATCH v2 13/17] selftests/mm: verify synchronous khugepaged driving is attributable Kiryl Shutsemau
2026-08-07 11:36 ` [PATCH v2 14/17] selftests/mm: add khugepaged race harness Kiryl Shutsemau
2026-08-07 11:36 ` [PATCH v2 15/17] selftests/mm: race collapse of windows with holes Kiryl Shutsemau
2026-08-07 11:36 ` [PATCH v2 16/17] selftests/mm: add memory-pressure threads to the khugepaged race harness Kiryl Shutsemau
2026-08-07 11:36 ` [PATCH v2 17/17] selftests/mm: zap whole PTE tables in " Kiryl Shutsemau
2026-08-10 12:58 ` [PATCH v2 00/17] selftests/mm: improve khugepaged coverage Alexander Gordeev
2026-08-11 11:40 ` Muhammad Usama Anjum [this message]

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=e1364571-376a-40c1-937c-40f68b06b09d@arm.com \
    --to=usama.anjum@arm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=hughd@google.com \
    --cc=kas@kernel.org \
    --cc=kirill@shutemov.name \
    --cc=lance.yang@linux.dev \
    --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=nico.pache@linux.dev \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=shuah@kernel.org \
    --cc=surenb@google.com \
    --cc=usama.arif@linux.dev \
    --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