Re: lock_kernel() & kmalloc - evil together?

From: Matthew Wilcox (matthew@wil.cx)
Date: Thu Aug 10 2000 - 16:14:22 EST


On Thu, Aug 10, 2000 at 04:57:07PM -0500, Sam Watters wrote:
> I was reading through the "Linux Kernel Locking HOWTO" and came across the
> following:
>
> "9.7 Things Which Sleep
>
> You can never call the following routines from an interrupt context, or while
> holding a spinlock, as they may sleep:
>
> [snippet skipped]
> * kmalloc(GFP_KERNEL)

> 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

the BKL is no ordinary spinlock. if the kernel wishes to schedule, it will
drop the BKL on behalf of the process and reacquire it again before returning
to your code. Don't panic, you haven't done anything bad. the snippet of
text above refers only to spin_lock() locks.

-- 
Revolutions do not require corporate support.

- 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