Re: kmalloc in the schedule function

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

 



On Thu, 2006-03-09 at 13:22 -0800, anil dahiya wrote:
> Hi 
> on 2.4.21-32(redhat enterprise update 5) when i call kmalloc  with
> GFP_KERNEL 
> my system get hangs it hangs.. Anyone can suggest what should i do ..

You didn't read the mail that you replied to (and top-quoted BTW)?

[....]
> Hareesh Nagarajan <hnagar2@xxxxxxxxx> wrote:
>         On 3/9/06, Mauricio Lin wrote:
>         > Hi all,
>         >
>         > Is it possible to use kmalloc() in schedule() function?
>         >
>         > I have used kmalloc to allocate memory in schedule() but it
>         does not work
>         > since during the boot the kernel gets frozen.
>         
>         kmalloc with the flag GFP_KERNEL can potentially sleep. Which
>         means,
>         the resource, which in this case is memory, cannot be
>         allocated in an
>         atomic manner, so the kernel can put the requester in a wait
>         queue,
>         call schedule(). (and of ! course when the resource is
>         available, the
>         requester is woken up.)
>         
>         So now inside schedule() you have a call that can sleep, or in
>         other
>         words, you have a call that can schedule(). So you see:
>         
>         schedule()
>         kmalloc(...)
>         schedule()
>         kmalloc(...)
>         ...
>         
>         This is far from ideal. You will run out of stack, which
>         inside the
>         kernel is only 4K. Stay away from kmalloc-ing inside schedule,
>         or if
>         you really need to use kmalloc, use it with the flag
>         GFP_ATOMIC.
[...]

	Bernd
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services




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