[openib-general] Proposed device enumeration & async event APIs

Tillier, Fabian ftillier at infiniconsys.com
Sun Sep 12 15:00:38 PDT 2004


> From: Roland Dreier [mailto:roland at topspin.com]
> Sent: Sunday, September 12, 2004 12:47 PM
> 
>     Fab> How do the above pci_xxx_drvdata functions avoid a malloc?
>     Fab> Can we do something similar?  Either way, I think your
>     Fab> proposed API will work fine.
> 
> The pci functions only support a single driver, so they can just use a
> single void * driver_data member of the struct device.  Since IB
> allows multiple consumers, the options are to have a table with a
> static limit, or to dynamically allocate context for each consumer as
> it gets used.  I really don't like having static limits so I chose the
> second option.
> 
> The chances of a small kmalloc (with GFP_KERNEL) failing are pretty
> small, and when such an allocation fails you're usually pretty screwed
> anyway.

Do you plan on having an allocation per client, or having an array of
allocations that you grow dynamically as needed?  I would think the
array would be beneficial since you end up with fewer allocations.  It
does require synchronization and a counter to keep track of the array
size.  Resize would then just do a malloc, copy, and free.

> 
>     Fab> Is it valid for a client to call the get function if it did
>     Fab> not call the set function?  Does that just result in NULL
>     Fab> being retuned?
> 
> Yes.
> 

Great!

- Fab



More information about the general mailing list