mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kay Sievers <kay.sievers@vrfy.org>
To: Roland Dreier <rdreier@cisco.com>
Cc: Greg KH <gregkh@suse.de>,
	Bart Van Assche <bart.vanassche@gmail.com>,
	OpenIB <general@lists.openfabrics.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [ofa-general] IB kernel modules and the kobject release() method
Date: Tue, 11 Aug 2009 14:56:28 +0200	[thread overview]
Message-ID: <ac3eb2510908110556s44db5e24rba901cc4d4a4c431@mail.gmail.com> (raw)
In-Reply-To: <adad4738l3v.fsf@cisco.com>

On Mon, Aug 10, 2009 at 22:33, Roland Dreier<rdreier@cisco.com> wrote:
>
>  > No, it still makes sense :)
>
> So what's the fix for this?

The fix is not to embed any kobject/struct device into an object whose
lifetime is not controlled by the kobject. The kobject should just be
a pointer then, and not inlined in the same memory the object uses,
which needs the kobject. The entire kobject embedding/release logic
works only properly if the kobject can own/control the lifetime of the
enclosing object - if not, it should just not be embedded.

> If even you have trouble understanding
> kobject lifetimes

I don't think we have trouble understanding that, but we are
hopelessly lost running after people who "optimize" the use of
kobjects/struct device to save an allocation or a separate dynamic
object.

> and the requirement for a release function, is there
> hope for anyone else?

Almost all uses where kobjects/struct device are statically allocated,
an object embeds more than a single kobject, or the embedded kobject
does not control the lifetime of the enclosing object, is just a
mis-use of kobjects.

Not sure, maybe it needs a simpler API to use non-embedded kobjects,
to make it easier to reach the originating object from the kobject.
That might not be obvious how to do that in some cases.

Kay

      reply	other threads:[~2009-08-11 12:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <e2e108260908060943u344bbe03k2baab01b204c9cca@mail.gmail.com>
     [not found] ` <adad478hmi8.fsf@cisco.com>
     [not found]   ` <e2e108260908061146y47ae45f5j6b8085d44cd1c45b@mail.gmail.com>
     [not found]     ` <adaocqsg339.fsf@cisco.com>
     [not found]       ` <e2e108260908061229v2c605aabp7cf66cbe568d6755@mail.gmail.com>
     [not found]         ` <adafxc4g1e7.fsf@cisco.com>
2009-08-07  7:26           ` Bart Van Assche
2009-08-08  3:48             ` Greg KH
2009-08-10 20:33               ` Roland Dreier
2009-08-11 12:56                 ` Kay Sievers [this message]

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=ac3eb2510908110556s44db5e24rba901cc4d4a4c431@mail.gmail.com \
    --to=kay.sievers@vrfy.org \
    --cc=bart.vanassche@gmail.com \
    --cc=general@lists.openfabrics.org \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdreier@cisco.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

all inboxes | Powered by JetHome®