From: Pankaj Suryawanshi <pankajssuryawanshi@gmail.com>
To: Michal Hocko <mhocko@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Vlastimil Babka <vbabka@suse.cz>,
pankaj.suryawanshi@einfochips.com
Subject: Re: How cma allocation works ?
Date: Fri, 23 Aug 2019 00:17:22 +0530 [thread overview]
Message-ID: <CACDBo57oFDEYY-GR1NEZEXKS409BkEx+RYywMNwuUn5f5Sz76A@mail.gmail.com> (raw)
In-Reply-To: <20190822130219.GK12785@dhcp22.suse.cz>
[-- Attachment #1: Type: text/plain, Size: 3250 bytes --]
On Thu, Aug 22, 2019 at 6:32 PM Michal Hocko <mhocko@kernel.org> wrote:
>
> On Wed 21-08-19 22:58:03, Pankaj Suryawanshi wrote:
> > Hello,
> >
> > Hard time to understand cma allocation how differs from normal
allocation ?
>
> The buddy allocator which is built for order-N sized allocations and it
> is highly optimized because it used from really hot paths. The allocator
> also involves memory reclaim to get memory when there is none
> immediatelly available.
>
> CMA allocator operates on a pre reserved physical memory range(s) and
> focuses on allocating areas that require physically contigous memory of
> larger sizes. Very broadly speaking. LWN usually contains nice writeups
> for many kernel internals. E.g. quick googling pointed to
https://lwn.net/Articles/486301/
>
> > I know theoretically how cma works.
> >
> > 1. How it reserved the memory (start pfn to end pfn) ? what is bitmap_*
> > functions ?
>
> Not sure what you are asking here TBH
I know it reserved memory at boot time from start pfn to end pfn, but when
i am requesting memory from cma it has different bitmap_*() in cma_alloc()
what they are ?
because we pass pfn and pfn+count to alloc_contig_range and pfn is come
from bitmap_*() function.
lets say i have reserved 100MB cma memory at boot time (strart pfn to end
pfn) and i am requesting allocation of 30MB from cma area then what is pfn
passed to alloc_contig_range() it is same as start pfn or
different.(calucaled by bitmap_*()) ?
>
> > 2. How alloc_contig_range() works ? it isolate all the pages including
> > unevictable pages, what is the practical work flow ? all this works with
> > virtual pages or physical pages ?
>
> Yes it isolates a specific physical contiguous (pfn) range, tries to
> move any used memory within that range and make it available for the
> caller.
what i understood here is that it isolate pages between range as
MIGRATE_ISOLATE, removed pages from buddy allocator including
allocated(movable/unevictable) pages. how unevictable pages isolated here ?
>
> > 3.what start_isolate_page_range() does ?
>
> There is some documentation for that function. Which part is not clear?
>
mention in above question
> > 4. what alloc_contig_migrate_range does() ?
>
> Have you checked the code? It simply tries to reclaim and/or migrate
> pages off the pfn range.
>
What is difference between migration, isolation and reclamation of pages ?
> > 5.what isolate_migratepages_range(), reclaim_clean_pages_from_list(),
> > migrate_pages() and shrink_page_list() is doing ?
>
> Again, have you checked the code/comments? What exactly is not clear?
>
Why again migrate_isolate_range() ?
(reclaim_clean_pages_fron_list) if we are reclaiming only clean pages then
pages will not contiguous ? we have only clean pages which are not
contiguous ?
What is work of shrink_page_list() ? please explain all flow with taking
one allocation for example let say reserved cma 100MB and then request
allocation of 30MB then how all the flow/function will work ?
> > Please let me know the flow with simple example.
>
> Look at alloc_gigantic_page which is using the contiguous allocator to
> get 1GB physically contiguous memory ranges to be used for hugetlb
> pages.
>
Thanks
> HTH
> --
> Michal Hocko
> SUSE Labs
[-- Attachment #2: Type: text/html, Size: 3886 bytes --]
next prev parent reply other threads:[~2019-08-22 18:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-21 17:28 Pankaj Suryawanshi
2019-08-22 13:02 ` Michal Hocko
2019-08-22 18:47 ` Pankaj Suryawanshi [this message]
2019-08-26 7:25 ` Michal Hocko
2019-08-26 17:11 ` Pankaj Suryawanshi
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=CACDBo57oFDEYY-GR1NEZEXKS409BkEx+RYywMNwuUn5f5Sz76A@mail.gmail.com \
--to=pankajssuryawanshi@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=pankaj.suryawanshi@einfochips.com \
--cc=vbabka@suse.cz \
/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