lkml.org 
[lkml]   [2019]   [Feb]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH 01/31] mm: migrate: Add exchange_pages to exchange two lists of pages.
On Fri, Feb 15, 2019 at 02:08:26PM -0800, Zi Yan wrote:
> From: Zi Yan <ziy@nvidia.com>
>
> In stead of using two migrate_pages(), a single exchange_pages() would
> be sufficient and without allocating new pages.

So i believe it would be better to arrange the code differently instead
of having one function that special case combination, define function for
each one ie:
exchange_anon_to_share()
exchange_anon_to_anon()
exchange_share_to_share()

Then you could define function to test if a page is in correct states:
can_exchange_anon_page() // return true if page can be exchange
can_exchange_share_page()

In fact both of this function can be factor out as common helpers with the
existing migrate code within migrate.c This way we would have one place
only where we need to handle all the special casing, test and exceptions.

Other than that i could not spot anything obviously wrong but i did not
spent enough time to check everything. Re-architecturing the code like
i propose above would make this a lot easier to review i believe.

Cheers,
Jérôme

>
> Signed-off-by: Zi Yan <ziy@nvidia.com>
> ---
> include/linux/ksm.h | 5 +
> mm/Makefile | 1 +
> mm/exchange.c | 846 ++++++++++++++++++++++++++++++++++++++++++++
> mm/internal.h | 6 +
> mm/ksm.c | 35 ++
> mm/migrate.c | 4 +-
> 6 files changed, 895 insertions(+), 2 deletions(-)
> create mode 100644 mm/exchange.c

[...]

> + from_page_count = page_count(from_page);
> + from_map_count = page_mapcount(from_page);
> + to_page_count = page_count(to_page);
> + to_map_count = page_mapcount(to_page);
> + from_flags = from_page->flags;
> + to_flags = to_page->flags;
> + from_mapping = from_page->mapping;
> + to_mapping = to_page->mapping;
> + from_index = from_page->index;
> + to_index = to_page->index;

Those are not use anywhere ...

\
 
 \ /
  Last update: 2019-02-21 22:11    [W:0.170 / U:11.284 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site