diff options
author | Joe Thornber <ejt@redhat.com> | 2023-03-29 10:29:34 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@kernel.org> | 2023-03-30 15:57:51 -0400 |
commit | 363b7fd76c91dc611a56d992e9550bb1ba070e1a (patch) | |
tree | a8871fafe3b50344d8ff12a4fc7403cfdfd9772a /drivers/md/dm-bio-prison-v1.c | |
parent | b6279f82eb11a1f380af3a26acf921c37505fc86 (diff) | |
download | lwn-363b7fd76c91dc611a56d992e9550bb1ba070e1a.tar.gz lwn-363b7fd76c91dc611a56d992e9550bb1ba070e1a.zip |
dm: improve hash_locks sizing and hash function
Both bufio and bio-prison-v1 use the identical model for splitting
their respective locks and rbtrees. Improve dm_num_hash_locks() to
distribute across more rbtrees to improve overall performance -- but
the maximum number of locks/rbtrees is still 64.
Also factor out a common hash function named dm_hash_locks_index(),
the magic numbers used were determined to be best using this program:
https://gist.github.com/jthornber/e05c47daa7b500c56dc339269c5467fc
Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Diffstat (limited to 'drivers/md/dm-bio-prison-v1.c')
-rw-r--r-- | drivers/md/dm-bio-prison-v1.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/md/dm-bio-prison-v1.c b/drivers/md/dm-bio-prison-v1.c index 6b726b8b300d..92afdca760ae 100644 --- a/drivers/md/dm-bio-prison-v1.c +++ b/drivers/md/dm-bio-prison-v1.c @@ -117,9 +117,10 @@ static int cmp_keys(struct dm_cell_key *lhs, return 0; } -static unsigned lock_nr(struct dm_cell_key *key, unsigned int num_locks) +static inline unsigned int lock_nr(struct dm_cell_key *key, unsigned int num_locks) { - return (key->block_begin >> BIO_PRISON_MAX_RANGE_SHIFT) & (num_locks - 1); + return dm_hash_locks_index((key->block_begin >> BIO_PRISON_MAX_RANGE_SHIFT), + num_locks); } bool dm_cell_key_has_valid_range(struct dm_cell_key *key) |