All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] btrfs: use kvmalloc() for allocations that can be larger than page size
@ 2026-09-08  7:15 Qu Wenruo
  2026-09-08  7:15 ` [PATCH 1/3] btrfs: use kvmalloc() for overwrite_item() Qu Wenruo
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Qu Wenruo @ 2026-09-08  7:15 UTC (permalink / raw)
  To: linux-btrfs

With the experimental bs > ps support, btrfs can hit several kmalloc()
call sites requesting physically contiguous memory that are larger
than a page, sometimes such allocation can be as large as 64K.

This means those kmalloc() has a much higher chance to fail if the
system's available memory is very fragmented on 4K page sized systems.

And there is already a report that with 64K nodesize, even bs == ps we
can still hit such kmalloc() failure.
(https://lore.kernel.org/linux-btrfs/250decb0-d940-4fe6-9b54-d06e1b293a1b@suse.com/)

But we do not really require any physically contiguous memory for a lot
of kmalloc() call sites, we just want a buffer to save some data
temporarily.

So change those possible larger than page size kmalloc() to kvmalloc()
to reduce the chance of memory allocation failure.

And since kvmalloc() falls back to kmalloc() if the allocation is not
larger than a page, it means for most cases it's still calling
kmalloc(), not affecting the most common cases anyway.

The first patch is a special case that affects the existing bs == ps
cases already.
The second one only affects bs > ps cases.
The third one mostly affects bs > ps cases, but can still improve S390's
hardware accelerated path with 4K page size.

Qu Wenruo (3):
  btrfs: use kvmalloc() for overwrite_item()
  btrfs: use kvmalloc() for uncompress_inline()
  btrfs: use kvmalloc() to allocate compression workspace buffer

 fs/btrfs/inode.c    |  4 ++--
 fs/btrfs/tree-log.c |  4 ++--
 fs/btrfs/zlib.c     | 10 +++++-----
 fs/btrfs/zstd.c     |  4 ++--
 4 files changed, 11 insertions(+), 11 deletions(-)

-- 
2.55.0


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

end of thread, other threads:[~2026-09-08 15:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-08  7:15 [PATCH 0/3] btrfs: use kvmalloc() for allocations that can be larger than page size Qu Wenruo
2026-09-08  7:15 ` [PATCH 1/3] btrfs: use kvmalloc() for overwrite_item() Qu Wenruo
2026-09-08  7:32   ` Daniel Vacek
2026-09-08  7:15 ` [PATCH 2/3] btrfs: use kvmalloc() for uncompress_inline() Qu Wenruo
2026-09-08  7:34   ` Daniel Vacek
2026-09-08  7:15 ` [PATCH 3/3] btrfs: use kvmalloc() to allocate compression workspace buffer Qu Wenruo
2026-09-08  7:38   ` Daniel Vacek
2026-09-08  7:58 ` [PATCH 0/3] btrfs: use kvmalloc() for allocations that can be larger than page size Johannes Thumshirn
2026-09-08 15:40 ` David Sterba

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.