Skip to content

allocate extent_buffer GFP_NOFAIL with unlocked retry

Boris Burkov linux-btrfs 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 5 repliesIn review
  2. v15 patches 4 repliesSuperseded

Changes in v2 from the cover letter

- rebase
- dropped the inhibit array allocation patch

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4btrfs: factor init_extent_buffer from __alloc_extent_bufferfs/btrfs/extent_io.c+12 -80 replies
2/4btrfs: add struct btrfs_eb_preallocfs/btrfs/ctree.c fs/btrfs/disk-io.c fs/btrfs/disk-io.h +4 more+168 -681 reply
3/4btrfs: enable unlocked NOFAIL retry for eb allocationsfs/btrfs/ctree.c fs/btrfs/extent_io.c fs/btrfs/extent_io.h +2 more+50 -140 replies
4/4btrfs: use GFP_NOWAIT for tree block readaheadfs/btrfs/extent_io.c+2 -10 replies

Reviews trailers per patch

1 of 4 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchDavid SterbaFilipe Manana
SeriesR-b R-b
1/4
2/4R-b
3/4
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/4] allocate extent_buffer GFP_NOFAIL with unlocked retry

From sampled fleet data measuring lock holders that go into direct reclaim with a waiter present when they eventually unlock, we have observed ~15% of those are btrfs extent_buffer allocations in btrfs_search_slot() done while holding btree locks. This is the single largest category. Additionally, a large source of hung_task timeouts is both btree waiters and direct reclaiming btree allocations, which further motivates the desire to drive down this source of stalls and contention.

The aim of this series is to allow us to allocate the extent_buffer, btrfs_folio_state, and the extent_buffer folios with GFP_NOWAIT then fallback with EAGAIN to outside the critical section to retry with GFP_NOFS | GFP_NOFAIL without any locks held.

This is analogous to how we must drop locks to read an extent_buffer and then EAGAIN.

The series does not manage to completely eliminate allocations from this lock holding path, as we also allocate inside xarray functions for the extent_buffer xarray and the btree_inode mapping xarray, the latter of which is done via filemap_add_folio() with no reserve type API. Luckily, those particular allocations are small cached slab allocations and have nearly no contribution to the production reclaim fueled contention.

Changelog:
v2:
- rebase
- dropped the inhibit array allocation patch

Boris Burkov (4):
btrfs: factor init_extent_buffer from __alloc_extent_buffer
btrfs: add struct btrfs_eb_prealloc
btrfs: enable unlocked NOFAIL retry for eb allocations
btrfs: use GFP_NOWAIT for tree block readahead

 fs/btrfs/ctree.c       |  36 ++++++-
 fs/btrfs/disk-io.c     |   6 +-
 fs/btrfs/disk-io.h     |   2 +
 fs/btrfs/extent-tree.c |   6 +-
 fs/btrfs/extent_io.c   | 213 ++++++++++++++++++++++++++++-------------
 fs/btrfs/extent_io.h   |  23 +++++
 fs/btrfs/subpage.c     |   7 +-
 fs/btrfs/subpage.h     |   3 +-
 fs/btrfs/tree-log.c    |   3 +-
 9 files changed, 220 insertions(+), 79 deletions(-)
Signature · 1 line
2.55.0