Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In the linux kernel, will a call to kfree ever sleep?

The title is pretty much the question...

I am writing some code that uses a spinlock to help in list management. The documentation on spinlocks are pretty clear about not making a call to anything that would sleep. I know there are ways to allocate memory that are "atomic", but I haven't seen anything about kfree or freeing the memory.

Intuition tells me it shouldn't ever sleep, but I haven't found were that is explicit.

like image 898
Gabe Avatar asked Sep 18 '13 16:09

Gabe


1 Answers

No, it never sleeps. It's safe to call kfree from arbitrary context. The only exception is the NMI oopser and similar arch code.

like image 100
pratik Avatar answered Oct 30 '22 06:10

pratik