Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4360010imm; Mon, 8 Oct 2018 21:00:49 -0700 (PDT) X-Google-Smtp-Source: ACcGV63993jRJvg2rZVZJGcxrB37hQ5wlXtRqkuJ5wCTUIVufTBpehiGKO3k1DQFVfJYa0/69aAA X-Received: by 2002:a63:fb54:: with SMTP id w20-v6mr24078766pgj.321.1539057649504; Mon, 08 Oct 2018 21:00:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539057649; cv=none; d=google.com; s=arc-20160816; b=iYzc7cINTspHlCvlIPoaKi0M3Crhcau9FmlHVv3s8vTIgfREqE7AZHqYLQyJN3nOBx uZeo0kiWGWkQzL3JH+dzViIhuhV/eSG77jNKrm08CXFQckhgS8+BY+T8Nr/w1EJqpqIp w2I7OLX90Y2x4T76+h5+kS4Mz1g2Fyu7tHOg3S7WSZHaxV0SslC4hLLMqQEkNF5BDKr+ WdOFSYlpejqF+TPk2HxJQS5HrDQ4RxsPPJ9tOXA9l5RTT76jCYIemmVSeWCBdUGhS0+m zpPZ8OzFNXkP6HLgUZe6cHEeSU30nuYUWE4iK9yIIeYqnUy2l9utTbcxwJAp8W0JZS99 56og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=56+e1VyqfDbDbGwFDpAnIaiP5vmVSj3/nv12XccDCrg=; b=m8EqDqLF9s1+U+8RaWTU7Cdbr3Tzf9GQBm+qJs8v5nD/psxzJZmZlI+u1BEVKp32SI fu6x4jEJ0w+CiBJWmSaLPM3LKpe85Z28c2Q3VReFdP/E+GoilCmBFtGkIdmbI5/nvWhc knSi8bjd//1gFbAACW1cyT8UbcflTk/1MX9f7ZSqDPgvRSpERglmZChGX9HCwzQMLAtV ah728iUcl6KrSNEl0BG5c5m2EU6VsQN4uADFA4Rse6V/n7WkEDGP4kOayOshcfDXBjnw FC0+EGg0fSsOLyGQXqJADB9c2B0fZbgJQD77szi5aD8O48/GRUrG8+ya8DIUPPWjNrZU 0lvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 34-v6si18829122pgt.95.2018.10.08.21.00.35; Mon, 08 Oct 2018 21:00:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726616AbeJILOH (ORCPT + 99 others); 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