[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <87in22wape.fsf@linux.ibm.com>
Date: Tue, 16 Oct 2018 14:05:25 +0530
From: "Aneesh Kumar K.V" <aneesh.kumar@...ux.ibm.com>
To: Alexey Kardashevskiy <aik@...abs.ru>, akpm@...ux-foundation.org,
Michal Hocko <mhocko@...nel.org>, mpe@...erman.id.au
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
linuxppc-dev@...ts.ozlabs.org
Subject: Re: [PATCH V3 1/2] mm: Add get_user_pages_cma_migrate
Alexey Kardashevskiy <aik@...abs.ru> writes:
> On 16/10/2018 18:16, Aneesh Kumar K.V wrote:
>> Alexey Kardashevskiy <aik@...abs.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
Powered by blists - more mailing lists