Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 0/3] btrfs: use kvmalloc() for cases where allocation can be more than one page
Date: Wed, 23 Sep 2026 15:14:24 +0930	[thread overview]
Message-ID: <cover.1790142027.git.wqu@suse.com> (raw)

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


             reply	other threads:[~2026-09-23  5:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23  5:44 Qu Wenruo [this message]
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

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=cover.1790142027.git.wqu@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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