lkml.org 
[lkml]   [2020]   [Jul]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v4 04/11] mm/hugetlb: make hugetlb migration callback CMA aware
From
Date
On 7/7/20 9:44 AM, js1304@gmail.com wrote:
> From: Joonsoo Kim <iamjoonsoo.kim@lge.com>
>
> new_non_cma_page() in gup.c which try to allocate migration target page
> requires to allocate the new page that is not on the CMA area.
> new_non_cma_page() implements it by removing __GFP_MOVABLE flag. This way
> works well for THP page or normal page but not for hugetlb page.
>
> hugetlb page allocation process consists of two steps. First is dequeing
> from the pool. Second is, if there is no available page on the queue,
> allocating from the page allocator.
>
> new_non_cma_page() can control allocation from the page allocator by
> specifying correct gfp flag. However, dequeing cannot be controlled until
> now, so, new_non_cma_page() skips dequeing completely. It is a suboptimal
> since new_non_cma_page() cannot utilize hugetlb pages on the queue so this
> patch tries to fix this situation.
>
> This patch makes the deque function on hugetlb CMA aware and skip CMA
> pages if newly added skip_cma argument is passed as true.

Hmm, can't you instead change dequeue_huge_page_node_exact() to test the PF_
flag and avoid adding bool skip_cma everywhere?

I think that's what Michal suggested [1] except he said "the code already does
by memalloc_nocma_{save,restore} API". It needs extending a bit though, AFAICS.
__gup_longterm_locked() indeed does the save/restore, but restore comes before
check_and_migrate_cma_pages() and thus new_non_cma_page() is called, so an
adjustment is needed there, but that's all?

Hm the adjustment should be also done because save/restore is done around
__get_user_pages_locked(), but check_and_migrate_cma_pages() also calls
__get_user_pages_locked(), and that call not being between nocma save and
restore is thus also a correctness issue?

[1] https://lore.kernel.org/r/20200629075510.GA32461@dhcp22.suse.cz

> Acked-by: Mike Kravetz <mike.kravetz@oracle.com>
> Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> ---
> include/linux/hugetlb.h | 6 ++----
> mm/gup.c | 3 ++-
> mm/hugetlb.c | 46 ++++++++++++++++++++++++++++++----------------
> mm/mempolicy.c | 2 +-
> mm/migrate.c | 2 +-
> 5 files changed, 36 insertions(+), 23 deletions(-)
>

\
 
 \ /
  Last update: 2020-07-07 13:40    [W:0.637 / U:0.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site