Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 0/3] btrfs: use kvmalloc() for allocations that can be larger than page size
Date: Tue, 8 Sep 2026 17:40:09 +0200	[thread overview]
Message-ID: <20260908154009.GD9053@twin.jikos.cz> (raw)
In-Reply-To: <cover.1788851649.git.wqu@suse.com>

On Tue, Sep 08, 2026 at 04:45:38PM +0930, Qu Wenruo wrote:
> 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.

I've asked around, confirming that virtual mappings and allocations are
not a problem on 64bit systems so we can do the kvmalloc as needed.

> 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.

If it's for hardware acceleration the memory can be DMAd then virtual
memory may not work. I haven't found any constraints for the s390
compression, it's a CPU instruction. It's quite possible assume there
are no limitation or the wrapper code falls back to software
compression.

      parent reply	other threads:[~2026-09-08 15:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=20260908154009.GD9053@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.com \
    /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