All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: kangning <kangning18z@ict.ac.cn>
Cc: haakon.bugge@oracle.com, linux-rdma@vger.kernel.org
Subject: Re: [PATCH v3] Fix one error in mthca_alloc
Date: Tue, 31 Aug 2021 12:52:21 +0300	[thread overview]
Message-ID: <YS371Qgef1FTTrHZ@unreal> (raw)
In-Reply-To: <20210827005228.15671-1-kangning18z@ict.ac.cn>

On Fri, Aug 27, 2021 at 08:52:28AM +0800, kangning 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.

I don't know what the sentence above means, but the change is unlikely
to be correct.

When alloc->last starts to be equal to alloc->max, the
find_next_zero_bit() will always return alloc->max. which will ensure
that the following code is executed.

   48         if (obj >= alloc->max) {
   49                 alloc->top = (alloc->top + alloc->max) & alloc->mask;
   50                 obj = find_first_zero_bit(alloc->table, alloc->max);
   51         }


However the mthca_alloc() function has other error, it returns -1 while
based on its declaration it needs to be unsigned,

Thanks

> 
> Signed-off-by: kangning <kangning18z@ict.ac.cn>
> ---
>  
>  I squashed two commits into one in this version.
>  
>  drivers/infiniband/hw/mthca/mthca_allocator.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/infiniband/hw/mthca/mthca_allocator.c b/drivers/infiniband/hw/mthca/mthca_allocator.c
> index aef1d274a14e..1141695093e7 100644
> --- a/drivers/infiniband/hw/mthca/mthca_allocator.c
> +++ b/drivers/infiniband/hw/mthca/mthca_allocator.c
> @@ -51,6 +51,9 @@ 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
> 

  reply	other threads:[~2021-08-31  9:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-27  0:52 [PATCH v3] Fix one error in mthca_alloc kangning
2021-08-31  9:52 ` Leon Romanovsky [this message]
2021-08-31 10:40   ` 康宁
2021-08-31 12:00     ` Leon Romanovsky
2021-08-31 12:16       ` kangning18z
2021-08-31 10:47   ` 康宁
     [not found]   ` <202109011027459851120@ict.ac.cn>
2021-09-01  7:51     ` Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YS371Qgef1FTTrHZ@unreal \
    --to=leon@kernel.org \
    --cc=haakon.bugge@oracle.com \
    --cc=kangning18z@ict.ac.cn \
    --cc=linux-rdma@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.