From patchwork Thu Jun 10 22:25:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 458469 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED 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 0AD8EC48BE0 for ; Thu, 10 Jun 2021 22:25:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA202613FF for ; Thu, 10 Jun 2021 22:25:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230385AbhFJW1W (ORCPT ); Thu, 10 Jun 2021 18:27:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:33346 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230447AbhFJW1W (ORCPT ); Thu, 10 Jun 2021 18:27:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 01E6B613DE; Thu, 10 Jun 2021 22:25:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1623363909; bh=mbEeI0Q1rpxV1yAh7M12M7twPTC/6Y7E9w+fuB9rNdw=; h=Date:From:To:Subject:From; b=cH3Y15+W4ph+DnLrRx6Cr457OWQxSIqy50bzKXMi8LxYj4kEuiMghYRtCrJxvt3vp pt/82SwYHdwZsD23NiO0Me+9Gn8sCLktx+IyBvFcKr5ucrHneBNkggYGIHdNoNUkBn 2IoSezQF4gZnNatcLBKpsJ6TQ7z2QyzpRDsnaKDw= Date: Thu, 10 Jun 2021 15:25:08 -0700 From: akpm@linux-foundation.org To: apopple@nvidia.com, hughd@google.com, kirill.shutemov@linux.intel.com, mm-commits@vger.kernel.org, peterx@redhat.com, rcampbell@nvidia.com, shy828301@gmail.com, stable@vger.kernel.org, wangyugui@e16-tech.com, will@kernel.org, willy@infradead.org, ziy@nvidia.com Subject: + mm-page_vma_mapped_walk-settle-pagehuge-on-entry.patch added to -mm tree Message-ID: <20210610222508.G4AEKRv6c%akpm@linux-foundation.org> User-Agent: s-nail v14.8.16 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch titled Subject: mm: page_vma_mapped_walk(): settle PageHuge on entry has been added to the -mm tree. Its filename is mm-page_vma_mapped_walk-settle-pagehuge-on-entry.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-page_vma_mapped_walk-settle-pagehuge-on-entry.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-page_vma_mapped_walk-settle-pagehuge-on-entry.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Hugh Dickins Subject: mm: page_vma_mapped_walk(): settle PageHuge on entry page_vma_mapped_walk() cleanup: get the hugetlbfs PageHuge case out of the way at the start, so no need to worry about it later. Link: https://lkml.kernel.org/r/e31a483c-6d73-a6bb-26c5-43c3b880a2@google.com Signed-off-by: Hugh Dickins Acked-by: Kirill A. Shutemov Reviewed-by: Peter Xu Cc: Alistair Popple Cc: "Kirill A. Shutemov" Cc: Matthew Wilcox Cc: Ralph Campbell Cc: Wang Yugui Cc: Will Deacon Cc: Yang Shi Cc: Zi Yan Cc: Signed-off-by: Andrew Morton --- mm/page_vma_mapped.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/mm/page_vma_mapped.c~mm-page_vma_mapped_walk-settle-pagehuge-on-entry +++ a/mm/page_vma_mapped.c @@ -153,10 +153,11 @@ bool page_vma_mapped_walk(struct page_vm if (pvmw->pmd && !pvmw->pte) return not_found(pvmw); - if (pvmw->pte) - goto next_pte; - if (unlikely(PageHuge(page))) { + /* The only possible mapping was handled on last iteration */ + if (pvmw->pte) + return not_found(pvmw); + /* when pud is not present, pte will be NULL */ pvmw->pte = huge_pte_offset(mm, pvmw->address, page_size(page)); if (!pvmw->pte) @@ -168,6 +169,9 @@ bool page_vma_mapped_walk(struct page_vm return not_found(pvmw); return true; } + + if (pvmw->pte) + goto next_pte; restart: pgd = pgd_offset(mm, pvmw->address); if (!pgd_present(*pgd)) @@ -233,7 +237,7 @@ restart: return true; next_pte: /* Seek to next pte only makes sense for THP */ - if (!PageTransHuge(page) || PageHuge(page)) + if (!PageTransHuge(page)) return not_found(pvmw); end = vma_address_end(page, pvmw->vma); do {