[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190221211038.GC5201@redhat.com>
Date: Thu, 21 Feb 2019 16:10:38 -0500
From: Jerome Glisse <jglisse@...hat.com>
To: ziy@...dia.com
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Dave Hansen <dave.hansen@...ux.intel.com>,
Michal Hocko <mhocko@...nel.org>,
"Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Vlastimil Babka <vbabka@...e.cz>,
Mel Gorman <mgorman@...hsingularity.net>,
John Hubbard <jhubbard@...dia.com>,
Mark Hairgrove <mhairgrove@...dia.com>,
Nitin Gupta <nigupta@...dia.com>,
David Nellans <dnellans@...dia.com>
Subject: Re: [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@...dia.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@...dia.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 ...
Powered by blists - more mailing lists