btrfs: use kvmalloc() for allocations that can be larger than page size
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest3 patches 5 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | btrfs: use kvmalloc() for overwrite_item()fs/ | +2 | 1 reply | |
| 2/3 | btrfs: use kvmalloc() for uncompress_inline()fs/ | +2 | 1 reply | |
| 3/3 | btrfs: use kvmalloc() to allocate compression workspace bufferfs/ fs/ | +7 | 1 reply |
Reviews trailers per patch
All 3 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Daniel Vacek | Johannes Thumshirn |
|---|---|---|
| Series | R-b | |
| 1/3 | R-b | |
| 2/3 | R-b | |
| 3/3 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH 0/3] btrfs: use kvmalloc() for allocations that can be larger than page size
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/[email protected]/)
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(-)
Signature · 1 line
2.55.0