From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB2E8606A323 for ; Sun, 29 Nov 2026 00:24:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mit.edu header.i=@mit.edu header.a=rsa-sha256 header.s=outgoing header.b=IJLJVFDZ Received: by kanga.kvack.org (Postfix) id EDEDE6B05B0; Sat, 28 Nov 2026 19:24:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E8F546B05B1; Sat, 28 Nov 2026 19:24:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA5D46B05B2; Sat, 28 Nov 2026 19:24:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id AB5646B05B0 for ; Sat, 28 Nov 2026 19:24:23 -0500 (EST) Received: from smtpin20.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C49891C4128 for ; Sun, 29 Nov 2026 00:24:21 +0000 (UTC) X-FDA: 85486259922.20.E999A00 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by imf12.hostedemail.com (Postfix) with ESMTP id 0A11940007 for ; Sun, 29 Nov 2026 00:24:19 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=mit.edu header.s=outgoing header.b=IJLJVFDZ; dmarc=pass (policy=none) header.from=mit.edu; spf=pass (imf12.hostedemail.com: domain of tytso@mit.edu designates 18.9.28.11 as permitted sender) smtp.mailfrom=tytso@mit.edu ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1795911860; b=h1UwEmh9lyRX5Vf+WIlBIBzDgz9GxSCDcOP1BTD2z/5ye8nSYr4++u+0Vqk7pdmWS6uvoA rDd+gJvrk7+y1G+y0EybTYJIwBrDQPUzoCENXjDyLq4hUv6CsCSBBwiKt7+6aJvcUp4YH8 ZlIaWwr71oMCkm2pijnaQRrQN16rl+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1795911860; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=1bk7x3a3seKCIB2CFqf1Nt/DQj5jrewLdDauL0m2YWU=; b=BRYz28YEit9TE33Y5dtLSZrlCN1dJ/evlDAc+ZX0U5fDa6iXko+yKKqzkfAYm83NAqyM5V +9IB980Rr3sM6ZGBMmQ8B+5QDBXqaluKr6vnhKFTYq2PQtT12j9miir2HPEk6YHkBub1GI 8dFmaz4JuSY4XzsQLBhpsxuqTGN3VWI= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=mit.edu header.s=outgoing header.b=IJLJVFDZ; dmarc=pass (policy=none) header.from=mit.edu; spf=pass (imf12.hostedemail.com: domain of tytso@mit.edu designates 18.9.28.11 as permitted sender) smtp.mailfrom=tytso@mit.edu Received: from trampoline.thunk.org (pool-173-48-111-191.bstnma.fios.verizon.net [173.48.111.191]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 6AT0O6gP014771 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 28 Nov 2026 19:24:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1795911850; bh=1bk7x3a3seKCIB2CFqf1Nt/DQj5jrewLdDauL0m2YWU=; h=Date:From:Subject:Message-ID:MIME-Version:Content-Type; b=IJLJVFDZsBShq+DWlQqPUUKLAdXn7E+ndpMV7n+xSowlgqT3lYC9MxqjSMzibuvsR 2j0uFTxePuGXio5V9nBYnPY3Bp98PuEpkzHjIKw6LWIWpJcOK1i92jKguj9daoRf0q mv00vuXfKfxd8pkF08q9n5mkl2tQEJJpw25KouNOoEtDYcw0uqKnbUvRqzdPo9MkxA GjgNQZrFyErub7g16POUNjP69W0ISCbjPJmsyU6rPTkULeNmNTaXU3fYqqAmju7tw/ m6w1oJNM53T4bZHC1ZUaoXFUMAqFfNYyC1yWbCxQndfu0iGJ9b4a7ypugEKaEgyxrn Oa8y9ZVBmg4VQ== Received: by trampoline.thunk.org (Postfix, from userid 15806) id 76D692E011A; Sat, 28 Nov 2026 19:24:06 -0500 (EST) Date: Sat, 28 Nov 2026 19:24:06 -0500 From: "Theodore Ts'o" To: Ext4 Developers List , linux-mm@kvack.org, Matthew Wilcox Subject: generic/255: read(2) returning ENOMEM on 64k file systems Message-ID: X-Archived-By: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="pkqpdjaqk3uzcnwz" Content-Disposition: inline X-Rspamd-Queue-Id: 0A11940007 X-Stat-Signature: 1bsqmyeahrszj9a33dw9e5w6mw86y5wm X-Rspam-User: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Rspamd-Server: rspam07 X-HE-Tag: 1795911859-668114 X-HE-Meta: U2FsdGVkX19F/qzR+b3NYvc+RwvnONfMBxY8mFblWt+MFP1fAp1eIKyvaSnclLyG7zcI15gDLBCvuUOSwqCR/KxDPpowJZ+DQh2gBkFy9I3pAVV2tWBGVFz452s1KSFLBLsMqa7YlnkaUVW6O9lbkfrEuuky9MW5BwWGJRZNU/s+tc/AKGVZmZDpnHmzivodFlYneiRQiy0xc4tmZcPgi3cPvagz3DzM2E5WMdTXm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2byjXAjYB+bPaPKIDIzaICe6dUOwIdbw5vFonqyg8uw2CsAuK4Mi5rLcxifKmsWpOBzZBzYYq228R5hP1rr6bBnuENKu9T/i0vrqfm73g/B6OrvOuh6umX4Vx1Eap9QU6TU+ov42pBEbz6ADivuhmNdJfj7we/nvTTFKdiYBux/Hc2Zkny8jhu809uHpLlbGJ7Yc3WSOYsldVgtAqkyPFEAkrUykL2dgC6PYNP2UNugBGyynFAJUSQVaMhdTmtShx/tcTv45/vyBIaV5U/tQ7ebgkCqIfjaEEVAq52sUFeBcgat3dZ78MLK/C0OsDAsYB Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 --pkqpdjaqk3uzcnwz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --pkqpdjaqk3uzcnwz Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="fix.patch" diff --git a/mm/filemap.c b/mm/filemap.c index a1b2ca5b933c..053aa6a5e580 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1956,6 +1956,21 @@ void *filemap_get_entry(struct address_space *mapping, pgoff_t index) return folio; } +/* + * A folio of the mapping's minimum order is the smallest unit the page cache + * can use for this mapping, so there is no smaller order to fall back to and + * a failed allocation is reported to userspace as -ENOMEM. The page allocator + * gives up on orders above PAGE_ALLOC_COSTLY_ORDER after a single round of + * reclaim and compaction, which happens easily on a fragmented system that + * has plenty of reclaimable memory. Ask it to try harder in that case. + */ +static gfp_t filemap_min_order_gfp(gfp_t gfp, unsigned int min_order) +{ + if (min_order > PAGE_ALLOC_COSTLY_ORDER && !(gfp & __GFP_NORETRY)) + gfp |= __GFP_RETRY_MAYFAIL; + return gfp; +} + /** * __filemap_get_folio_mpol - Find and get a reference to a folio. * @mapping: The address_space to search. @@ -2044,6 +2059,9 @@ struct folio *__filemap_get_folio_mpol(struct address_space *mapping, err = -ENOMEM; if (order > min_order) alloc_gfp |= __GFP_NORETRY | __GFP_NOWARN; + else + alloc_gfp = filemap_min_order_gfp(alloc_gfp, + min_order); folio = filemap_alloc_folio(alloc_gfp, order, policy); if (!folio) continue; @@ -2652,11 +2670,13 @@ static int filemap_create_folio(struct kiocb *iocb, struct folio_batch *fbatch) int error; unsigned int min_order = mapping_min_folio_order(mapping); pgoff_t index; + gfp_t gfp; if (iocb->ki_flags & (IOCB_NOWAIT | IOCB_WAITQ)) return -EAGAIN; - folio = filemap_alloc_folio(mapping_gfp_mask(mapping), min_order, NULL); + gfp = filemap_min_order_gfp(mapping_gfp_mask(mapping), min_order); + folio = filemap_alloc_folio(gfp, min_order, NULL); if (!folio) return -ENOMEM; if (iocb->ki_flags & IOCB_DONTCACHE) @@ -4149,7 +4169,10 @@ static struct folio *do_read_cache_folio(struct address_space *mapping, repeat: folio = filemap_get_folio(mapping, index); if (IS_ERR(folio)) { - folio = filemap_alloc_folio(gfp, mapping_min_folio_order(mapping), NULL); + unsigned int min_order = mapping_min_folio_order(mapping); + + folio = filemap_alloc_folio(filemap_min_order_gfp(gfp, min_order), + min_order, NULL); if (!folio) return ERR_PTR(-ENOMEM); index = mapping_align_index(mapping, index); --pkqpdjaqk3uzcnwz Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="direct-reclaim.patch" diff --git a/mm/vmscan.c b/mm/vmscan.c index 6a1af9b92349..66b8d1bcc0fd 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; --pkqpdjaqk3uzcnwz--