[openib-general][PATCH][kdapl]: inc/dec module ref count

Muli Ben-Yehuda mulix at mulix.org
Sun Jul 31 08:13:30 PDT 2005


On Sun, Jul 31, 2005 at 06:08:11PM +0300, Guy German wrote:
> Hi Muli,
> 
> Wouldn't it be solved by moving the try_module_get call to the 
> beginning of the dapl_ia_open function ? 

No. Even if it's theoretically the first line in the function, the
compiler can and will create a function prologue that will run before
you raise the reference count (same thing with decrementing the ref
count at module unload time and the function epilogue). You must do
module reference counting before executing even one instruction from
the module.

> You are right - try_module_get() can fail when the module is not ready 
> to be entered. should be something like: 
> + if (!try_module_get(THIS_MODULE))
> +	return -EBUSY;

Yes - but at the caller, not callee.

Cheers,
Muli
-- 
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/




More information about the general mailing list