Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757997AbcCCQWa (ORCPT ); Thu, 3 Mar 2016 11:22:30 -0500 Received: from www9186uo.sakura.ne.jp ([153.121.56.200]:58222 "EHLO www9186uo.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752348AbcCCQW2 (ORCPT ); Thu, 3 Mar 2016 11:22:28 -0500 X-Greylist: delayed 435 seconds by postgrey-1.27 at vger.kernel.org; Thu, 03 Mar 2016 11:22:28 EST Date: Fri, 4 Mar 2016 01:15:54 +0900 From: Naoya Horiguchi To: "Kirill A. Shutemov" Cc: Naoya Horiguchi , linux-mm@kvack.org, "Kirill A. Shutemov" , Hugh Dickins , Andrew Morton , Dave Hansen , Andrea Arcangeli , Mel Gorman , Michal Hocko , Vlastimil Babka , Pavel Emelyanov , linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 05/11] mm: thp: check pmd migration entry in common path Message-ID: <20160303161554.GB14896@www9186uo.sakura.ne.jp> References: <1456990918-30906-1-git-send-email-n-horiguchi@ah.jp.nec.com> <1456990918-30906-6-git-send-email-n-horiguchi@ah.jp.nec.com> <20160303105058.GC30948@node.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-2022-jp Content-Disposition: inline In-Reply-To: <20160303105058.GC30948@node.shutemov.name> User-Agent: Mutt/1.5.20 (2009-12-10) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2058 Lines: 49 On Thu, Mar 03, 2016 at 01:50:58PM +0300, Kirill A. Shutemov wrote: > On Thu, Mar 03, 2016 at 04:41:52PM +0900, Naoya Horiguchi wrote: > > If one of callers of page migration starts to handle thp, memory management code > > start to see pmd migration entry, so we need to prepare for it before enabling. > > This patch changes various code point which checks the status of given pmds in > > order to prevent race between thp migration and the pmd-related works. > > > > Signed-off-by: Naoya Horiguchi > > --- > > arch/x86/mm/gup.c | 3 +++ > > fs/proc/task_mmu.c | 25 +++++++++++++-------- > > mm/gup.c | 8 +++++++ > > mm/huge_memory.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++------ > > mm/memcontrol.c | 2 ++ > > mm/memory.c | 5 +++++ > > 6 files changed, 93 insertions(+), 16 deletions(-) > > > > diff --git v4.5-rc5-mmotm-2016-02-24-16-18/arch/x86/mm/gup.c v4.5-rc5-mmotm-2016-02-24-16-18_patched/arch/x86/mm/gup.c > > index f8d0b5e..34c3d43 100644 > > --- v4.5-rc5-mmotm-2016-02-24-16-18/arch/x86/mm/gup.c > > +++ v4.5-rc5-mmotm-2016-02-24-16-18_patched/arch/x86/mm/gup.c > > @@ -10,6 +10,7 @@ > > #include > > #include > > #include > > +#include > > > > #include > > > > @@ -210,6 +211,8 @@ static int gup_pmd_range(pud_t pud, unsigned long addr, unsigned long end, > > if (pmd_none(pmd)) > > return 0; > > if (unlikely(pmd_large(pmd) || !pmd_present(pmd))) { > > + if (unlikely(is_pmd_migration_entry(pmd))) > > + return 0; > > Hm. I've expected to see bunch of pmd_none() to pmd_present() conversions. > That's seems a right way guard the code. Otherwise we wound need even more > checks once PMD-level swap is implemented. Yes, I agree. I'll try some for this pmd_none/pmd_present issue. Thanks, Naoya > > I think we need to check for migration entires only if we have something > to do with migration. In all other cases pmd_present() should be enough to > bail out.