Thanks! On Thu, Jan 10, 2019 at 12:51 AM Okash Khawaja <[email protected]> wrote:
> On Wed, Jan 9, 2019 at 3:17 PM Carter Cheng <[email protected]> wrote: > > > > Hi, > > > > I am curious where in the kernel sources would I find the kmalloc > implementation? I am curious how GFP_ATOMIC option is implemented. > > > > Thanks, > > > > Carter. > > Hi Carter, > > kmalloc() implementation can be found in include/linux/slab.h. > Interesting part of kmalloc() is the use of kmem_cache. kmem_cache is > basically a pool of memory. kmalloc() maintains a system of > kmem_cache's and allocates memory from those caches to the caller. How > it allocates that memory is determined by type of request (e.g. > GFP_ATOMIC) and "buddy system" algorithm, which is an algorithm > designed to minimise fragmentation and be cache efficient. > > From what I remember, kmalloc system sets aside memory for "emergency" > uses, like kmalloc calls with GFP_ATOMIC. So for normal memory > allocation calls, execution may sleep until memory becomes available, > even though there may be memory available in the emergence cache. > > Hope it helps :) > > Okash > > > _______________________________________________ > > Kernelnewbies mailing list > > [email protected] > > https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies >
_______________________________________________ Kernelnewbies mailing list [email protected] https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
