Re: while(1) in init_module()

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

 



Hi Rajaram ....

> Hi,
>
>    In the init_module() of a kernel module , I inserted
>
>   while(1);

Nasty experiment ;) but it's okay, even adult is allowed to get nasty 
sometimes :)

>   and then tried to insert the module. When I insmoded the module,
> the system hung without any keyboard/ mouse responses.
>
>   Why does this happen ?
>   Even if the insmod() is busy in the kernel mode with while(1); , it
> should have been preempted by scheduler to run other processes..right
> ? ( as kernel 2.6 is preemptive even in kernel mode ).

First of all, I agree with Thomas...make sure you do enable 
CONFIG_PREEMPT in the currently running kernel. Even 2.6 kernel are 
preemptible in kernel mode, if this feature is disabled during kernel 
compilation, then it will be disabled.

Second, I observe kernel/module.c (i use 2.6.11.1), specifically 
sys_init_module(). You will see these lines:
/* Start the module */
        if (mod->init != NULL)
                ret = mod->init();
I don't see any lock-grabbing function prefixing those lines (especially 
one who disables irq), so I firmly believe interrupt is still accepted 
and processed as usual.

try this simple idea, inside the "while(1)", call schedule() to 
voluntarily call the scheduler. And before inserting the module, run a 
program/application and put it on nice level -19. Insert the module and 
see if the application is stuck....(something that doesn't need 
keyboard/mouse interactivity, maybe mpg123).

hope it helps.

regards,

Mulyadi

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux