git: c44fbfdb5686 - main - roundup_pow_of_two: don't take the log of it
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 28 Sep 2024 17:01:35 UTC
The branch main has been updated by dougm:
URL: https://cgit.FreeBSD.org/src/commit/?id=c44fbfdb56862c4c8d2563483b4fff8f9a5a1d43
commit c44fbfdb56862c4c8d2563483b4fff8f9a5a1d43
Author: Doug Moore <dougm@FreeBSD.org>
AuthorDate: 2024-09-28 17:00:06 +0000
Commit: Doug Moore <dougm@FreeBSD.org>
CommitDate: 2024-09-28 17:00:06 +0000
roundup_pow_of_two: don't take the log of it
Based on the definitions, ilog2(roundup_pow_of_two(x)) ==
order_base_2(x). Replace the former with the latter in a few places to
save a few calculations.
Reviewed by: bz, kib
Differential Revision: https://reviews.freebsd.org/D46827
---
sys/dev/mlx4/mlx4_en/en.h | 2 +-
sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/sys/dev/mlx4/mlx4_en/en.h b/sys/dev/mlx4/mlx4_en/en.h
index a29b40ddaf10..838894f7b02f 100644
--- a/sys/dev/mlx4/mlx4_en/en.h
+++ b/sys/dev/mlx4/mlx4_en/en.h
@@ -232,7 +232,7 @@ enum cq_type {
/*
* Useful macros
*/
-#define ROUNDUP_LOG2(x) ilog2(roundup_pow_of_two(x))
+#define ROUNDUP_LOG2(x) order_base_2(x)
#define XNOR(x, y) (!(x) == !(y))
#define ILLEGAL_MAC(addr) (addr == 0xffffffffffffULL || addr == 0x0)
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c
index 3cda28752592..b391946440b9 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c
@@ -488,7 +488,7 @@ static int set_kernel_sq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
MLX4_IB_QPT_PROXY_GSI | MLX4_IB_QPT_TUN_SMI_OWNER)))
qp->sq.wqe_shift = ilog2(64);
else
- qp->sq.wqe_shift = ilog2(roundup_pow_of_two(s));
+ qp->sq.wqe_shift = order_base_2(s);
for (;;) {
qp->sq_max_wqes_per_wr = DIV_ROUND_UP(s, 1U << qp->sq.wqe_shift);
@@ -544,7 +544,7 @@ static int set_user_sq_size(struct mlx4_ib_dev *dev,
/* Sanity check SQ size before proceeding */
if ((1 << ucmd->log_sq_bb_count) > dev->dev->caps.max_wqes ||
ucmd->log_sq_stride >
- ilog2(roundup_pow_of_two(dev->dev->caps.max_sq_desc_sz)) ||
+ order_base_2(dev->dev->caps.max_sq_desc_sz) ||
ucmd->log_sq_stride < MLX4_IB_MIN_SQ_STRIDE)
return -EINVAL;