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

Sean Hefty mshefty at ichips.intel.com
Mon May 8 10:53:12 PDT 2006


Michael S. Tsirkin wrote:
> 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);
> }

As a general rule, I always avoid holding a lock around a user's callback.  It 
restricts what a user can do too much.

- Sean



More information about the general mailing list