Date: Sat, 28 Sep 2024 21:26:51 GMT From: Doug Moore <dougm@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 5a5da24fc85a - main - mlx5: optimize ilog2 calculation Message-ID: <202409282126.48SLQpMd000633@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=5a5da24fc85aa7711eed8f3e303c0cf6f5ebcca4 commit 5a5da24fc85aa7711eed8f3e303c0cf6f5ebcca4 Author: Doug Moore <dougm@FreeBSD.org> AuthorDate: 2024-09-28 21:24:44 +0000 Commit: Doug Moore <dougm@FreeBSD.org> CommitDate: 2024-09-28 21:24:44 +0000 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 --- sys/dev/mlx5/mlx5_ib/mlx5_ib_mem.c | 4 ++-- 1 file 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 {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202409282126.48SLQpMd000633>