[openib-general] Re: [PATCH] libibverbs: protect device list initialization

Michael S. Tsirkin mst at mellanox.co.il
Wed Nov 9 09:30:14 PST 2005


Quoting r. Roland Dreier <rolandd at cisco.com>:
> Subject: Re: [PATCH] libibverbs: protect device list initialization
> 
> > The following patch solves a problem I'm seeing when multiple
> > threads try to call ibv_get_devices at the same time.
> 
> Looks good, thanks.

BTW I think this will or something like this will be needed even
if we change the library API.

> > Which brings me to another issue: our code examples call non-reentrant
> > dlist_for_each variants of dlist scanning routines, which will
> > create strange problems for multi-threaded users who might copy this.
> 
> I was thinking recently that it would be better to just kill the dlist
> use in the libibverbs API entirely.  It was a mistake to be lazy and
> use the code for sysfs, because I don't think dlist is designed very
> well.  Returning something like a simple singly-linked list of devices
> would be better.
> 
> What do you think?
> 
>  - R.
> 

Basically I agree.

The problem I see with the API is with the re-entrancy of ibv_get_devices:
for hotplug to work, it seems clear that we'll need to rescan
the device list on each call to ibv_get_devices, so we will need
something like ibv_put_devices to let the library know the user is not
walking the list anymore.

Given this assumption, it would seems better to let
ibv_get_devices to just malloc and return an array of devices,
and ibv_put_devices return it, than force everyone to
use the sysfs dlist.

-- 
MST



More information about the general mailing list