Re: How cma allocation works ?
From: Michal Hocko
Date: Thu Aug 22 2019 - 09:46:11 EST
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
> 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.
> 3.what start_isolate_page_range() does ?
There is some documentation for that function. Which part is not clear?
> 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.
> 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?
> 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.
HTH
--
Michal Hocko
SUSE Labs