linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Weihang Li <liweihang@huawei.com>
Cc: <dledford@redhat.com>, <leon@kernel.org>,
	<linux-rdma@vger.kernel.org>, <linuxarm@huawei.com>
Subject: Re: [PATCH for-next] RDMA/hns: Create QP/CQ with selected QPN/CQN for bank load balance
Date: Fri, 18 Sep 2020 11:25:25 -0300	[thread overview]
Message-ID: <20200918142525.GA306144@nvidia.com> (raw)
In-Reply-To: <1599642563-10264-1-git-send-email-liweihang@huawei.com>

On Wed, Sep 09, 2020 at 05:09:23PM +0800, Weihang Li wrote:
> From: Yangyang Li <liyangyang20@huawei.com>
> 
> In order to improve performance by balancing the load between different
> banks of cache, the QPC cache is desigend to choose one of 8 banks
> according to lower 3 bits of QPN, and the CQC cache uses the lower 2 bits
> to choose one from 4 banks. The hns driver needs to count the number of
> QP/CQ on each bank and then assigns the QP/CQ being created to the bank
> with the minimum load first.
> 
> Signed-off-by: Yangyang Li <liyangyang20@huawei.com>
> Signed-off-by: Weihang Li <liweihang@huawei.com>
>  drivers/infiniband/hw/hns/hns_roce_alloc.c  | 46 +++++++++++++++++++++++++++++
>  drivers/infiniband/hw/hns/hns_roce_cq.c     | 38 +++++++++++++++++++++++-
>  drivers/infiniband/hw/hns/hns_roce_device.h |  8 +++++
>  drivers/infiniband/hw/hns/hns_roce_qp.c     | 39 ++++++++++++++++++++++--
>  4 files changed, 128 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/hns/hns_roce_alloc.c b/drivers/infiniband/hw/hns/hns_roce_alloc.c
> index a522cb2..cbe955c 100644
> +++ b/drivers/infiniband/hw/hns/hns_roce_alloc.c
> @@ -36,6 +36,52 @@
>  #include "hns_roce_device.h"
>  #include <rdma/ib_umem.h>
>  
> +static int get_bit(struct hns_roce_bitmap *bitmap, u8 bankid,
> +		   u8 mod, unsigned long *obj)
> +{
> +	unsigned long offset_bak = bitmap->last;
> +	bool one_circle_flag = false;
> +
> +	do {
> +		*obj = find_next_zero_bit(bitmap->table, bitmap->max,
> +					  bitmap->last);
> +		if (*obj >= bitmap->max) {
> +			*obj = find_first_zero_bit(bitmap->table, bitmap->max);
> +			one_circle_flag = true;
> +		}
> +
> +		bitmap->last = (*obj + 1);
> +		if (bitmap->last == bitmap->max) {
> +			bitmap->last = 0;
> +			one_circle_flag = true;
> +		}
> +
> +		/* Not found after a round of search */
> +		if (bitmap->last >= offset_bak && one_circle_flag)
> +			return -EINVAL;
> +
> +	} while (*obj % mod != bankid);
> +
> +	return 0;
> +}

This looks like an ida, is there a reason it has to be open coded?

Jason

  reply	other threads:[~2020-09-18 14:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-09  9:09 [PATCH for-next] RDMA/hns: Create QP/CQ with selected QPN/CQN for bank load balance Weihang Li
2020-09-18 14:25 ` Jason Gunthorpe [this message]
2020-09-19  9:25   ` liweihang
2020-11-06  1:52   ` liweihang
2020-11-06 13:37     ` Jason Gunthorpe
2020-11-10  9:19       ` liweihang
2020-11-10 17:46         ` Jason Gunthorpe
2020-11-12 11:20           ` liweihang

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=20200918142525.GA306144@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=dledford@redhat.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=liweihang@huawei.com \
    /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 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).