From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
David Herrmann <dh.herrmann@gmail.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC 1/2] core: Add generic object registry implementation
Date: Fri, 7 Nov 2014 08:31:43 -0800 [thread overview]
Message-ID: <20141107163143.GD10256@kroah.com> (raw)
In-Reply-To: <20141106161321.GB14873@ulmo.nvidia.com>
On Thu, Nov 06, 2014 at 05:13:24PM +0100, Thierry Reding wrote:
> 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.
The module reference count will never work as it is racy (you can't have
the module itself do the incrementing, which is what is happening here).
I'd argue that the module reference isn't needed at all, because if the
module shuts down and wants to be removed, it will have properly cleaned
up all of its data structures already, right? So why use it?
greg k-h
next prev parent reply other threads:[~2014-11-07 16:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-04 16:29 [RFC 1/2] core: Add generic object registry implementation Thierry Reding
2014-11-04 16:29 ` [RFC 2/2] drm/panel: Use generic object registry Thierry Reding
2014-11-04 16:38 ` [RFC 1/2] core: Add generic object registry implementation Greg Kroah-Hartman
2014-11-05 9:13 ` Thierry Reding
2014-11-06 2:18 ` Greg Kroah-Hartman
2014-11-06 10:25 ` Thierry Reding
2014-11-06 16:13 ` Thierry Reding
2014-11-07 16:31 ` Greg Kroah-Hartman [this message]
2014-11-05 12:36 ` Andrzej Hajda
2014-11-05 14:04 ` Thierry Reding
2014-11-05 16:00 ` Andrzej Hajda
2014-11-06 9:48 ` Thierry Reding
2014-11-07 9:10 ` Andrzej Hajda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141107163143.GD10256@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=daniel.vetter@ffwll.ch \
--cc=dh.herrmann@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox