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

Michael S. Tsirkin mst at mellanox.co.il
Mon May 8 09:07:13 PDT 2006


Quoting r. Tom Tucker <tom at opengridcomputing.com>:
> Subject: Re: [openib-general] Re: [PATCH] cm refcount race fix
> 
> On Mon, 2006-05-08 at 08:53 -0700, Roland Dreier wrote:
> >  > +	/* Make sure cm_deref_id is not in progress */
> >  > +	spin_lock_irq(&cm_id_priv->lock);
> >  > +	spin_unlock_irq(&cm_id_priv->lock);
> > 
> > How does this help anything?  cm_deref_id() can still be in progress,
> > it just can't hold the lock during this empty section of code.
> > 
> 
> Maybe Michael means this...
> 
> 
> T1
> 	
> 	spin_lock_irq(&obj->lock);
> 	if (atomic_dec_and_test(&obj->refcount))
> 		wake_up(&obj->wait);
> 	spin_unlock_irq(&obj->lock);
> 
> T2
> 
> 	atomic_dec(&obj->refcount);
> 	wait_event(&obj->wait, !atomic_read(&obj->refcount))
> 	spin_lock_irq(&obj->lock);
> 	spin_unlock_irq(&obj->lock);
> 	kfree(obj);
> 

Right, that's what the patch does. No?

-- 
MST



More information about the general mailing list