public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] btrfs: reduce div64 calls for __btrfs_map_block() and its variants
@ 2023-02-05  8:53 Qu Wenruo
  2023-02-05  8:53 ` [PATCH 1/2] btrfs: remove map_lookup->stripe_len Qu Wenruo
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Qu Wenruo @ 2023-02-05  8:53 UTC (permalink / raw)
  To: linux-btrfs

Div64 is much slower than 32 bit division, and only get improved in
the most recent CPUs, that's why we have dedicated div64* helpers.

One usage of div64 is in __btrfs_map_block() and its variants, where we
got @stripe_nr as u64, and all later division has to go the div64
helpers.

But the truth is, with our current chunk size limit (10G) and fixed
stripe length (64K), we can have at most 160K stripes in a chunk, which
is small enough for u32 already.

So this patchset would reduce div64 calls by:

- Remove map_lookup::stripe_len first
  So now we don't need to call div64 to calculate @stripe_nr, just a
  simple right shift, then truncate to u32.

  This is a prerequisite for the 2nd patch, without the fixed stripe
  length, we have to rely on div64.

- Reduce the width of various @stripe_nr to 32

- Use regular divitsion and module to do the calculation
  Now we can get rid of the fear that we missed some div64 helpers.
  

Qu Wenruo (2):
  btrfs: remove map_lookup->stripe_len
  btrfs: reduce div64 calls by limiting the number of stripes of a chunk
    to u32

 fs/btrfs/block-group.c            |  18 ++---
 fs/btrfs/scrub.c                  |  43 ++++++------
 fs/btrfs/tests/extent-map-tests.c |   1 -
 fs/btrfs/tree-checker.c           |  14 ++++
 fs/btrfs/volumes.c                | 110 +++++++++++++++---------------
 fs/btrfs/volumes.h                |   7 +-
 6 files changed, 104 insertions(+), 89 deletions(-)

-- 
2.39.1


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

end of thread, other threads:[~2023-02-06 10:16 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-05  8:53 [PATCH 0/2] btrfs: reduce div64 calls for __btrfs_map_block() and its variants Qu Wenruo
2023-02-05  8:53 ` [PATCH 1/2] btrfs: remove map_lookup->stripe_len Qu Wenruo
2023-02-06  6:39   ` Christoph Hellwig
2023-02-06  8:28   ` Johannes Thumshirn
2023-02-06  8:50     ` Qu Wenruo
2023-02-06  8:56       ` Johannes Thumshirn
2023-02-05  8:53 ` [PATCH 2/2] btrfs: reduce div64 calls by limiting the number of stripes of a chunk to u32 Qu Wenruo
2023-02-05 12:09   ` kernel test robot
2023-02-05 12:20   ` kernel test robot
2023-02-06  6:44   ` Christoph Hellwig
2023-02-06 10:16     ` Qu Wenruo
2023-02-06  6:38 ` [PATCH 0/2] btrfs: reduce div64 calls for __btrfs_map_block() and its variants Christoph Hellwig
2023-02-06  6:58   ` Qu Wenruo
2023-02-06  7:02     ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox