aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs/metaslab.c
diff options
context:
space:
mode:
authorAlexander Motin <[email protected]>2021-06-29 08:59:14 -0400
committerGitHub <[email protected]>2021-06-29 06:59:14 -0600
commit5b7053a9a5a624603843a07ac0b360af64839e72 (patch)
tree14f35686ae48cd8b876fc1a0741993e0a5c324d1 /module/zfs/metaslab.c
parentf20fb199e60722abc052b6034bddb6b83d870c99 (diff)
Avoid 64bit division in multilist index functions
The number of sublists in a multilist is relatively small. We dont need 64 bits to calculate an index. 32 bits is sufficient and makes the code more efficient. Reviewed-by: Matthew Ahrens <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Mark Maybee <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Sponsored-By: iXsystems, Inc. Closes #12288
Diffstat (limited to 'module/zfs/metaslab.c')
-rw-r--r--module/zfs/metaslab.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/module/zfs/metaslab.c b/module/zfs/metaslab.c
index 92f51806a..23f3e2989 100644
--- a/module/zfs/metaslab.c
+++ b/module/zfs/metaslab.c
@@ -1874,7 +1874,12 @@ static unsigned int
metaslab_idx_func(multilist_t *ml, void *arg)
{
metaslab_t *msp = arg;
- return (msp->ms_id % multilist_get_num_sublists(ml));
+
+ /*
+ * ms_id values are allocated sequentially, so full 64bit
+ * division would be a waste of time, so limit it to 32 bits.
+ */
+ return ((unsigned int)msp->ms_id % multilist_get_num_sublists(ml));
}
uint64_t