Re: Stopping Kernel Threads at module unload time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 9 Nov 2005, Aritz Bastida wrote:

> 2005/11/9, Arnd Bergmann <[email protected]>:
>> On Middeweken 09 November 2005 17:56, Aritz Bastida wrote:
>>> Now, if I call kthread_stop() in module unload time, does that code
>>> run in user process context just like system calls do? That is
>>> important, because if it cannot sleep, it would deadlock.
>>
>> Yes, it runs in the context of the delete_module system call.
>> I think it's more likely that you're not returning from your
>> thread loop.
>>
>> Please post a URL for your module source code so we can see
>> what goes wrong there.
>>
>>         Arnd <><
>
> Than you very much Arnd!
> You solved my problem. hehe
>
> I began to write a test module for showing you this and have just
> realized about the problem. As I create as many threads as CPUs, I
> have to delete them all when finishing.
>
> I killed them like this:
>
>        /* We don't need the distraction of CPUs appearing and vanishing. */
>        lock_cpu_hotplug();
>        for_each_online_cpu(cpu) {
>                p = per_cpu(ksensord_info, cpu);
>                kthread_stop(p);
>        }
>        unlock_cpu_hotplug();
>
> I locked the cpu hotplug lock to protect the for_each_online_cpu()
> code in case a cpu appears/vanishes, so I am actually calling
> kthread_stop() in an atomic context, so it wakes up the process, but
> dont let it run!
>
> This is quite a subtle error, but of course it's my complete fault :P
> May be a BUG_ON(in_atomic()) within kthread_stop() would let this kind of
> errors be acknowledged more easily.
>
> Thank you for your help
> Regards
>
> Aritz Bastida


Ah, yes.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.13.4 on an i686 machine (5589.55 BogoMips).
Warning : 98.36% of all statistics are fiction.
.

****************************************************************
The information transmitted in this message is confidential and may be privileged.  Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited.  If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to [email protected] - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux