From 363b7fd76c91dc611a56d992e9550bb1ba070e1a Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Wed, 29 Mar 2023 10:29:34 -0400 Subject: 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 Signed-off-by: Mike Snitzer --- drivers/md/dm-bufio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/md/dm-bufio.c') diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c index c1126ad45bdb..8a448185662c 100644 --- a/drivers/md/dm-bufio.c +++ b/drivers/md/dm-bufio.c @@ -398,7 +398,7 @@ struct dm_buffer_cache { static inline unsigned int cache_index(sector_t block, unsigned int num_locks) { - return block & (num_locks - 1); + return dm_hash_locks_index(block, num_locks); } static inline void cache_read_lock(struct dm_buffer_cache *bc, sector_t block) -- cgit v1.2.3