All of lore.kernel.org
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Kiryl Shutsemau <kirill@shutemov.name>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>,
	Lorenzo Stoakes <ljs@kernel.org>,
	Nico Pache <nico.pache@linux.dev>
Cc: Barry Song <baohua@kernel.org>, Dev Jain <dev.jain@arm.com>,
	Hugh Dickins <hughd@google.com>,
	Lance Yang <lance.yang@linux.dev>,
	"Liam R. Howlett" <liam@infradead.org>,
	Michal Hocko <mhocko@suse.com>, Mike Rapoport <rppt@kernel.org>,
	Ryan Roberts <ryan.roberts@arm.com>,
	Shuah Khan <shuah@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Usama Arif <usama.arif@linux.dev>,
	Vlastimil Babka <vbabka@kernel.org>, Zi Yan <ziy@nvidia.com>,
	linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Kiryl Shutsemau (Meta)" <kas@kernel.org>
Subject: Re: [PATCH 00/16] selftests/mm: improve khugepaged coverage
Date: Mon, 3 Aug 2026 09:21:09 +0800	[thread overview]
Message-ID: <f9f01bc0-490b-4d06-85a0-e4693b80696c@linux.alibaba.com> (raw)
In-Reply-To: <20260802195254.1937477-1-kirill@shutemov.name>



On 8/3/26 3:52 AM, 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.

