linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 0/3] btrfs: reduce memory usage for btrfs_raid_bio structure
Date: Thu,  9 Oct 2025 15:09:58 +1030	[thread overview]
Message-ID: <cover.1759984060.git.wqu@suse.com> (raw)

This series replace the following members of btrfs_raid_bio:

	struct sector_ptr bio_sectors[nr_sectors]
	struct sector_ptr stripe_sectors[nr_sectors]

To the following ones:

	phys_addr_t bio_sectors[nr_sectors]
	phys_addr_t stripe_sectors[nr_sectors]
	unsigned long uptodate_bitmap[nr_sectors]

For x86_64 (4K page size) with the fixed 64K stripe size and 3 disks, the
memory usage of those members (not the full structure) will be reduced from:

	8 * 2 + 48 * 16 * 2 = 1552

To
	8 * 3 + 48 * 8 * 2 + 8 * 2 = 808

Almost halved the memory usage.

The memory saving comes from:

- Compat sector_ptr::uptodate bit into a bitmap
  This not only saves space, but also allow us to call bitmap_*()
  helpers when we need to set multiple bits in one go (mostly for
  subpage cases)

- Remove sector_ptr::uptodate flag
  We can use a special paddr (not NULL though) to indicate if the paddr
  is valid or not.

- Get rid of sector_ptr
  That structure has extra bits that take a full byte for each flag.
  This is the biggest space saving.

Qu Wenruo (3):
  btrfs: raid56: remove sector_ptr::has_paddr member
  btrfs: raid56: move sector_ptr::uptodate into a dedicated bitmap
  btrfs: raid56: remove sector_ptr structure

 fs/btrfs/raid56.c | 347 ++++++++++++++++++++++------------------------
 fs/btrfs/raid56.h |  17 +--
 2 files changed, 168 insertions(+), 196 deletions(-)

-- 
2.50.1


             reply	other threads:[~2025-10-09  4:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-09  4:39 Qu Wenruo [this message]
2025-10-09  4:39 ` [PATCH 1/3] btrfs: raid56: remove sector_ptr::has_paddr member Qu Wenruo
2025-10-09  4:40 ` [PATCH 2/3] btrfs: raid56: move sector_ptr::uptodate into a dedicated bitmap Qu Wenruo
2025-10-09  4:40 ` [PATCH 3/3] btrfs: raid56: remove sector_ptr structure Qu Wenruo
2025-11-10 22:58 ` [PATCH 0/3] btrfs: reduce memory usage for btrfs_raid_bio structure Qu Wenruo
2025-11-11 13:11   ` David Sterba

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.1759984060.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;
as well as URLs for NNTP newsgroup(s).