Re: owner field in `struct fs'

From: David Woodhouse (dwmw2@infradead.org)
Date: Mon Jun 26 2000 - 14:49:41 EST


On Mon, 26 Jun 2000, Alexander Viro wrote:

> Erm... There is one case when MOD_INC_USE_COUNT is kosher and even needed,
> but it's pretty convoluted. Consider modules A, B and C.
> A provides register_foo() and unregister_foo()
> B provides foo1
> C does register_foo(&foo1) and unregister_foo(&foo1) for ioctls on
> some device.
>
> Notice that C depends on A and B, but A and B are independent. However,
> once foo1 is registered we want A to be pinned down. MOD_INC_USE_COUNT in
> register_foo() is OK here - C depends on A and if we have C around the A
> will stay there...

You, sir, have a sick mind. But my code actually _does_ things like that
so I suppose I should shut up :)

If you __MOD_INC_USE_COUNT on _registration_ then the cleanup_module
function can never get called and the module can't be unloaded. You
generally want to increase the use count when it's _USED_ not when it's
registered.

But yes - if you were to increase the use count on registration, then that
would generally be safe anyway, because the structure being registered
will generally reside in the same module as the caller of the
register_foo() function, and that should be locked in place when it's
running.

-- 
dwmw2

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Jun 26 2000 - 21:00:09 EST