[ofa-general] RE: [PATCH/RFC] IB/mad: Fix possible deadlock (cancel_delayed_work inside spinlock)

Sean Hefty sean.hefty at intel.com
Fri Aug 14 21:36:32 PDT 2009


>How about this approach?  Basically it just open-codes delayed work by
>splitting the timer and the work struct, and switches to mod_timer()
>instead of del_timer() + add_timer().  It passes very light testing here
>(basically I started ipoib and nothing blew up).

The approach looks okay to me. 

>@@ -512,7 +523,8 @@ static void unregister_mad_agent(struct
>ib_mad_agent_private *mad_agent_priv)
> 	 */
> 	cancel_mads(mad_agent_priv);
> 	port_priv = mad_agent_priv->qp_info->port_priv;
>-	cancel_delayed_work(&mad_agent_priv->timed_work);
>+	del_timer_sync(&mad_agent_priv->timeout_timer);
>+	cancel_work_sync(&mad_agent_priv->timeout_work);

I had to check if there was a race between del_timer_sync() and the worker
thread, but the call to cancel_mads() looks like it prevents any issues.

- Sean




More information about the general mailing list