lkml.org 
[lkml]   [2018]   [Oct]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH V3 1/2] mm: Add get_user_pages_cma_migrate
Date
Alexey Kardashevskiy <aik@ozlabs.ru> writes:

> On 16/10/2018 18:16, Aneesh Kumar K.V wrote:
>> Alexey Kardashevskiy <aik@ozlabs.ru> writes:
>>
>>> + }
>>>> + }
>>>> + }
>>>> + if (!list_empty(&cma_page_list)) {
>>>> + /*
>>>> + * drop the above get_user_pages reference.
>>>> + */
>
>
> btw, can these pages be used by somebody else in this short window
> before we migrated and pinned them?

isolate lru page make sure that we remove them from lru list. So lru
walkers won't find the page. If somebody happen to increment the page
reference count in that window, the migrate_pages will fail. That is
handled via migrate_page_move_mapping returning EAGAIN

>
>
>>>> + for (i = 0; i < ret; ++i)
>>>> + put_page(pages[i]);
>>>> +
>>>> + if (migrate_pages(&cma_page_list, new_non_cma_page,
>>>> + NULL, 0, MIGRATE_SYNC, MR_CONTIG_RANGE)) {
>>>> + /*
>>>> + * some of the pages failed migration. Do get_user_pages
>>>> + * without migration.
>>>> + */
>>>> + migrate_allow = false;
>>>
>>>
>>> migrate_allow seems useless, simply calling get_user_pages_fast() should
>>> make the code easier to read imho. And the comment says
>>> get_user_pages(), where does this guy hide?
>>
>> I didn't get that suggestion. What we want to do here is try to migrate pages as
>> long as we find CMA pages in the result of get_user_pages_fast. If we
>> failed any migration attempt, don't try to migrate again.
>
>
> Setting migrate_allow to false here means you jump up, call
> get_user_pages_fast() and then run the loop which will do nothing just
> because if(...migrate_allow) is false. Instead of jumping up you could
> just call get_user_pages_fast().

ok, that is coding preference I guess, I prefer to avoid multiple
get_user_pages_fast there. Since we droped the page reference, we need
to _go back_ and get the page reference without attempting to migrate. That
is the way I was looking at this.

>
> btw what is migrate_pages() leaves something in cma_page_list (I cannot
> see it removing pages)? Won't it loop indefinitely?
>

putback_movable_pages take care of that. The below hunk.

if (!list_empty(&cma_page_list))
putback_movable_pages(&cma_page_list);

-aneesh

\
 
 \ /
  Last update: 2018-10-16 10:36    [W:0.038 / U:47.692 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site