Re: lock_kernel() & kmalloc - evil together?

From: Andi Kleen (ak@suse.de)
Date: Thu Aug 10 2000 - 17:24:48 EST


On Thu, Aug 10, 2000 at 04:57:07PM -0500, Sam Watters wrote:
> Okay, I screwed up in a patch I am doing and I put slipped in some
> kmalloc(GFP_KERNEL) calls in a segment of code that lies between a
> lock_kernel()/unlock_kernel() - specifically in do_fork(). I did find some
> other kmalloc(GFP_KERNEL) calls that occur in this same segment (in functions
> that get called from do_fork()). So, am I truly evil for adding these new
> kmalloc(GFP_KERNEL) calls? Any suggestions on how best to allocate memory while

You're not evil, the kernel lock is magic and the scheduler drops it when
entered (it is just used to get cooperative multitasking like in 2.0). There
fore you're allowed to sleep. This is not true for other spinlocks.

When you cannot sleep you should use kmalloc(..., GFP_ATOMIC), but it is
less reliable than GFP_KERNEL.

-Andi
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Aug 15 2000 - 21:00:22 EST