diff options
| author | Doug Moore <dougm@FreeBSD.org> | 2024-09-28 21:24:44 +0000 |
|---|---|---|
| committer | Doug Moore <dougm@FreeBSD.org> | 2024-09-28 21:24:44 +0000 |
| commit | 5a5da24fc85aa7711eed8f3e303c0cf6f5ebcca4 (patch) | |
| tree | db7d595563997e37540a5d52bbeba82fea76b6c9 | |
| parent | 3873b9a8b3a51731e5db92ab0c5c59797e416015 (diff) | |
mlx5: optimize ilog2 calculation
Rather than compute ilog2(roundup_pow_of_two(x)), which invokes ilog2
twice, just use order_base_2 once. And employ that optimization
twice.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D46838
| -rw-r--r-- | sys/dev/mlx5/mlx5_ib/mlx5_ib_mem.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib_mem.c b/sys/dev/mlx5/mlx5_ib/mlx5_ib_mem.c index bd06e531531b..9428e6ece3a4 100644 --- a/sys/dev/mlx5/mlx5_ib/mlx5_ib_mem.c +++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib_mem.c @@ -78,10 +78,10 @@ void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, } if (i) { - m = min_t(unsigned long, ilog2(roundup_pow_of_two(i)), m); + m = min_t(unsigned long, order_base_2(i), m); if (order) - *order = ilog2(roundup_pow_of_two(i) >> m); + *order = order_base_2(i) - m; *ncont = DIV_ROUND_UP(i, (1 << m)); } else { |
