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
This commit is contained in:
Doug Moore
2024-09-28 16:24:44 -05:00
parent 3873b9a8b3
commit 5a5da24fc8
+2 -2
View File
@@ -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 {