All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] btrfs: use kvmalloc() for cases where allocation can be more than one page
@ 2026-09-23  5:44 Qu Wenruo
  2026-09-23  5:44 ` [PATCH 1/3] btrfs: use kvmalloc() for btrfs_encoded_read_inline() Qu Wenruo
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Qu Wenruo @ 2026-09-23  5:44 UTC (permalink / raw)
  To: linux-btrfs

There are still some cases where kmalloc() and its variants are called
where the memory allocated can be multiple pages on x86_64.

Normally any kmalloc() with a size that <= PAGE_ALLOC_COSTLY_ORDER (3)
should not fail that easily, so even we allocate a multi-page buffer
using kmalloc() as long as it's not reaching 64K (4K page size) it
should still be fine.

Thus those cases are all very rare:

- An inlined extent larger than 4K
  This can only be archived by a system with page size larger than 4K,
  along with larger max_inline.

  And still, only 64K sized inlined extent can really cause problems.

- Too many RAID56 data stripes with SHA256
  To go beyond 4K, it only requires 9 data stripes, but to reach 64K
  (order > 3) it requires 128 data stripes which is beyond sanity.

- Fragmented memory at btrfs module load time
  This is in fact more common than the above 2 cases, but this requires
  CONFIG_BTRFS_FS_RUN_SANITY_TESTS and load the module after the memory
  is fragmented, it's still very rare.
  
So all of those fixes are just another bike shred problem, but
considering it's not that hard to fix, so here comes the patches.

Qu Wenruo (3):
  btrfs: use kvmalloc() for btrfs_encoded_read_inline()
  btrfs: use kvzalloc() for btrfs_raid_bio::csum_buf
  btrfs: use kvmalloc() inside test_eb_bitmaps()

 fs/btrfs/inode.c                 | 4 ++--
 fs/btrfs/raid56.c                | 8 ++++----
 fs/btrfs/tests/extent-io-tests.c | 4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)

-- 
2.55.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-09-23  7:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-23  5:44 [PATCH 0/3] btrfs: use kvmalloc() for cases where allocation can be more than one page Qu Wenruo
2026-09-23  5:44 ` [PATCH 1/3] btrfs: use kvmalloc() for btrfs_encoded_read_inline() Qu Wenruo
2026-09-23  5:44 ` [PATCH 2/3] btrfs: use kvzalloc() for btrfs_raid_bio::csum_buf Qu Wenruo
2026-09-23  5:44 ` [PATCH 3/3] btrfs: use kvmalloc() inside test_eb_bitmaps() Qu Wenruo
2026-09-23  7:42 ` [PATCH 0/3] btrfs: use kvmalloc() for cases where allocation can be more than one page Sun YangKai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.