diff options
author | Alexander Motin <[email protected]> | 2021-06-29 08:59:14 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-29 06:59:14 -0600 |
commit | 5b7053a9a5a624603843a07ac0b360af64839e72 (patch) | |
tree | 14f35686ae48cd8b876fc1a0741993e0a5c324d1 /module/zfs/arc.c | |
parent | f20fb199e60722abc052b6034bddb6b83d870c99 (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/arc.c')
-rw-r--r-- | module/zfs/arc.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 04d275dd8..3484fff3b 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -7454,9 +7454,10 @@ arc_state_multilist_index_func(multilist_t *ml, void *obj) * Also, the low order bits of the hash value are thought to be * distributed evenly. Otherwise, in the case that the multilist * has a power of two number of sublists, each sublists' usage - * would not be evenly distributed. + * would not be evenly distributed. In this context full 64bit + * division would be a waste of time, so limit it to 32 bits. */ - return (buf_hash(hdr->b_spa, &hdr->b_dva, hdr->b_birth) % + return ((unsigned int)buf_hash(hdr->b_spa, &hdr->b_dva, hdr->b_birth) % multilist_get_num_sublists(ml)); } |