From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44E11C64EB0 for ; Tue, 9 Oct 2018 03:59:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 09FFB2085B for ; Tue, 9 Oct 2018 03:59:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 09FFB2085B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726642AbeJILOH (ORCPT ); Tue, 9 Oct 2018 07:14:07 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:59800 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725803AbeJILOH (ORCPT ); Tue, 9 Oct 2018 07:14:07 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B2093ED1; Mon, 8 Oct 2018 20:59:14 -0700 (PDT) Received: from p8cg001049571a15.blr.arm.com (p8cg001049571a15.blr.arm.com [10.162.0.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7221C3F5B3; Mon, 8 Oct 2018 20:59:12 -0700 (PDT) From: Anshuman Khandual To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: kirill.shutemov@linux.intel.com, akpm@linux-foundation.org, mhocko@suse.com, zi.yan@cs.rutgers.edu, will.deacon@arm.com Subject: [PATCH] mm/thp: Correctly differentiate between mapped THP and PMD migration entry Date: Tue, 9 Oct 2018 09:28:58 +0530 Message-Id: <1539057538-27446-1-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A normal mapped THP page at PMD level should be correctly differentiated from a PMD migration entry while walking the page table. A mapped THP would additionally check positive for pmd_present() along with pmd_trans_huge() as compared to a PMD migration entry. This just adds a new conditional test differentiating the two while walking the page table. Fixes: 616b8371539a6 ("mm: thp: enable thp migration in generic path") Signed-off-by: Anshuman Khandual --- On X86, pmd_trans_huge() and is_pmd_migration_entry() are always mutually exclusive which makes the current conditional block work for both mapped and migration entries. This is not same with arm64 where pmd_trans_huge() returns positive for both mapped and migration entries. Could some one please explain why pmd_trans_huge() has to return false for migration entries which just install swap bits and its still a PMD ? Nonetheless pmd_present() seems to be a better check to distinguish between mapped and (non-mapped non-present) migration entries without any ambiguity. mm/page_vma_mapped.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index ae3c2a3..b384396 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -161,7 +161,8 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) pmde = READ_ONCE(*pvmw->pmd); if (pmd_trans_huge(pmde) || is_pmd_migration_entry(pmde)) { pvmw->ptl = pmd_lock(mm, pvmw->pmd); - if (likely(pmd_trans_huge(*pvmw->pmd))) { + if (likely(pmd_trans_huge(*pvmw->pmd) && + pmd_present(*pvmw->pmd))) { if (pvmw->flags & PVMW_MIGRATION) return not_found(pvmw); if (pmd_page(*pvmw->pmd) != page) -- 2.7.4