[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-kernel
Subject:    inc/dec modcounts.
From:       R.E.Wolff () bitwizard ! nl (Rogier Wolff)
Date:       2000-08-06 14:55:36
[Download RAW message or body]


Hi,

Recently many modules implementing character devices were modified to
leave inc/dec module_count to the caller.

If I'm not mistaken, this is due to the fact that you're in trouble
if you have an SMP system where:

	processor 1                         processor 2

	goes to call open ()

	dereferences module->open

	is one or two instructions 
	into the "_open" function of
	the module.

	                                    unloads module. 

	tries to increment module 
        count.


If I'm not mistaken this means that inc/dec module count can never be
left to a module, and the caller should always make sure that before
calling ..._open, the module count is incremented. (and decremented on
close or open-error.)

This simplifies a lot of driver modules: The care of the module counts
is delegated to the calling functions. (*)

I'm currently working on an ATM driver, and instead of finding the
right points where to add incmodcount into my driver, I'd rather
remove them from all other drivers, and put them into the calling
layer.

Agreement, tell me I'm wrong. Anything?

			Roger.


(*) And this is good from a software-engineering point-of-view too!
Two reasons:
	- First there are many more drivers than points where modules
	  are called. 
	- Secondly, as all drivers share the same refcount code, an
	  error can be noticed on any driver, not just the one that 
	  say happens to have a small refcount bug. 

-- 
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
*       Common sense is the collection of                                *
******  prejudices acquired by age eighteen.   -- Albert Einstein ********

-
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/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic