[RFC 1/2] core: Add generic object registry implementation

Thierry Reding thierry.reding at gmail.com
Thu Nov 6 08:13:24 PST 2014


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/dri-devel/attachments/20141106/f280695e/attachment-0001.sig>


More information about the dri-devel mailing list