public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "JP Kobryn (Meta)" <jp.kobryn@linux.dev>
To: boris@bur.io, mark@harmstone.com, clm@fb.com, wqu@suse.com,
	dsterba@suse.com, linux-btrfs@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, linux-team@meta.com
Subject: [PATCH 0/2] btrfs: prevent direct reclaim during compressed readahead
Date: Fri, 20 Mar 2026 00:34:43 -0700	[thread overview]
Message-ID: <20260320073445.80218-1-jp.kobryn@linux.dev> (raw)

We're finding that while under memory pressure, direct reclaim is kicking
in during compressed readahead. This puts the associated task into D-state.
Then shrink_lruvec() disables interrupts when acquiring the LRU lock. Under
heavy pressure, reclaim can run long enough that the CPU becomes prone to
CSD lock stalls since it cannot service incoming IPIs. Although the CSD
lock stalls are the worst case scenario, we have found many more subtle
occurrences of this latency on the order of seconds, over a minute in some
cases.

Prevent direct reclaim during compressed readahead. This is achieved by
using different GFP flags whenever the bio is marked for readahead. The
flags are similar to GFP_NOFS but stripped of __GFP_DIRECT_RECLAIM.  Also,
__GFP_NOWARN is added since these allocations are allowed to fail. Demand
reads still use full GFP_NOFS and will enter reclaim if needed.

There has been some previous work done to reduce the frequency of calling
add_ra_bio_pages() [0]. This patch is complementary in that it reduces the
latency associated with those calls.

[0] https://lore.kernel.org/linux-btrfs/656838ec1232314a2657716e59f4f15a8eadba64.1751492111.git.boris@bur.io/

JP Kobryn (Meta) (2):
  btrfs: additional gfp api for allocating compressed folios
  btrfs: prevent direct reclaim during compressed readahead

 fs/btrfs/compression.c | 44 ++++++++++++++++++++++++++++++++++--------
 fs/btrfs/compression.h |  1 +
 2 files changed, 37 insertions(+), 8 deletions(-)

-- 
2.52.0


             reply	other threads:[~2026-03-20  7:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-20  7:34 JP Kobryn (Meta) [this message]
2026-03-20  7:34 ` [PATCH 1/2] btrfs: additional gfp api for allocating compressed folios JP Kobryn (Meta)
2026-03-20 11:11   ` Mark Harmstone
2026-03-20 17:55   ` David Sterba
2026-03-20  7:34 ` [PATCH 2/2] btrfs: prevent direct reclaim during compressed readahead JP Kobryn (Meta)
2026-03-20  7:36   ` Christoph Hellwig
2026-03-20 16:17     ` JP Kobryn (Meta)
2026-03-20 10:12   ` Qu Wenruo
2026-03-20 11:14     ` Mark Harmstone
2026-03-20 11:11   ` Mark Harmstone
2026-03-20 11:10 ` [PATCH 0/2] " Mark Harmstone

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=20260320073445.80218-1-jp.kobryn@linux.dev \
    --to=jp.kobryn@linux.dev \
    --cc=boris@bur.io \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-team@meta.com \
    --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