[openib-general] Re: user_mad.c: deadlock?

Michael S. Tsirkin mst at mellanox.co.il
Wed Nov 9 10:07:31 PST 2005


Quoting r. Roland Dreier <rolandd at cisco.com>:
> Subject: Re: user_mad.c: deadlock?
> 
>     Michael> I'm not convinced.  What would prevent ib_umad_close from
>     Michael> touching the list if we release the mutex?
> 
> Good point, ib_umad_close() could race against device removal.  But we
> had that problem before: ib_umad_close() doesn't hold the mutex while
> going through the agent list.
> 
>  - R.
> 

To fix ib_umad_kill_port properly, lets clean out port->file_list under the
mutex. Something using list_del_init, like

struct list_head *list;
for (;;) {
	down_write(&port->mutex);
	if (!list_empty(&port->file_list))
		break;
	list=port->file_list->next;
	list_del_init(list);
	up_write(&port->mutex);
	file = list_entry(file, list, port_list);

	/* ... Deregister .... */
	down_write(&port->mutex);
}

Makes sense?

-- 
MST



More information about the general mailing list