From nobody Tue Jun 16 20:37:39 2026 Received: from mail-dy1-f182.google.com (mail-dy1-f182.google.com [74.125.82.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7607439D6DB for ; Wed, 29 Apr 2026 07:10:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777446649; cv=none; b=LEgI30u7FM56HxhO/kR+aCCODkm08duKQIyiaHN6Gac3igjqke3STsONU3MGFkFq8RlUNrf723D3OxXPkcGUB5qILc2X0irK2Yngm1ePGQosZhE/h1VyEECkFvR6E2gPOCZbKJh1xU115kWH16gtHU9A3dgcdxaXgzRz9aDBq8M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777446649; c=relaxed/simple; bh=lgJe9gJeU4AuKOrNjpDmrlMYpeUP928w/B1EnYLtuRM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=oJaTNiB5WZR/23AkqAqw/iD18M1Hl1p4w2kRjDY6VtuagMqzFsbc7GJnkg5qp+SLxw7paXZIEA8ObTaoIWKKWiu9xUNwwU0oSF3ZJkpTls/gQo959TcNOPUmL1mAOyyfYyt5399vyA4HSHkLMa8XwhCrdPecnvsgPyJ/iZmxDuI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wbinvd.org; spf=pass smtp.mailfrom=wbinvd.org; dkim=pass (2048-bit key) header.d=wbinvd.org header.i=@wbinvd.org header.b=Qv9aln5w; arc=none smtp.client-ip=74.125.82.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wbinvd.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wbinvd.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wbinvd.org header.i=@wbinvd.org header.b="Qv9aln5w" Received: by mail-dy1-f182.google.com with SMTP id 5a478bee46e88-2ba895adfeaso12899324eec.0 for ; Wed, 29 Apr 2026 00:10:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wbinvd.org; s=wbinvd; t=1777446646; x=1778051446; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=JvMkiMSkoPoG3P9EaL3Cbb8ZOBvfwwRmrUF1MTc3Tso=; b=Qv9aln5w83XXYm3hyvK6DwbZ5IUWei3nwA0xwW8FmsG7juByfTcj36B5zUaDHE5uDp jyvIywfv8Plb1FvWWtl4OkqGRCwJ0U/y1qH16RPECnubFz5po4pfQkcnsXVj5J4CcgzC BnZD2ijUnjjjvl+qGPoUKrchhjwXReQplAYy/OOp2uKpe98BZIfoxZI6FtnvkhYvrmwL 5lUoMYsBYZjYwFEztLgcBh1h5xk7aXsDOiodwvTLdheS8Ov9wTet+swR8iUfuDJV062G jFJNTWTTS2fmylWriGN98CgmgfJaMbSvrekq0jMzFvzmF+u3X4zEwDyF7J1i/4wSpJBw 7Tpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777446646; x=1778051446; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=JvMkiMSkoPoG3P9EaL3Cbb8ZOBvfwwRmrUF1MTc3Tso=; b=pY0tmcEkSz4Z9R6C8VU/7zG1gf3t5wNb4BzUb0fqFxLhtJjZQuSXfJPcoPxwTO/fg9 5qakHA5DDtti0n0sXgwS7j2kOujKk1/zynrmcrn//r5ya99h5T1DIY4lboh2zFx64GGZ ToESp09t+dn0gwXdjd3Ep6gEdjbAdKZM5/ZB6SSIACFisOqfyds9sx223CQszratplwJ EJwnWbQGFQW4fuJyhH2Oul5TmbDOwikr6LZcJM1Bct4xTNBXoF6PSrVB379kR8fSNb/q 0btlf5KrhPCA5bYGk+aK0Y5IX3PiYP209Lb/cRNcC4WtBmDGg6eCr2sN2ZdVG+CtjBl9 pSdQ== X-Gm-Message-State: AOJu0YzBTfX26w3JrNhsAcw10Ni4w+zs4HO69B1YEjW2irJTr9AZBV2g 4n4IlufzncoPyuooa2cAI9AqIZm/sRFJajUZsHBxWueKgP4iwJK5lMX7Zz/UPS6gJlHlAotRaoY fLWyJ X-Gm-Gg: AeBDieukE2f3AtmsaQGpWlSwssvgpBvQ9X2XTX4vRJNqPhaqOel6dZ4dKYNz5fKN29y yodWrOLm4gQo1LS28x4iXY5IKU8WlFDLSXbp/paUgZcy9RdUcams+qbWbhpl+x4d+sAgA+5lx+J FXyQZpk0CZJBqEcVFNOp3U6OMhI4f5eZ3ghsMpWAj8LnmmHmM+J96JcDYCTnWEXILLT/HwDBda6 dlzl3FUPXtOheZnzKSfJ9gPHSUXX4mAqbzSYiwR8Jxew34BeM4HEtC6BJxdZ6TiLNckw1re/hDr 2CWj1bmV30KIG8hqnyhU3XoCFRLT456Yuk/ZRV4bpYzYe1FA8orGQL2ksWTFC4KtTfrnpylYNOJ UUYaeNGR5BNaHfYUOoYGdWK1kda/kx2063Lhjrgf7ihj7PzULFpLmlyMS5zh9ssIDb5/4v/sC8Z pxlPn8iGpnutIowoqvXDBC1K1Ed28iDPzJI6tP X-Received: by 2002:a05:7300:6c24:b0:2dd:5641:f01 with SMTP id 5a478bee46e88-2ed198bf5aamr1257642eec.28.1777446645843; Wed, 29 Apr 2026 00:10:45 -0700 (PDT) Received: from mozart.vkv.me ([2001:5a8:468b:d015:6050:66c4:ba14:2c51]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2ed1c09c6e3sm1036260eec.25.2026.04.29.00.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2026 00:10:45 -0700 (PDT) From: Calvin Owens To: linux-kernel@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Chris Mason , David Sterba , "JP Kobryn (Meta)" , Mark Harmstone , Qu Wenruo Subject: [PATCH] btrfs: always pass __GFP_NOWARN from add_ra_bio_pages() Date: Wed, 29 Apr 2026 00:10:25 -0700 Message-ID: X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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: 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/compressi= on.c:454:8 451 452 folio =3D filemap_alloc_folio(mapping_gfp_const= raint(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 reada= head") Signed-off-by: Calvin Owens --- fs/btrfs/compression.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index b2393a48a8fe..d29a42ff8653 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -408,21 +408,19 @@ static noinline int add_ra_bio_pages(struct inode *in= ode, end_index =3D (i_size_read(inode) - 1) >> PAGE_SHIFT; =20 /* - * Avoid direct reclaim when the caller does not allow it. Since - * add_ra_bio_pages() is always speculative, suppress allocation warnings - * in either case. + * Avoid direct reclaim when the caller does not allow it. */ + constraint_gfp =3D ~__GFP_FS; + cache_gfp =3D GFP_NOFS | __GFP_NOWARN; if (!direct_reclaim) { - constraint_gfp =3D ~(__GFP_FS | __GFP_DIRECT_RECLAIM) | __GFP_NOWARN; - cache_gfp =3D (GFP_NOFS & ~__GFP_DIRECT_RECLAIM) | __GFP_NOWARN; - } else { - constraint_gfp =3D (~__GFP_FS) | __GFP_NOWARN; - cache_gfp =3D GFP_NOFS | __GFP_NOWARN; + constraint_gfp &=3D ~__GFP_DIRECT_RECLAIM; + cache_gfp &=3D ~__GFP_DIRECT_RECLAIM; } =20 while (cur < compressed_end) { pgoff_t page_end; pgoff_t pg_index =3D cur >> PAGE_SHIFT; + gfp_t masked_constraint_gfp; u32 add_size; =20 if (pg_index > end_index) @@ -449,8 +447,14 @@ static noinline int add_ra_bio_pages(struct inode *ino= de, continue; } =20 - folio =3D filemap_alloc_folio(mapping_gfp_constraint(mapping, constraint= _gfp), - 0, NULL); + /* + * Since add_ra_bio_pages() is always speculative, suppress + * allocation warnings. + */ + masked_constraint_gfp =3D mapping_gfp_constraint(mapping, constraint_gfp= ); + masked_constraint_gfp |=3D __GFP_NOWARN; + + folio =3D filemap_alloc_folio(masked_constraint_gfp, 0, NULL); if (!folio) break; =20 --=20 2.47.3