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=-6.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, 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 BE68FCA9EAF for ; Thu, 24 Oct 2019 13:07:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6A98E20659 for ; Thu, 24 Oct 2019 13:07:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="n5TAheGl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A98E20659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1C7376B0007; Thu, 24 Oct 2019 09:07:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 176B76B0008; Thu, 24 Oct 2019 09:07:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0654D6B000A; Thu, 24 Oct 2019 09:07:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0133.hostedemail.com [216.40.44.133]) by kanga.kvack.org (Postfix) with ESMTP id D2CD06B0007 for ; Thu, 24 Oct 2019 09:07:08 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 72D4B824999B for ; Thu, 24 Oct 2019 13:07:08 +0000 (UTC) X-FDA: 76078703736.12.brass91_3e41d751c2e52 X-HE-Tag: brass91_3e41d751c2e52 X-Filterd-Recvd-Size: 9430 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Thu, 24 Oct 2019 13:07:07 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id a21so2247977ljh.9 for ; Thu, 24 Oct 2019 06:07:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=tkk6G5aHv6FVuWM741oKE389BRFXRaj6IbXbEW6yA1Y=; b=n5TAheGlAHyqwUFch1gDhnr7YjBFCO1Wk56bpymnySGUNJ3WfCvdDHuboiKcMLQb03 exkAUP0/TUfc1Jl1ZJCgn3dDFQ1DhlaF3mDeu/CLPPluUcMVLAyNVCpeNyrzBpsO4vF/ cVUkbHTKHKfV2Bv+s14y50GtUjXSCwmI8wz5pxmcBb8eYC3ur8o5dIgFlf2ZPkzw532K Kep1ZzfRHm3cY/zfGx2nIBzyUjOPHKZ5oZg7ZkcA3pAr9Sl12cV03Y1cupWc1fwDsvTu L7g8XjIgybiySuSzD7LZXc+Bc7zrDeL+gBhlkrcxCtrsVtq5TkpYqDETZLk77gNl5CXS FLMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=tkk6G5aHv6FVuWM741oKE389BRFXRaj6IbXbEW6yA1Y=; b=id9CC9NTJrMEr15XEzLXBCJnvusQnp9Q0dM/9eHDv5vArNEtViSv9ETj1aDM6eUd/L 1dF1bI1K0elW3Tr0LXgDKO3Mok2wA7zbaxMNvcowj5GLd7LYD09ns/4uL7Vc/C5WYNLH egrzKA3cFLpqurhTf+Aj2EruYrfucewzjoy7w8OWcXK+QJhpPqXLRWN28R8JxqR3nTNf ZBfiB91eHjWIxK8T/Z32NQG2OHsbTgQ9L7O2Z/bqcz+P8yHsDYcNjVyCUSDZTPHUVcaE F54bJJv3g4ohguBGHAYgxSkuxsumSDaWhSE7ju4XfPZEbqPXu5QzXQYBw3UigERIJ80v lD6g== X-Gm-Message-State: APjAAAUW4I2Q9MPk0msrC9IDEuqisTizRKBsqAwe/sWSBFM4PpJ7bHZw Ub8ghRIlkSbUSc1/Vi7PrctepTTyycGPhUb7PZI= X-Google-Smtp-Source: APXvYqwKbGmB3fZE31Be7iKOqtLOx2kBt/iIU4EzatUeJ/XuUjsrMJXzEx7sWNPPbTCPFOfdQZVsoTbIcyjaEJ7/0eo= X-Received: by 2002:a2e:970b:: with SMTP id r11mr9317177lji.56.1571922426444; Thu, 24 Oct 2019 06:07:06 -0700 (PDT) MIME-Version: 1.0 References: <20191018101248.33727-1-steven.price@arm.com> <20191018101248.33727-12-steven.price@arm.com> In-Reply-To: <20191018101248.33727-12-steven.price@arm.com> From: Zong Li Date: Thu, 24 Oct 2019 21:06:55 +0800 Message-ID: Subject: Re: [PATCH v12 11/22] mm: pagewalk: Add p4d_entry() and pgd_entry() To: Steven Price Cc: linux-mm@kvack.org, Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Peter Zijlstra , Thomas Gleixner , Will Deacon , x86@kernel.org, "H. Peter Anvin" , linux-arm-kernel@lists.infradead.org, Linux Kernel Mailing List , Mark Rutland , "Liang, Kan" , Andrew Morton Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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: Steven Price =E6=96=BC 2019=E5=B9=B410=E6=9C=8819=E6= =97=A5 =E9=80=B1=E5=85=AD =E4=B8=8B=E5=8D=884:14=E5=AF=AB=E9=81=93=EF=BC=9A > > pgd_entry() and pud_entry() were removed by commit 0b1fbfe50006c410 > ("mm/pagewalk: remove pgd_entry() and pud_entry()") because there were > no users. We're about to add users so reintroduce them, along with > p4d_entry() as we now have 5 levels of tables. > > Note that commit a00cc7d9dd93d66a ("mm, x86: add support for > PUD-sized transparent hugepages") already re-added pud_entry() but with > different semantics to the other callbacks. Since there have never > been upstream users of this, revert the semantics back to match the > other callbacks. This means pud_entry() is called for all entries, not > just transparent huge pages. > > Signed-off-by: Steven Price > --- > include/linux/pagewalk.h | 19 +++++++++++++------ > mm/pagewalk.c | 27 ++++++++++++++++----------- > 2 files changed, 29 insertions(+), 17 deletions(-) > > diff --git a/include/linux/pagewalk.h b/include/linux/pagewalk.h > index bddd9759bab9..12004b097eae 100644 > --- a/include/linux/pagewalk.h > +++ b/include/linux/pagewalk.h > @@ -8,15 +8,15 @@ struct mm_walk; > > /** > * mm_walk_ops - callbacks for walk_page_range > - * @pud_entry: if set, called for each non-empty PUD (2nd-level)= entry > - * this handler should only handle pud_trans_huge() = puds. > - * the pmd_entry or pte_entry callbacks will be used= for > - * regular PUDs. > - * @pmd_entry: if set, called for each non-empty PMD (3rd-level)= entry > + * @pgd_entry: if set, called for each non-empty PGD (top-level)= entry > + * @p4d_entry: if set, called for each non-empty P4D entry > + * @pud_entry: if set, called for each non-empty PUD entry > + * @pmd_entry: if set, called for each non-empty PMD entry > * this handler is required to be able to handle > * pmd_trans_huge() pmds. They may simply choose to > * split_huge_page() instead of handling it explicit= ly. > - * @pte_entry: if set, called for each non-empty PTE (4th-level)= entry > + * @pte_entry: if set, called for each non-empty PTE (lowest-lev= el) > + * entry > * @pte_hole: if set, called for each hole at all levels > * @hugetlb_entry: if set, called for each hugetlb entry > * @test_walk: caller specific callback function to determine wh= ether > @@ -24,8 +24,15 @@ struct mm_walk; > * "do page table walk over the current vma", return= ing > * a negative value means "abort current page table = walk > * right now" and returning 1 means "skip the curren= t vma" > + * > + * p?d_entry callbacks are called even if those levels are folded on a > + * particular architecture/configuration. > */ > struct mm_walk_ops { > + int (*pgd_entry)(pgd_t *pgd, unsigned long addr, > + unsigned long next, struct mm_walk *walk); > + int (*p4d_entry)(p4d_t *p4d, unsigned long addr, > + unsigned long next, struct mm_walk *walk); > int (*pud_entry)(pud_t *pud, unsigned long addr, > unsigned long next, struct mm_walk *walk); > int (*pmd_entry)(pmd_t *pmd, unsigned long addr, > diff --git a/mm/pagewalk.c b/mm/pagewalk.c > index d48c2a986ea3..fc4d98a3a5a0 100644 > --- a/mm/pagewalk.c > +++ b/mm/pagewalk.c > @@ -93,15 +93,9 @@ static int walk_pud_range(p4d_t *p4d, unsigned long ad= dr, unsigned long end, > } > > if (ops->pud_entry) { > - spinlock_t *ptl =3D pud_trans_huge_lock(pud, walk= ->vma); > - > - if (ptl) { > - err =3D ops->pud_entry(pud, addr, next, w= alk); > - spin_unlock(ptl); > - if (err) > - break; > - continue; > - } > + err =3D ops->pud_entry(pud, addr, next, walk); > + if (err) > + break; > } > > split_huge_pud(walk->vma, pud, addr); > @@ -135,7 +129,12 @@ static int walk_p4d_range(pgd_t *pgd, unsigned long = addr, unsigned long end, > break; > continue; > } > - if (ops->pmd_entry || ops->pte_entry) > + if (ops->p4d_entry) { > + err =3D ops->p4d_entry(p4d, addr, next, walk); > + if (err) > + break; > + } > + if (ops->pud_entry || ops->pmd_entry || ops->pte_entry) > err =3D walk_pud_range(p4d, addr, next, walk); > if (err) > break; > @@ -162,7 +161,13 @@ static int walk_pgd_range(unsigned long addr, unsign= ed long end, > break; > continue; > } > - if (ops->pmd_entry || ops->pte_entry) > + if (ops->pgd_entry) { > + err =3D ops->pgd_entry(pgd, addr, next, walk); > + if (err) > + break; > + } > + if (ops->p4d_entry || ops->pud_entry || ops->pmd_entry || > + ops->pte_entry) > err =3D walk_p4d_range(pgd, addr, next, walk); > if (err) > break; > -- > 2.20.1 > It's good to me. Tested-by: Zong Li