Re: while(1) in init_module()

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

 



Please see in line.

Mulyadi Santosa <mulyadi.santosa@xxxxxxxxx> wrote:
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 :)

<Raja> I am very much a small kid in kernel programming :)     <Raja>

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

<Raja> Yes !,  I saw that this flag is not set in the .config file. <Raja>

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.

<Raja> but for me, the keyboard and mouse went off ! even the on/off button ! <Raja>

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).

< Raja > I tried putting schedule() inside init_module(). Now it did not hang the system. I could proceed with other processes, but only the insmod never returned. But I did not try your suggestion of another process and nice value etc..
So in this case the init_module is run in time slices just to call schedule() again and voluntarily give up the CPU..is it ?
btw..what is mpg 123 ?
<Raja>

hope it helps.

<Raja> Thanks a lot <Raja>

regards,

Mulyadi

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



Yahoo! Photos
Got holiday prints? See all the ways to get quality prints in your hands ASAP.

[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