All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH rdma] IB/mlx5: Optimize u64 division on 32-bit arches
@ 2020-02-17  7:36 Alexander Lobakin
  2020-03-04 17:19 ` Jason Gunthorpe
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Lobakin @ 2020-02-17  7:36 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Leon Romanovsky, Doug Ledford, Randy Dunlap, Maxim Mikityanskiy,
	Alexander Lobakin, linux-rdma, linux-kernel

Commit f164be8c0366 ("IB/mlx5: Extend caps stage to handle VAR
capabilities") introduced a straight "/" division of the u64
variable "bar_size".
This was fixed with commit 685eff513183 ("IB/mlx5: Use div64_u64
for num_var_hw_entries calculation"). However, div64_u64() is
redundant here as mlx5_var_table::stride_size is of type u32.
Make the actual code way more optimized on 32-bit kernels using
div_u64() and fix 80 chars break-through by the way.

Fixes: 685eff513183 ("IB/mlx5: Use div64_u64 for num_var_hw_entries
calculation")
Signed-off-by: Alexander Lobakin <alobakin@dlink.ru>
---
 drivers/infiniband/hw/mlx5/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index e4bcfa81b70a..026391e4ceb4 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -6545,7 +6545,8 @@ static int mlx5_ib_init_var_table(struct mlx5_ib_dev *dev)
 					doorbell_bar_offset);
 	bar_size = (1ULL << log_doorbell_bar_size) * 4096;
 	var_table->stride_size = 1ULL << log_doorbell_stride;
-	var_table->num_var_hw_entries = div64_u64(bar_size, var_table->stride_size);
+	var_table->num_var_hw_entries = div_u64(bar_size,
+						var_table->stride_size);
 	mutex_init(&var_table->bitmap_lock);
 	var_table->bitmap = bitmap_zalloc(var_table->num_var_hw_entries,
 					  GFP_KERNEL);
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH rdma] IB/mlx5: Optimize u64 division on 32-bit arches
  2020-02-17  7:36 [PATCH rdma] IB/mlx5: Optimize u64 division on 32-bit arches Alexander Lobakin
@ 2020-03-04 17:19 ` Jason Gunthorpe
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2020-03-04 17:19 UTC (permalink / raw)
  To: Alexander Lobakin
  Cc: Leon Romanovsky, Doug Ledford, Randy Dunlap, Maxim Mikityanskiy,
	linux-rdma, linux-kernel

On Mon, Feb 17, 2020 at 10:36:29AM +0300, Alexander Lobakin wrote:
> Commit f164be8c0366 ("IB/mlx5: Extend caps stage to handle VAR
> capabilities") introduced a straight "/" division of the u64
> variable "bar_size".
> This was fixed with commit 685eff513183 ("IB/mlx5: Use div64_u64
> for num_var_hw_entries calculation"). However, div64_u64() is
> redundant here as mlx5_var_table::stride_size is of type u32.
> Make the actual code way more optimized on 32-bit kernels using
> div_u64() and fix 80 chars break-through by the way.
> 
> Fixes: 685eff513183 ("IB/mlx5: Use div64_u64 for num_var_hw_entries
> calculation")
> Signed-off-by: Alexander Lobakin <alobakin@dlink.ru>
> ---
>  drivers/infiniband/hw/mlx5/main.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Applied to for-next, thanks

Jason

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-04 17:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-17  7:36 [PATCH rdma] IB/mlx5: Optimize u64 division on 32-bit arches Alexander Lobakin
2020-03-04 17:19 ` Jason Gunthorpe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.