Widespread misuse of GFP_ATOMIC
Hello linux janitors,
from kmalloc man page:
GFP_ATOMIC - Allocation will not sleep. May use emergency pools. For example, use this inside interrupt handlers.GFP_NOWAIT - Allocation will not sleep.
grepping linux kernel tree:
[0:/usr/linux-src> ]$ grep -R GFP_ATOMIC . |wc -l
4452
[0:/usr/linux-src> ]$ grep -R GFP_NOWAIT . |wc -l
220
(alternative flags and some accounting:
total k.*alloc calls: 34320GFP_KERNEL appearances: 23819GDP_ATOMIC appearances: 4452GFP_NOWAIT appearances: 220
unaccounted: 5829)
GFP_ATOMIC is meant for interrupt handlers and emergency pool. Widespread misuse renders the emergency pool useless.
I believe the vast majority of such uses can be converted to GFP_NOWAIT. Even valid uses of GFP_ATOMIC are likely rendered useless by this widespread misuse.
You may wish to replace such calls.
Cheers, coypu
Quoted 23 lines · On Sun, 10 Apr 2016, [email protected] wrote:
Hello linux janitors,
from kmalloc man page:
GFP_ATOMIC- Allocation will not sleep. May use emergency pools. For example, use this inside interrupt handlers.GFP_NOWAIT- Allocation will not sleep.grepping linux kernel tree:
[0:/usr/linux-src> ]$ grep -R
GFP_ATOMIC. |wc -l
4452
[0:/usr/linux-src> ]$ grep -RGFP_NOWAIT. |wc -l
220(alternative flags and some accounting:
total k.*alloc calls: 34320GFP_KERNELappearances: 23819GDP_ATOMICappearances: 4452GFP_NOWAITappearances: 220unaccounted: 5829)
Quoted 8 lines
GFP_ATOMICis meant for interrupt handlers and emergency pool. Widespread misuse renders the emergency pool useless.I believe the vast majority of such uses can be converted to
GFP_NOWAIT. Even valid uses ofGFP_ATOMICare likely rendered useless by this widespread misuse.You may wish to replace such calls.
How does one know which need the emergency pool?
julia
GFP_NOWAIT is when you have a somewhat painless backup plan in case the allocation fails. If you're worried that there are too many GFP_ATOMICs, then it's better to re-arrange the code so the allocation can sleep.
regards,
dan carpenter