Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752733AbdCSUJ2 (ORCPT ); Sun, 19 Mar 2017 16:09:28 -0400 Received: from outbound-smtp05.blacknight.com ([81.17.249.38]:56402 "EHLO outbound-smtp05.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752623AbdCSUJZ (ORCPT ); Sun, 19 Mar 2017 16:09:25 -0400 Date: Sun, 19 Mar 2017 20:09:12 +0000 From: Mel Gorman To: J?r?me Glisse Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, John Hubbard , Naoya Horiguchi , David Nellans Subject: Re: [HMM 06/16] mm/migrate: add new boolean copy flag to migratepage() callback Message-ID: <20170319200912.GF2774@techsingularity.net> References: <1489680335-6594-1-git-send-email-jglisse@redhat.com> <1489680335-6594-7-git-send-email-jglisse@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1489680335-6594-7-git-send-email-jglisse@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3366 Lines: 98 On Thu, Mar 16, 2017 at 12:05:25PM -0400, J?r?me Glisse wrote: > Allow migration without copy in case destination page already have > source page content. This is usefull for new dma capable migration > where use device dma engine to copy pages. > > This feature need carefull audit of filesystem code to make sure > that no one can write to the source page while it is unmapped and > locked. It should be safe for most filesystem but as precaution > return error until support for device migration is added to them. > > Signed-off-by: J?r?me Glisse I really dislike the amount of boilerplace code this creates and the fact that additional headers are needed for that boilerplate. As it's only of relevance to DMA capable migration, why not simply infer from that if it's an option instead of updating all supporters of migration? If that is unsuitable, create a new migreate_mode for a no-copy migration. You'll need to alter some sites that check the migrate_mode and it *may* be easier to convert migrate_mode to a bitmask but overall it would be less boilerplate and confined to just the migration code. > diff --git a/mm/migrate.c b/mm/migrate.c > index 9a0897a..cb911ce 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -596,18 +596,10 @@ static void copy_huge_page(struct page *dst, struct page *src) > } > } > > -/* > - * Copy the page to its new location > - */ > -void migrate_page_copy(struct page *newpage, struct page *page) > +static void migrate_page_states(struct page *newpage, struct page *page) > { > int cpupid; > > - if (PageHuge(page) || PageTransHuge(page)) > - copy_huge_page(newpage, page); > - else > - copy_highpage(newpage, page); > - > if (PageError(page)) > SetPageError(newpage); > if (PageReferenced(page)) > @@ -661,6 +653,19 @@ void migrate_page_copy(struct page *newpage, struct page *page) > > mem_cgroup_migrate(page, newpage); > } > + > +/* > + * Copy the page to its new location > + */ > +void migrate_page_copy(struct page *newpage, struct page *page) > +{ > + if (PageHuge(page) || PageTransHuge(page)) > + copy_huge_page(newpage, page); > + else > + copy_highpage(newpage, page); > + > + migrate_page_states(newpage, page); > +} > EXPORT_SYMBOL(migrate_page_copy); > > /************************************************************ > @@ -674,8 +679,8 @@ EXPORT_SYMBOL(migrate_page_copy); > * Pages are locked upon entry and exit. > */ > int migrate_page(struct address_space *mapping, > - struct page *newpage, struct page *page, > - enum migrate_mode mode) > + struct page *newpage, struct page *page, > + enum migrate_mode mode, bool copy) > { > int rc; > > @@ -686,7 +691,11 @@ int migrate_page(struct address_space *mapping, > if (rc != MIGRATEPAGE_SUCCESS) > return rc; > > - migrate_page_copy(newpage, page); > + if (copy) > + migrate_page_copy(newpage, page); > + else > + migrate_page_states(newpage, page); > + > return MIGRATEPAGE_SUCCESS; > } > EXPORT_SYMBOL(migrate_page); Other than some reshuffling, this is the place where the new copy parameters it used and it has the mode parameter. At worst you end up creating a helper to check two potential migrate modes to have either ASYNC, SYNC or SYNC_LIGHT semantics. I expect you want SYNC symantics. This patch is huge relative to the small thing it acatually requires.