linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Yamin Friedman <yaminf@mellanox.com>
Cc: Sagi Grimberg <sagi@grimberg.me>, Christoph Hellwig <hch@lst.de>,
	Leon Romanovsky <leonro@mellanox.com>,
	linux-rdma@vger.kernel.org
Subject: Re: [PATCH V4 2/4] RDMA/core: Introduce shared CQ pool API
Date: Fri, 29 May 2020 15:59:37 -0300	[thread overview]
Message-ID: <20200529185937.GA2467@ziepe.ca> (raw)
In-Reply-To: <1590568495-101621-3-git-send-email-yaminf@mellanox.com>

On Wed, May 27, 2020 at 11:34:53AM +0300, Yamin Friedman wrote:
> +struct ib_cq *ib_cq_pool_get(struct ib_device *dev, unsigned int nr_cqe,
> +			     int comp_vector_hint,
> +			     enum ib_poll_context poll_ctx)
> +{
> +	static unsigned int default_comp_vector;
> +	unsigned int vector, num_comp_vectors;
> +	struct ib_cq *cq, *found = NULL;
> +	int ret;
> +
> +	if (poll_ctx > IB_POLL_LAST_POOL_TYPE) {
> +		WARN_ON_ONCE(poll_ctx > IB_POLL_LAST_POOL_TYPE);
> +		return ERR_PTR(-EINVAL);
> +	}
> +
> +	num_comp_vectors = min_t(int, dev->num_comp_vectors,
> +				 num_online_cpus());
> +	/* Project the affinty to the device completion vector range */
> +	if (comp_vector_hint < 0)
> +		vector = default_comp_vector++ % num_comp_vectors;

This should not be touching this shared data without some concurrency
management, I changed it to this:

	if (comp_vector_hint < 0) {
		comp_vector_hint =
			(READ_ONCE(default_comp_vector) + 1) % num_comp_vectors;
		WRITE_ONCE(default_comp_vector, comp_vector_hint);
	}
	vector = comp_vector_hint % num_comp_vectors;

Jason

  reply	other threads:[~2020-05-29 18:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-27  8:34 [PATCH V4 0/4] Introducing RDMA shared CQ pool Yamin Friedman
2020-05-27  8:34 ` [PATCH V4 1/4] RDMA/core: Add protection for shared CQs used by ULPs Yamin Friedman
2020-05-27  8:34 ` [PATCH V4 2/4] RDMA/core: Introduce shared CQ pool API Yamin Friedman
2020-05-29 18:59   ` Jason Gunthorpe [this message]
2020-05-27  8:34 ` [PATCH V4 3/4] nvme-rdma: use new shared CQ mechanism Yamin Friedman
2020-05-27  8:34 ` [PATCH V4 4/4] nvmet-rdma: " Yamin Friedman
2020-05-29 19:03 ` [PATCH V4 0/4] Introducing RDMA shared CQ pool Jason Gunthorpe

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=20200529185937.GA2467@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=hch@lst.de \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sagi@grimberg.me \
    --cc=yaminf@mellanox.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).