Re: [PATCH V4 2/4] RDMA/core: Introduce shared CQ pool API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux