From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stamatis Mitrofanis Date: Thu, 04 Oct 2001 03:14:08 +0000 Subject: Re: Unloading drivers, start-up, shut-down and a rewrite (a problem) Message-Id: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org Keith Owens wrote: >On Tue, 02 Oct 2001 03:00:00 +0100, >stamit wrote: > >>Now, the final thing that remains for unloading to be complete is >>reference counting. I tried to do it with bash (by storing counts in >>*.ref files in the driver directories) and guess what I stumbled to... a >>race condition! Multiple hotplug events can be processed by the scripts >>at the same time. So I took it back. Isn't there a way to use modutils >>programs to play with the module's real refrence counts? It would make >>things a whole lot easier (and safer). >> > >Without knowing exactly what you are trying to do I am guessing but it >sounds like you need this: > >* kernel/module.c registers /proc/sys/kernel/mod_use_count, mode 600. >* module.c creates a dummy module entry called mod_use_count the first > time that /proc/sys/kernel/mod_use_count is written to. >* /proc/sys/kernel/mod_use_count recognises commands like > up module-name > down module-name > and adjusts the use counts and reference chain accordingly. Hotplug > scripts use mod_use_count to bump the reference count before allowing > a start event to continue and after completing a stop event. > >If the module does not exist (already unloaded) then write fails with >some return code. There is no specific code for "module does not >exist" so pick something similar, like ESRCH or ENXIO. > I'm trying to implement module unloading in the hotplug scripts. Aside that, I'm also doing a rewrite, a slight redesign and "beautification" of the scripts generally because thay lacked such things as readability and uniformity. I'm trying to make them beautiful because, hey, vendors might choose to release drivers with scripts for our hotplug project! So I'm making them pretty so they'll be attractive. :-) Of course, because, besides making scripts and framework pretty, I'm also implementing the ability to unload modules, I needed to have a method to play with the modules' reference counts(which is the only thing still missing from my rewrite). And since you pointed me to the right way, I'll try to add it and post a patch when it's ready. I didn't really know about that because I'm not very into the kernel's internals. I'm doing mostly user-space stuff so far (thus my interest for the scripts). _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel