Powered By Blogger

Monday, November 2, 2015

Kmalloc: Which Flag to Use When

Which Flag to Use When
Situation                                                        Solution
Process context, can sleep                             Use GFP_KERNEL

Process context, cannot sleep                        Use GFP_ATOMIC, or perform your allocations                     
                                                                       with GFP_KERNEL at an earlier or later point
                                                                       when you can sleep.

Interrupt handler                                           Use GFP_ATOMIC

Softirq                                                           Use GFP_ATOMIC

Tasklet                                                          Use GFP_ATOMIC

Need DMA-able memory, can sleep            Use (GFP_DMA | GFP_KERNEL)

Need DMA-able memory, cannot sleep       Use (GFP_DMA | GFP_ATOMIC), or perform your 
                                                                      allocation at an earlier point when you can sleep

No comments:

Post a Comment