Yes, I’ve already sent out several versions of mTHP collapse test 
cases[1]. Not sure if you’ve seen my patchset, and it looks like some of 
our work overlaps :(

[1] 
https://lore.kernel.org/all/cover.1785564857.git.baolin.wang@linux.alibaba.com/

> 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.
> 
>   - vm_util grows folio-order helpers: is_backed_by_folio() moves out of
>     split_huge_page_test.c, and a range-level form asks whether every
>     order-aligned window of a range is backed by one folio of exactly that
>     order, mapped head to tail.
> 
>   - folio_order_check validates those helpers against the kernel for every
>     anon THP order it supports, before any collapse test trusts them.
> 
>   - khugepaged_full_pass() drives exactly one scan pass through the sysfs
>     wake path, so a barrier completes on the daemon's own cadence instead of
>     needing a short scan_sleep_millisecs.
> 
>   - khugepaged -o <order> runs order-parameterized anon collapse cases: a
>     full table, only the populated window, default max_ptes_none and
>     max_ptes_none=0, and collapse upward from smaller large folios. Any
>     order up to the PMD order, where the same cases baseline the PMD path.
> 
>   - khugepaged_race races two faulters, MADV_DONTNEED, transient FOLL_PIN,
>     fork and mremap against one of three collapse drivers: khugepaged a pass
>     at a time, khugepaged free-running, or a MADV_COLLAPSE loop. Every
>     racing page must read as its pattern or as zero. -z collapses
>     hole-bearing windows; -p adds pageout and compaction, the only threads
>     that elevate a source folio's refcount from the reclaim side. DEBUG_VM,
>     page_table_check, KASAN and lockdep are the other half of the oracle.
> 
>   - A shared-source write race pins the CoW isolation contract: a co-sharer
>     writing throughout a collapse must not see the collapsing side's pages.
> 
>   - Four tests fail on the environment rather than on the kernel: the
>     collapse wait is a fixed three seconds whatever a huge page costs to
>     build, collapse_compound_extreme wants a 512M page from the fault path,
>     the shmem cases want a PMD-order page cache folio the page cache caps
>     below, and the swap cases fail instead of skipping without swap. Scale
>     the wait (a 2M PMD is unchanged) and skip the other three. This is why
>     the suite now runs on arm64 with 64K pages.
> 
> Tested on mm-new (1dbd7c34bb92):
> 
>    x86-64 4K    105 pass, 3 skip, 0 fail
>    arm64 64K     87 pass, 7 skip, 0 fail
> 
> The skips are structural: sub-PMD cases decline at the PMD order and the
> mixed-source case at the smallest order, and on 64K pages
> collapse_compound_extreme and the shmem cases skip for the reasons above.
> 
> Kiryl Shutsemau (Meta) (16):
>    selftests/mm: move is_backed_by_folio() into vm_util
>    selftests/mm: add folio-order check for VA ranges
>    selftests/mm: add folio-order detection self-check
>    selftests/mm: add order-parameterized khugepaged collapse cases
>    selftests/mm: add khugepaged completion barrier helper
>    selftests/mm: add khugepaged race harness
>    selftests/mm: cover a shared-source collapse write race
>    selftests/mm: skip collapse_compound_extreme where the PMD is too
>      large
>    selftests/mm: skip khugepaged swap tests when no swap is configured
>    selftests/mm: verify synchronous khugepaged driving is attributable
>    selftests/mm: race-harness variant for permissive hole occupancy
>    selftests/mm: add memory-pressure threads to the khugepaged race
>      harness
>    selftests/mm: parameterize the mixed-source collapse case by source
>      order
>    selftests/mm: zap whole PTE tables in the khugepaged race harness
>    selftests/mm: scale khugepaged's collapse wait with the PMD size
>    selftests/mm: skip khugepaged shmem cases without a PMD page cache
>      folio
> 
>   tools/testing/selftests/mm/.gitignore         |   3 +
>   tools/testing/selftests/mm/Makefile           |   3 +
>   .../testing/selftests/mm/folio_order_check.c  | 138 +++++
>   .../testing/selftests/mm/hugepage_settings.c  |  66 ++-
>   .../testing/selftests/mm/hugepage_settings.h  |   2 +
>   tools/testing/selftests/mm/khugepaged.c       | 430 +++++++++++++++-
>   tools/testing/selftests/mm/khugepaged_race.c  | 483 ++++++++++++++++++
>   .../selftests/mm/khugepaged_sync_check.c      | 198 +++++++
>   tools/testing/selftests/mm/run_vmtests.sh     |  17 +
>   .../selftests/mm/split_huge_page_test.c       |  62 ---
>   tools/testing/selftests/mm/vm_util.c          | 157 ++++++
>   tools/testing/selftests/mm/vm_util.h          |   7 +
>   12 files changed, 1490 insertions(+), 76 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
> 



  parent reply	other threads:[~2026-08-03  1:21 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-02 19:52 [PATCH 00/16] selftests/mm: improve khugepaged coverage Kiryl Shutsemau
2026-08-02 19:52 ` [PATCH 01/16] selftests/mm: move is_backed_by_folio() into vm_util Kiryl Shutsemau
2026-08-03 11:04   ` Mike Rapoport
2026-08-02 19:52 ` [PATCH 02/16] selftests/mm: add folio-order check for VA ranges Kiryl Shutsemau
2026-08-03 11:04   ` Mike Rapoport
2026-08-02 19:52 ` [PATCH 03/16] selftests/mm: add folio-order detection self-check Kiryl Shutsemau
2026-08-03 11:04   ` Mike Rapoport
2026-08-02 19:52 ` [PATCH 04/16] selftests/mm: add order-parameterized khugepaged collapse cases Kiryl Shutsemau
2026-08-03 11:04   ` Mike Rapoport
2026-08-02 19:52 ` [PATCH 05/16] selftests/mm: add khugepaged completion barrier helper Kiryl Shutsemau
2026-08-03 11:04   ` Mike Rapoport
2026-08-02 19:52 ` [PATCH 06/16] selftests/mm: add khugepaged race harness Kiryl Shutsemau
2026-08-03 11:04   ` Mike Rapoport
2026-08-02 19:52 ` [PATCH 07/16] selftests/mm: cover a shared-source collapse write race Kiryl Shutsemau
2026-08-02 19:52 ` [PATCH 08/16] selftests/mm: skip collapse_compound_extreme where the PMD is too large Kiryl Shutsemau
2026-08-02 19:52 ` [PATCH 09/16] selftests/mm: skip khugepaged swap tests when no swap is configured Kiryl Shutsemau
2026-08-03 11:04   ` Mike Rapoport
2026-08-02 19:52 ` [PATCH 10/16] selftests/mm: verify synchronous khugepaged driving is attributable Kiryl Shutsemau
2026-08-02 19:52 ` [PATCH 11/16] selftests/mm: race-harness variant for permissive hole occupancy Kiryl Shutsemau
2026-08-02 19:52 ` [PATCH 12/16] selftests/mm: add memory-pressure threads to the khugepaged race harness Kiryl Shutsemau
2026-08-02 19:52 ` [PATCH 13/16] selftests/mm: parameterize the mixed-source collapse case by source order Kiryl Shutsemau
2026-08-02 19:52 ` [PATCH 14/16] selftests/mm: zap whole PTE tables in the khugepaged race harness Kiryl Shutsemau
2026-08-02 19:52 ` [PATCH 15/16] selftests/mm: scale khugepaged's collapse wait with the PMD size Kiryl Shutsemau
2026-08-02 19:52 ` [PATCH 16/16] selftests/mm: skip khugepaged shmem cases without a PMD page cache folio Kiryl Shutsemau
2026-08-02 22:50   ` Zi Yan
2026-08-06 12:54     ` Kiryl Shutsemau
2026-08-03  1:21 ` Baolin Wang [this message]
2026-08-05 15:15   ` [PATCH 00/16] selftests/mm: improve khugepaged coverage Kiryl Shutsemau
2026-08-03 11:04 ` Mike Rapoport

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=f9f01bc0-490b-4d06-85a0-e4693b80696c@linux.alibaba.com \
    --to=baolin.wang@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.