From: David Sterba <dsterba@suse.cz>
To: Calvin Owens <calvin@wbinvd.org>
Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org,
Chris Mason <clm@fb.com>, David Sterba <dsterba@suse.com>,
"JP Kobryn (Meta)" <jp.kobryn@linux.dev>,
Mark Harmstone <mark@harmstone.com>, Qu Wenruo <wqu@suse.com>
Subject: Re: [PATCH] btrfs: always pass __GFP_NOWARN from add_ra_bio_pages()
Date: Wed, 29 Apr 2026 12:54:23 +0200 [thread overview]
Message-ID: <20260429105423.GI3906171@suse.cz> (raw)
In-Reply-To: <fa015cf39d4dd9575052141e86bce7417c61d4e1.1777445157.git.calvin@wbinvd.org>
On Wed, Apr 29, 2026 at 12:10:25AM -0700, Calvin Owens wrote:
> A build workload newly prints order-0 allocation failures on 7.1-rc1:
>
> sh: page allocation failure: order:0
> mode:0x14084a(__GFP_HIGHMEM|__GFP_MOVABLE|__GFP_IO|__GFP_KSWAPD_RECLAIM|
> __GFP_COMP|__GFP_HARDWALL)
> CPU: 27 UID: 1000 PID: 855540 Comm: sh Not tainted 7.1.0-rc1-llvm-00058-gdca922e019dd #1 PREEMPTLAZY
> Call Trace:
> <TASK>
> dump_stack_lvl+0x50/0x70
> warn_alloc+0xeb/0x100
> __alloc_pages_slowpath+0x567/0x5a0
> ? filemap_get_entry+0x11a/0x140
> __alloc_frozen_pages_noprof+0x249/0x2d0
> alloc_pages_mpol+0xe4/0x180
> folio_alloc_noprof+0x80/0xa0
> add_ra_bio_pages+0x13c/0x4b0
> btrfs_submit_compressed_read+0x229/0x300
> submit_one_bio+0x9e/0xe0
> btrfs_readahead+0x185/0x1a0
> [...]
>
> (lldb) source list -a add_ra_bio_pages+0x13c
> .../vmlinux.unstripped add_ra_bio_pages + 316 at .../fs/btrfs/compression.c:454:8
> 451
> 452 folio = filemap_alloc_folio(mapping_gfp_constraint(mapping, constraint_gfp),
> 453 0, NULL);
> -> 454 if (!folio)
> 455 break;
>
> I can reproduce this consistently by running a memory hog concurrently
> with a buffered writer on a machine with a very large amount of swap.
>
> Commit 7ae37b2c94ed ("btrfs: prevent direct reclaim during compressed
> readahead") clearly intended to suppress these warnings. But because the
> mask set in the address_space with mapping_set_gfp_mask() doesn't include
> __GFP_NOWARN, mapping_gfp_constraint() removes it from constraint_gfp
> before it is passed to filemap_alloc_folio().
>
> Fix by refactoring the code to add __GFP_NOWARN after the call to
> mapping_gfp_constraint().
>
> Fixes: 7ae37b2c94ed ("btrfs: prevent direct reclaim during compressed readahead")
> Signed-off-by: Calvin Owens <calvin@wbinvd.org>
This is on me, the original patch https://lore.kernel.org/linux-btrfs/20260323051414.64704-1-jp.kobryn@linux.dev/
had the __GFP_NOWARN at the allocation. As this was not explained as
necessary I moved it to the constant assignments to be grouped. But this
changed the semantics.
Added to for-next, thanks.
prev parent reply other threads:[~2026-04-29 10:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 7:10 [PATCH] btrfs: always pass __GFP_NOWARN from add_ra_bio_pages() Calvin Owens
2026-04-29 10:54 ` David Sterba [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=20260429105423.GI3906171@suse.cz \
--to=dsterba@suse.cz \
--cc=calvin@wbinvd.org \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=jp.kobryn@linux.dev \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@harmstone.com \
--cc=wqu@suse.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