linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] btrfs: reduce memory usage for btrfs_raid_bio structure
@ 2025-10-09  4:39 Qu Wenruo
  2025-10-09  4:39 ` [PATCH 1/3] btrfs: raid56: remove sector_ptr::has_paddr member Qu Wenruo
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Qu Wenruo @ 2025-10-09  4:39 UTC (permalink / raw)
  To: linux-btrfs

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


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

end of thread, other threads:[~2025-11-11 13:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-09  4:39 [PATCH 0/3] btrfs: reduce memory usage for btrfs_raid_bio structure Qu Wenruo
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

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