From: Carter Cheng <cartercheng@gmail.com>
To: Okash Khawaja <okash.khawaja@gmail.com>
Cc: kernelnewbies <kernelnewbies@kernelnewbies.org>
Subject: Re: where to find the kmalloc implementation
Date: Thu, 10 Jan 2019 21:51:44 +0800 [thread overview]
Message-ID: <CALS6=qW5aReCtGOhFJvaYPicP=wWVAgEGd=EVvucCPFpbth5Vg@mail.gmail.com> (raw)
In-Reply-To: <CAOtcWM1gBXCXfihsQYxrfAz5B=DAYbRLLkXPZQE=40c4LYu0Zg@mail.gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 1337 bytes --]
Thanks!
On Thu, Jan 10, 2019 at 12:51 AM Okash Khawaja <okash.khawaja@gmail.com>
wrote:
> On Wed, Jan 9, 2019 at 3:17 PM Carter Cheng <cartercheng@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 :)
>
> Okash
>
> > _______________________________________________
> > Kernelnewbies mailing list
> > Kernelnewbies@kernelnewbies.org
> > https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
[-- Attachment #1.2: Type: text/html, Size: 2012 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
prev parent reply other threads:[~2019-01-10 13:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-09 15:16 where to find the kmalloc implementation Carter Cheng
2019-01-09 16:51 ` Okash Khawaja
2019-01-10 13:51 ` Carter Cheng [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CALS6=qW5aReCtGOhFJvaYPicP=wWVAgEGd=EVvucCPFpbth5Vg@mail.gmail.com' \
--to=cartercheng@gmail.com \
--cc=kernelnewbies@kernelnewbies.org \
--cc=okash.khawaja@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).