linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix one error in mthca_alloc
@ 2021-08-26 10:52 kangning
  2021-08-26 12:49 ` Haakon Bugge
  0 siblings, 1 reply; 2+ messages in thread
From: kangning @ 2021-08-26 10:52 UTC (permalink / raw)
  To: linux-rdma; +Cc: kangning

drivers/infiniband/hw/mthca/mthca_allocator.c: alloc->last left unchanged in mthca_alloc, which
has impact on performance of function find_next_zero_bit in mthca_alloc.

Signed-off-by: kangning <kangning18z@ict.ac.cn>
---
 drivers/infiniband/hw/mthca/mthca_allocator.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/infiniband/hw/mthca/mthca_allocator.c b/drivers/infiniband/hw/mthca/mthca_allocator.c
index aef1d274a14e..e81bb0fcd08e 100644
--- a/drivers/infiniband/hw/mthca/mthca_allocator.c
+++ b/drivers/infiniband/hw/mthca/mthca_allocator.c
@@ -51,6 +51,10 @@ u32 mthca_alloc(struct mthca_alloc *alloc)
 	}
 
 	if (obj < alloc->max) {
+		alloc->last = (obj + 1);
+		if (alloc->last == alloc->max) {
+			alloc->last = 0;
+		}
 		set_bit(obj, alloc->table);
 		obj |= alloc->top;
 	} else
-- 
2.17.1


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

* Re: [PATCH] Fix one error in mthca_alloc
  2021-08-26 10:52 [PATCH] Fix one error in mthca_alloc kangning
@ 2021-08-26 12:49 ` Haakon Bugge
  0 siblings, 0 replies; 2+ messages in thread
From: Haakon Bugge @ 2021-08-26 12:49 UTC (permalink / raw)
  To: kangning; +Cc: OFED mailing list



> On 26 Aug 2021, at 12:52, kangning <kangning18z@ict.ac.cn> wrote:
> 
> drivers/infiniband/hw/mthca/mthca_allocator.c: alloc->last left unchanged in mthca_alloc, which
> has impact on performance of function find_next_zero_bit in mthca_alloc.
> 
> Signed-off-by: kangning <kangning18z@ict.ac.cn>
> ---
> drivers/infiniband/hw/mthca/mthca_allocator.c | 4 ++++
> 1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/infiniband/hw/mthca/mthca_allocator.c b/drivers/infiniband/hw/mthca/mthca_allocator.c
> index aef1d274a14e..e81bb0fcd08e 100644
> --- a/drivers/infiniband/hw/mthca/mthca_allocator.c
> +++ b/drivers/infiniband/hw/mthca/mthca_allocator.c
> @@ -51,6 +51,10 @@ u32 mthca_alloc(struct mthca_alloc *alloc)
> 	}
> 
> 	if (obj < alloc->max) {
> +		alloc->last = (obj + 1);

No need for parenthesis.

> +		if (alloc->last == alloc->max) {

No need for braces.


Otherwise, looks good to me:

Reviewed-by: Håkon Bugge <haakon.bugge@oracle.com>


> +			alloc->last = 0;
> +		}
> 		set_bit(obj, alloc->table);
> 		obj |= alloc->top;
> 	} else
> -- 
> 2.17.1
> 


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

end of thread, other threads:[~2021-08-26 12:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-26 10:52 [PATCH] Fix one error in mthca_alloc kangning
2021-08-26 12:49 ` Haakon Bugge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).