lkml.org 
[lkml]   [2009]   [Aug]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
FromKay Sievers <>
DateTue, 11 Aug 2009 14:56:28 +0200
SubjectRe: [ofa-general] IB kernel modules and the kobject release() method
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2009-08-11 14:59    [from the cache]
©2003-2010