Re: [RFC] add kobject to struct module

From: Rusty Russell
Date: Wed Sep 10 2003 - 21:44:47 EST


In message <20030910230614.GB5758@xxxxxxxxx> you write:
> On Wed, Sep 10, 2003 at 06:07:35PM +1000, Rusty Russell wrote:
> > In message <20030910041122.GE9760@xxxxxxxxx> you write:

> Why are you detaching the kobject from struct module?
> In my patch I accounted for the kobject's reference count in the module
> reference count (just not the count exported to userspace, as to not
> break the userspace tools.) So if a user has a module sysfs file open
> (like the "refcount" file), the module reference count is incremented
> and the module is not allowed to be unloaded until that count drops.
> This removes any race condition with the kobject being in use when the
> module structure is freed.

Sorry, my bad. This is related to another bug: you unregistered the
kobject before checking the reference count. This is bad, because the
remove can fail, and you don't re-register the kobject. Even if we
re-register, now there's a spurious failure as the kobject vanishes
for a moment and reappears. And let's not think about what happens if
trying to re-register the kobject fails 8(

So I think we really do want to unregister the kobject as part of the
cleanup, which makes things a little more complicated: my immediately
previous patch which should do what we want. If it's still not clear,
then I'm obviously doing a really crappy job of explaining...

Thanks,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/