In message <20000622174858.304CE8154@halfway> I wrote:
> OK. Here is how it would work:
Alternate solution to avoid module problems: Phil Rumpf and I came up
with basically identical answers. It assumes that MOD_INC_USE_COUNT
is always called in user context, and involves no changes to module
code.
1) static volatile int freeze[NR_CPUS];
2) sys_delete_module fires off a RT kernel thread for every other
CPU:
... /* Fire off #CPUs - 1 threads */
retry:
for (i = 0; i < smp_num_cpus(); i++)
if (!freeze[i] && i != smp_processor_id())
goto retry;
if (atomic_read(&mod->uc.use) == 0)
mod->cleanup();
else
err = -EBUSY;
memset(freeze, 0, sizeof(freeze));
3) Threads do:
freeze[smp_processor_id()] = 1;
while (freeze[smp_processor_id()]);
exit
That effectively freezes the other cpus, and cleanup() can sleep et al.
No more races.
Problems?
Rusty.
--
Hacking time.
------- End of Forwarded Message
|