From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753432AbbDPTfI (ORCPT ); Thu, 16 Apr 2015 15:35:08 -0400 Received: from cantor2.suse.de ([195.135.220.15]:49938 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751501AbbDPTe7 (ORCPT ); Thu, 16 Apr 2015 15:34:59 -0400 Date: Thu, 16 Apr 2015 20:34:54 +0100 From: Mel Gorman To: Hugh Dickins Cc: Linux-MM , Rik van Riel , Minchan Kim , Dave Hansen , Andi Kleen , LKML Subject: Re: [PATCH 4/4] mm: migrate: Batch TLB flushing when unmapping pages for migration Message-ID: <20150416193454.GT14842@suse.de> References: <1429179766-26711-1-git-send-email-mgorman@suse.de> <1429179766-26711-5-git-send-email-mgorman@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 16, 2015 at 11:57:15AM -0700, Hugh Dickins wrote: > > @@ -1098,6 +1098,8 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, > > if (!swapwrite) > > current->flags |= PF_SWAPWRITE; > > > > + alloc_tlb_ubc(); > > + > > for(pass = 0; pass < 10 && retry; pass++) { > > retry = 0; > > > > @@ -1144,6 +1146,8 @@ out: > > if (!swapwrite) > > current->flags &= ~PF_SWAPWRITE; > > > > + try_to_unmap_flush(); > > This is the right place to aim to flush, but I think you have to make > more changes before it is safe to do so here. > > The putback_lru_page(page) in unmap_and_move() is commented "A page > that has been migrated has all references removed and will be freed". > > If you leave TLB flushing until after the page has been freed, then > there's a risk that userspace will see, not the data it expects at > whatever virtual address, but data placed in there by the next user > of this freed page. > > So you'll need to do a little restructuring first. > Well spotted. I believe you are correct and it almost certainly applies to patch 2 as well for similar reasons. It also impacts the maximum reasonable batch size that can be managed while maintaing safety. I'll do the necessary shuffling tomorrow or Monday. -- Mel Gorman SUSE Labs