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

Tom Tucker tom at opengridcomputing.com
Mon May 8 09:03:34 PDT 2006


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);



>  - R.
> _______________________________________________
> openib-general mailing list
> openib-general at openib.org
> http://openib.org/mailman/listinfo/openib-general
> 
> To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general




More information about the general mailing list