Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Theodore Ts'o" <tytso@mit.edu>,
	"Ext4 Developers List" <linux-ext4@vger.kernel.org>,
	linux-mm@kvack.org, "Matthew Wilcox" <willy@infradead.org>
Subject: Re: generic/255: read(2) returning ENOMEM on 64k file systems
Date: Mon, 30 Nov 2026 00:24:40 +0000	[thread overview]
Message-ID: <sashiko-outbox-240151@kernel.org> (raw)
In-Reply-To: <awsvBJeU3SGSdklm@mit.edu>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] mm: missing Signed-off-by trailer and informal RFC email commit
  message
- [High] mm: vmscan: bypassing compaction_ready() breaks costly
  __GFP_RETRY_MAYFAIL
- [Low] mm/filemap: missing Fixes trailer for minimum-order folio
  allocations
--

commit 6134b8058c4679c6f6ebfa5d61c0da90b8cc6fdd
Author: Theodore Ts'o <tytso@mit.edu>

> generic/255: read(2) returning ENOMEM on 64k file systems
>
> On systems with a 4k page size, when reading from a file system that
> has a 64k block size, every page cache folio has an order of at least
> 4, which is above PAGE_ALLOC_COSTLY_ORDER (== 3).  As a result, any
> memory allocation without __GFP_RETRY_MAYFAIL or __GFP_NOFAIL can be
> very prone to failure, even when there is gigabytes of memory
> available.
>
> This is causing the xfstests test generic/251 to fail 50-60% of the
> time on my test appliance when running the ext4/64k configuration.
> It's not clear what the best solution might be.  Please note that this
> is not ext4 specific.  Any file system attempting to use a 64k block
> size on a system with 4k blocks could run into this issue.
>
> The simplest fix which the LLM came up with is the first attached
> patch; it causes mm/filemap.c to use __GFP_RETRY_MAYFAIL when needed.
> This is not a complete fix, however.  The LLM came up with a more
> reliable reproducer which fails nearly 100% of the time (25/26 runs),
> using __GFP_RETRY_MAYFAIL beings it down to 4% of the time (1/23
> runs)[1].
>
> [1] https://github.com/tytso/ext4-artifacts/blob/main/2026-11-xfstests-test-fixes/evidence/mm251/findings.md#42-test-results
>
> Using __GFP_NOFAIL makes it completely reliable (of course), as does
> an additional patch which changes direct relcaim to be more aggressive
> if __GFP_RETRY_MAYFAIL is passed (the second attached patch,
> direct-reclaim.patch).
>
> I believe the first patch shouldn't be _too_ controversial; but it's
> not a complete solution.  Is the second patch is the right way to go,
> or would some other approach would be better?
>
> Thanks in advance for suggestions and comments!
>
>                                                 - Ted
>
> P.S.  For more details, you can read (in very exhausting detail) the
> report from the LLM[2].  Other xfstests failures that I'm working
> through can be found here[3].
>
> [2] https://github.com/tytso/ext4-artifacts/blob/main/2026-11-xfstests-test-fixes/evidence/mm251/findings.md
> [3] https://github.com/tytso/ext4-artifacts/blob/main/2026-11-xfstests-test-fixes/xfstests-fixes.md

[Severity: High]
This commit is missing a Signed-off-by: trailer.  In addition, the commit
message is written as an informal RFC mailing-list note discussing two
separate attached patches rather than a self-contained kernel changelog, and
the subject line lacks an mm: prefix while citing generic/255 instead of
generic/251.

[Severity: Low]
For the minimum folio order allocation failure in mm/filemap.c, should this
include a Fixes: tag for the commit that started allocating
mapping_min_folio_order() folios?

  Fixes: ab95d23bab22 ("filemap: allocate mapping_min_order folios in the page cache")

> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 6a1af9b92349f..66b8d1bcc0fd5 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -6680,6 +6680,7 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc)
>  			 */
>  			if (IS_ENABLED(CONFIG_COMPACTION) &&
>  			    sc->order > PAGE_ALLOC_COSTLY_ORDER &&
> +			    !(sc->gfp_mask & __GFP_RETRY_MAYFAIL) &&
>  			    compaction_ready(zone, sc)) {
>  				sc->compaction_ready = true;
>  				continue;

[Severity: High]
Does bypassing compaction_ready() for all costly __GFP_RETRY_MAYFAIL
allocations force unconditional node reclaim and prevent compaction from
escalating to COMPACT_PRIO_SYNC_FULL when a zone already has plenty of free
base pages?

In __alloc_pages_slowpath(), the initial compact_first pass only runs
COMPACT_PRIO_ASYNC compaction before entering __alloc_pages_direct_reclaim().
compaction_ready() checks both whether the high-order watermark is already
met and whether free base pages satisfy compaction_suitable() above the high
watermark:

mm/vmscan.c:compaction_ready() {
	if (!gfp_compaction_allowed(sc->gfp_mask))
		return false;

	/* Allocation can already succeed, nothing to do */
	if (zone_watermark_ok(zone, sc->order, min_wmark_pages(zone),
			      sc->reclaim_idx, 0))
		return true;
    ...
	watermark = high_wmark_pages(zone);
	if (compaction_suitable(zone, sc->order, watermark, sc->reclaim_idx))
		return true;

	return false;
}

With compaction_ready() skipped, shrink_zones() unconditionally calls
shrink_node() on every node in the zonelist even when gigabytes of free
order-0..3 pages are already available for synchronous compaction.  Under
MGLRU, shrink_node() does not call should_continue_reclaim() and keeps
reclaiming until sc->nr_reclaimed reaches max(sc->nr_to_reclaim,
compact_gap(sc->order)).

Worse, if a zone has abundant free base pages for compaction but no
unprotected reclaimable LRU pages (for example, memory is already free in
lower orders or protected by memory.low), sc->compaction_ready remains false
and do_try_to_free_pages() cannot return 1 via its sc->compaction_ready
check.  Instead, direct reclaim scans all priorities down to 0, throttles in
VMSCAN_THROTTLE_NOPROGRESS, triggers the force_deactivate and
memcg_low_reclaim retry passes (breaching cgroup memory.low protection), and
returns 0.  A zero return from __perform_reclaim() causes
__alloc_pages_direct_reclaim() to skip drain_all_pages() and causes
__alloc_pages_slowpath() to skip should_compact_retry(), so compaction
never escalates to COMPACT_PRIO_SYNC_FULL.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/awsvBJeU3SGSdklm@mit.edu?part=1


      reply	other threads:[~2026-11-30  0:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29  0:24 generic/255: read(2) returning ENOMEM on 64k file systems Theodore Ts'o
2026-11-30  0:24 ` sashiko-bot [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=sashiko-outbox-240151@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tytso@mit.edu \
    --cc=willy@infradead.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