From patchwork Tue Oct 9 03:58:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 10631795 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7775514BD for ; Tue, 9 Oct 2018 03:59:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 691502993B for ; Tue, 9 Oct 2018 03:59:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D19F299DD; Tue, 9 Oct 2018 03:59:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C64682993B for ; Tue, 9 Oct 2018 03:59:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C1D56B0003; Mon, 8 Oct 2018 23:59:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 349A96B0005; Mon, 8 Oct 2018 23:59:17 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1EAF36B0006; Mon, 8 Oct 2018 23:59:17 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) by kanga.kvack.org (Postfix) with ESMTP id E24E96B0003 for ; Mon, 8 Oct 2018 23:59:16 -0400 (EDT) Received: by mail-oi1-f198.google.com with SMTP id e136-v6so150437oib.11 for ; Mon, 08 Oct 2018 20:59:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=56+e1VyqfDbDbGwFDpAnIaiP5vmVSj3/nv12XccDCrg=; b=R2azXoQDQVbGWpqcofQW9vzQoKeayF2dqPHno+IUtxkStwDiNZDjCqEiM6Qah9xntG +H+1u2bzS2Uv3UP/Yvi2Wz5eKZNBP9aeEVVeIyMwEGa2ZSeQQ2Sdc7TNe6P42rCEu3Pg AY14l/qVX+AcBlumjPkw2AGhmNt6puy0iCBybDfaWMpMpQzrHaSQFyN7AOriq8AE879w zKl3YO15/GyRS4oQ6h2ITtHAxN4BIOW/Ozu2B3pZJxiULZaQgez7flZTGHZ6YylN4GCH 6Zur+eKKptFOaaJxaYeVJ/q/C0dJ9dPsvJd25DLtkVLyXjqhDQ/SiWq2EDKedhY7APse GMlg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of anshuman.khandual@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com X-Gm-Message-State: ABuFfohxDipbrHWZlPtkWl3A8eJ5jKexe9dtk36Epziz9SmFs5xAOF+U uQqe54iEcTjWRNaCTj5yTUpVAOjFrK8051KYqmtU5LGmFltr7nqV5EibYSF0iuCI+GG7f4Tr7Y7 2KbnCOeG3+SR/u39wn1CHAHJpWSOPR1KN2WjrHuSFeX+eQor0fhh2iSSLc66imp1FRA== X-Received: by 2002:aca:5541:: with SMTP id j62-v6mr5657357oib.202.1539057556577; Mon, 08 Oct 2018 20:59:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV61h5PLI2rH0C3VaGBfLjxYevFSm80hEyUP3BVSEIGApIMa/2aMP7yN190JJ+8bsPzR6kFG9 X-Received: by 2002:aca:5541:: with SMTP id j62-v6mr5657349oib.202.1539057555805; Mon, 08 Oct 2018 20:59:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539057555; cv=none; d=google.com; s=arc-20160816; b=PMZ1RdlMccTAv90zXgOKjCbGrhbz+/1339v6ILAAtlG2cKBCoRnnL43ZlhTt6UAbxx euvoz0sQd2J+qPZxIKDUxCEM2mkumt83TjnDl/Os8K04MdR934fqO3RuXvNnEebYFmUh NytIOKY+RyXtdaqp+fDDGvnVuFhFrrCyOm5LZTMfYN36OYV65heKeiYAgzTmJ3OBY3Zm 6pu379wNENZ/DBJKapjQvJ4RfolRW1+Q+txwW15LPxyDXEW9H06yUaiyfOhPbpYx4u7D 6D7cnyxDeUEsF7Xakh2inhqLYMQJulsgf5X246timr3IQSCfszn8ZniW+Iim04qk9xVe G23Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from; bh=56+e1VyqfDbDbGwFDpAnIaiP5vmVSj3/nv12XccDCrg=; b=toCaTdd2HzswfXBLfC+jwy8P1YprBObUZgxY42T2LdojKbWNHGHPzln+k1Gb7DCLZD Kb0K5kADiSO16mELoEApGBOtUhtdU1p/49+2C9PqEiH1FLdV6x/Nr0SWOIT+5SqzrGtl dbL7At0CfqKjMJ1fZb1waAZ04eVILUfVLh8e3qeS5qNv/liCF+DU5adrhUegfvTuFFrT OWl5eEFn/Bv2jEFiVcoxc7dg0mkEktsOs2jprXjNouN8cI9tbDXp9aFYvczhN3HcJBOC VSkzm6xGxmY083ZcGZ9o/xQokR+gAWkpvXYY8XXbfusV4GTbCmDLUl4v7ZZo1qZhJjnQ dgsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of anshuman.khandual@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id l18-v6si8424775oth.164.2018.10.08.20.59.15 for ; Mon, 08 Oct 2018 20:59:15 -0700 (PDT) Received-SPF: pass (google.com: domain of anshuman.khandual@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of anshuman.khandual@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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)