[openib-general] Re: [PATCH] libibverbs: protect device list initialization
Michael S. Tsirkin
mst at mellanox.co.il
Wed Nov 9 13:29:54 PST 2005
Quoting r. Roland Dreier <rolandd at cisco.com>:
> Subject: Re: [PATCH] libibverbs: protect device list initialization
>
> Michael> BTW I think this will or something like this will be
> Michael> needed even if we change the library API.
>
> Yes, we definitely need to be thread-safe here.
Do you plan to check in the thread safety patch, meanwhile?
> Michael> The problem I see with the API is with the re-entrancy of
> Michael> ibv_get_devices: for hotplug to work, it seems clear that
> Michael> we'll need to rescan the device list on each call to
> Michael> ibv_get_devices, so we will need something like
> Michael> ibv_put_devices to let the library know the user is not
> Michael> walking the list anymore.
>
> Michael> Given this assumption, it would seems better to let
> Michael> ibv_get_devices to just malloc and return an array of
> Michael> devices, and ibv_put_devices return it, than force
> Michael> everyone to use the sysfs dlist.
>
> Yeah, the reason I've been avoiding this is that having
> ibv_put_devices seems ugly to me. And having the caller allocate a
> buffer (and having to deal with resizing it etc) also seems ugly.
> So I'm somewhat paralyzed ;)
Maybe its a naming thing? We can call the list "iterator",
does this make it less ugly?
ibv_device_iter_init(iter);
ibv_for_each_device(iter) {
}
ibv_device_iter_cleanup(iter);
--
MST
More information about the general
mailing list