lkml.org 
[lkml]   [2006]   [Mar]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [Bug? Report] kref problem
    On Thu, Mar 16, 2006 at 08:45:10PM +0300, Artem B. Bityutskiy wrote:
    >
    > Greg KH wrote:
    > >Don't statically create kobjects, it's not nice. But the real problem
    > >is below...
    >
    > Well, that was just an example...
    >
    > But in real life I do use a static kobject in one case, so I'm very
    > interested what should I do instead. I have a subsystem, and I want it
    > to put all its stuff in a /sys/A directory. So I just define a static
    > kobject for A and assign a dummy release function to it. Why is this bad?

    If you use decl_subsys(), you should be fine for this. Use that instead
    of trying to roll your own subsystem kobjects please. That
    infrastructure was written for a reason...

    > And what should I do instead? kmalloc(sizeof(struct kobject),
    > GFP_KERNEL) ? I do not have a dynamic structure corresponding to my
    > module. I have many data structures corresponding to entities my object
    > handles and I have one static array which refers them. All is simple. I
    > do not want to introduce a dynamic data structure corresponding to the
    > subsystem as a whole just in order to not use static kobjects.

    Data (kobjects) have a different lifespan than code (modules).
    Seperating them is a good idea, and if not, your reference counting
    issues can be quite nasty. See the recent EDAC fiasco for a good
    example of how easy it is to mess things up in this manner.

    thanks,

    greg k-h
    -
    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: 2006-03-16 19:01    [W:0.023 / U:32.012 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site