[openib-general] Re: [PATCH] cm refcount race fix

Michael S. Tsirkin mst at mellanox.co.il
Mon May 8 10:36:55 PDT 2006


Quoting r. Roland Dreier <rdreier at cisco.com>:
> Subject: Re: [PATCH] cm refcount race fix
> 
>     Michael> It's easy to fix cm. But 12 other files (8 modules) have
>     Michael> the same race.  Did you consider this? If yes - it's your
>     Michael> call, that's the way we should do it.
> 
> I definitely think we should do this the right way.  It's not worth
> saving a few minutes at the cost of having atomic operations protected
> by a spinlock.
> 
>  - R.
> 

Actually, in some places we can get rid of all the refcounting completely.
Consider mthca_cq_event as an example - I think we can just:

void mthca_cq_event(struct mthca_dev *dev, u32 cqn,
		    enum ib_event_type event_type)
{
	struct mthca_cq *cq;
	struct ib_event event;

	spin_lock(&dev->cq_table.lock);

	cq = mthca_array_get(&dev->cq_table.cq, cqn & (dev->limits.num_cqs - 1));

	if (!cq) {
		mthca_warn(dev, "Async event for bogus CQ %08x\n", cqn);
		goto unlock;
	}

	event.device      = &dev->ib_dev;
	event.event       = event_type;
	event.element.cq  = &cq->ibcq;
	if (cq->ibcq.event_handler)
		cq->ibcq.event_handler(&event, cq->ibcq.cq_context);

unlock:
	spin_unlock(&dev->cq_table.lock);
}


-- 
MST



More information about the general mailing list