Messages in this thread | | | Date | Thu, 6 Nov 2014 17:13:24 +0100 | From | Thierry Reding <> | Subject | Re: [RFC 1/2] core: Add generic object registry implementation |
| |
On Thu, Nov 06, 2014 at 11:25:32AM +0100, Thierry Reding wrote: > On Wed, Nov 05, 2014 at 06:18:15PM -0800, Greg Kroah-Hartman wrote: [...] > > Sure, document it better if you want, but I think something needs to be > > done differently if at all possible. > > try_module_get() is the only way I know of that ensures that the code of > a module stays around. Everytime we give out a new reference to a record > we also need to increment the module reference count accordingly to make > sure the underlying code doesn't go away all of a sudden. > > I guess that's not entirely accurate. The module reference count doesn't > have to be increment for every record reference, it only needs to track > each record. So the try_module_get() and module_put() could move into > registry_add() and registry_get(), respectively. But the ->owner field > would still be in the record structure.
On further thought I don't think this will work either. Given that the record can be removed from the registry while somebody else still has a reference to it, the module owning the record must stay around as long as there's a reference to the record.
Maybe the module reference count needs to be incremented when the record is initialized and decremented when the record is released.
Thierry [unhandled content-type:application/pgp-signature] | |