where to find the kmalloc implementation
cartercheng at gmail.com
Thu Jan 10 08:51:44 EST 2019
On Thu, Jan 10, 2019 at 12:51 AM Okash Khawaja <okash.khawaja at gmail.com>
> On Wed, Jan 9, 2019 at 3:17 PM Carter Cheng <cartercheng at gmail.com> 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 :)
> > _______________________________________________
> > Kernelnewbies mailing list
> > Kernelnewbies at kernelnewbies.org
> > https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Kernelnewbies