All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zi Yan" <ziy@nvidia.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: "Baolin Wang" <baolin.wang@linux.alibaba.com>,
	"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>, <linux-mm@kvack.org>,
	<linux-kselftest@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	"Kiryl Shutsemau (Meta)" <kas@kernel.org>
Subject: Re: [PATCH 16/16] selftests/mm: skip khugepaged shmem cases without a PMD page cache folio
Date: Sun, 02 Aug 2026 18:50:36 -0400	[thread overview]
Message-ID: <DKETQDCO9OYH.2FDBR4ZXGHLM@nvidia.com> (raw)
In-Reply-To: <20260802195254.1937477-17-kirill@shutemov.name>

On Sun Aug 2, 2026 at 3:52 PM EDT, Kiryl Shutsemau wrote:
> From: "Kiryl Shutsemau (Meta)" <kas@kernel.org>
>
> The page cache caps folio order at MAX_PAGECACHE_ORDER, and
> xas_split_alloc() puts that cap below the PMD order where a PMD is 512M --
> arm64 with 64K base pages, as include/linux/pagemap.h says outright.
> shmem_huge_global_enabled() then offers no PMD order at all, so
> MADV_COLLAPSE of a shmem range answers -EINVAL and khugepaged passes over
> it.

IIRC, after READ_ONLY_THP_FOR_FS is removed, all pagecache folios are
split using non uniform split, xas_try_split(), so does shmem (except
shmem in swapcache not splittable). In theory, we can get rid of the
cap, since xas_try_split() does not split more than one level like
one can try to make xas_split_alloc() split more than two level (e.g.,
512MB to 64KB on arm64 with 64KB base page).

>
> The shmem cases nonetheless ask for a PMD-sized shmem folio, so on such a
> configuration four of them fail and the run bails out in the middle:
>
> not ok 2 collapse_full not ok 4 collapse_single_pte_entry # Allocate huge
> page...Bail out! madvise(MADV_COLLAPSE): Invalid argument (22)
>
> That is the kernel declining something it deliberately does not support,
> not a collapse defect.  Skip those cases where the PMD order is not a shmem
> order, which thp_shmem_supported_orders() already reports -- it reads the
> same per-size shmem_enabled controls the kernel only publishes for orders
> the page cache can hold.  A tmpfs-backed file argument is skipped on the
> same grounds, and a run left with nothing to collapse into skips outright.
>
> Anonymous collapse is unaffected: its orders are not capped this way, and
> the anonymous cases pass at a 512M PMD.
>
> Assisted-by: Claude-Code:claude-opus-5
> Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
> ---
>  tools/testing/selftests/mm/khugepaged.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
>
> diff --git a/tools/testing/selftests/mm/khugepaged.c b/tools/testing/selftests/mm/khugepaged.c
> index 9213ce1658d0..c5a3c3922581 100644
> --- a/tools/testing/selftests/mm/khugepaged.c
> +++ b/tools/testing/selftests/mm/khugepaged.c
> @@ -1584,6 +1584,27 @@ int main(int argc, char **argv)
>  	hpage_pmd_nr = hpage_pmd_size / page_size;
>  	hpage_pmd_order = __builtin_ctz(hpage_pmd_nr);
>  
> +	/*
> +	 * The page cache caps folio order at MAX_PAGECACHE_ORDER, which
> +	 * xas_split_alloc() puts below the PMD order on arm64 with 64K pages.
> +	 * A PMD-sized page cache folio is then impossible, so the kernel
> +	 * refuses these collapses by design and there is nothing to test.
> +	 */
> +	if (!(thp_shmem_supported_orders() & (1UL << hpage_pmd_order))) {
> +		if (shmem_ops) {
> +			ksft_print_msg("no PMD-order page cache folio: skipping shmem\n");
> +			shmem_ops = NULL;
> +		}
> +		if (finfo.type == VMA_SHMEM && read_only_file_ops) {
> +			ksft_print_msg("no PMD-order page cache folio: skipping tmpfs file\n");
> +			read_only_file_ops = NULL;
> +			read_write_file_read_ops = NULL;
> +			read_write_file_write_ops = NULL;
> +		}
> +		if (!anon_ops && !shmem_ops && !read_only_file_ops)
> +			ksft_exit_skip("Nothing left to collapse into\n");
> +	}
> +
>  	if (anon_target_order &&
>  	    !(thp_supported_orders() & (1UL << anon_target_order)))
>  		ksft_exit_skip("Order %d is not a supported anon THP order\n",




-- 
Best Regards,
Yan, Zi


  reply	other threads:[~2026-08-02 22:50 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 [this message]
2026-08-06 12:54     ` Kiryl Shutsemau
2026-08-03  1:21 ` [PATCH 00/16] selftests/mm: improve khugepaged coverage Baolin Wang
2026-08-05 15:15   ` 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=DKETQDCO9OYH.2FDBR4ZXGHLM@nvidia.com \
    --to=ziy@nvidia.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 \
    /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.