Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3971091ybl; Mon, 9 Dec 2019 03:16:04 -0800 (PST) X-Google-Smtp-Source: APXvYqxO6tfAjkmiuGaGLq8znlWcrLty86iirBJ7BwyFFRhLSm0ilKskPKnCIEjoFdms8VeYcdcb X-Received: by 2002:aca:75d7:: with SMTP id q206mr18355261oic.9.1575890164463; Mon, 09 Dec 2019 03:16:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575890164; cv=none; d=google.com; s=arc-20160816; b=YKrbB5smmlJiV/olheNpKhF0k+E8vCdAcv0UQ+4kMhyw7Yi2EFHtpFv1CgmFflmYOQ A63h2nTH7sEKNvtJRJ11mUw7me9NRfhLrmR+jretU7e1wqBkPcNBq2QzMjZhoUqp01EZ NtPUBP8YF6qfZb7oKCjHgqsztaYwOOTBnt1r6nJ1Wcndy2ewiW0cprH6a0at4GRc4xcV UC47YS50fAGrkyXovmPNYJ6plDcEJeMof7f7Aidob3JqoTX0//Ge1v0ZOgcaw+5nrQ3Q w+iIDUa40Q7SjjUunp47hqsX9RaK+hklilbPxdmoKin72oiOWnqw92qZh2BDWyt+9rc+ YWzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=XZuRucHIqLwKPO1HxkQwabXKOayjrItxGS6v6m9PqXw=; b=F9aOD9p2W/qaw3Bm5G4XzpyBI6OXriR0IUytgOjjh5YmKuXfa07l03JYbtnfJd7wlu 9o0ul9BlpmNXHzo9uE5212RCZ2j8nWMkfpb51g4VWx82nv/ipZObALSTd5OF2AoT4rky MfxNfJiUqpmxy3EFtuQ38K9suEqO+x9WQ+8CjGh/+xs26Qbv6LosxNnwI9G8hqAy3WXr rOwzM4fpiS8Z2a2FYzRM+1M7xpXDo//QPW2kitDgJN+sdNYpzXKWen9Byveo3CJ4VdBZ 5sUFUIAbwzG5vc7vtsUbC9kgOFcuCihBYdKoIHC9s89/AP7UjMqgAx/ASS14cc0J3r1v x6/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=gGCrjof4; 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 e15si1719459otp.161.2019.12.09.03.15.52; Mon, 09 Dec 2019 03:16:04 -0800 (PST) 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; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=gGCrjof4; 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 S1727611AbfLILIj (ORCPT + 99 others); Mon, 9 Dec 2019 06:08:39 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:48203 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727599AbfLILIi (ORCPT ); Mon, 9 Dec 2019 06:08:38 -0500 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 47WgRQ3lb0z9sPc; Mon, 9 Dec 2019 22:08:34 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ellerman.id.au; s=201909; t=1575889716; bh=rYe8qrzC5Yad6k0eMTD1iKIi3I9u3ShpcDApHGCih3Q=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=gGCrjof44OinljG4Usq9loRpcZytu5Q1MmX9DfuOjt5J0oZKbDHKViLkY1olhW6TL pn3HGcv7TtoOBTs89AAkcK3LZjCcC3pXDiGZYqa3idH9EFVf0ZMTzTbQy2ifdjUnXs WWvGJ0hDpCBUzNv0pFFMRi6eJNsdTc4VS8zXAeqBueA217DSpk+dnzLbU3IurJsDim NmWi5VTrIrL4NS5d96cHb6EX8oD4F2+FEVHCHxaM4N6GC2ZDLMm5fPTxG5YYbCsM4W l+4EgpGiwjPYyVN9avCdVDu8fRbCUD5NAiTisSShqziayscWKNDKBtEW1ypOAZP5x8 1kdoBUkZl7b3w== From: Michael Ellerman To: Steven Price , Andrew Morton , linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?utf-8?B?SsOpcsO0bWU=?= Glisse , Peter Zijlstra , Thomas Gleixner , Will Deacon , x86@kernel.org, "H. Peter Anvin" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Rutland , "Liang\, Kan" , Benjamin Herrenschmidt , Paul Mackerras , linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org Subject: Re: [PATCH v16 06/25] powerpc: mm: Add p?d_leaf() definitions In-Reply-To: <20191206135316.47703-7-steven.price@arm.com> References: <20191206135316.47703-1-steven.price@arm.com> <20191206135316.47703-7-steven.price@arm.com> Date: Mon, 09 Dec 2019 22:08:32 +1100 Message-ID: <875ziprc27.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Steven Price writes: > walk_page_range() is going to be allowed to walk page tables other than > those of user space. For this it needs to know when it has reached a > 'leaf' entry in the page tables. This information is provided by the > p?d_leaf() functions/macros. > > For powerpc pmd_large() already exists and does what we want, so hoist > it out of the CONFIG_TRANSPARENT_HUGEPAGE condition and implement the > other levels. Macros are used to provide the generic p?d_leaf() names. > > CC: Benjamin Herrenschmidt > CC: Paul Mackerras > CC: Michael Ellerman > CC: linuxppc-dev@lists.ozlabs.org > CC: kvm-ppc@vger.kernel.org > Signed-off-by: Steven Price > --- > arch/powerpc/include/asm/book3s/64/pgtable.h | 30 ++++++++++++++------ > 1 file changed, 21 insertions(+), 9 deletions(-) > > diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h > index b01624e5c467..3dd7b6f5edd0 100644 > --- a/arch/powerpc/include/asm/book3s/64/pgtable.h > +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h > @@ -923,6 +923,12 @@ static inline int pud_present(pud_t pud) > return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PRESENT)); > } > > +#define pud_leaf pud_large > +static inline int pud_large(pud_t pud) > +{ > + return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); > +} We already have: #define pud_is_leaf pud_is_leaf static inline bool pud_is_leaf(pud_t pud) { return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); } And so on. These went in relatively recently in: d6eacedd1f0e ("powerpc/book3s: Use config independent helpers for page table walk") Assuming those all work for you, maybe your patch in this series should just do: #define pud_leaf pud_is_leaf And so on. And then we can do a patch later to change the arch/powerpc code to use pud_leaf() etc. directly and drop the "is" versions. cheers > @@ -966,6 +972,12 @@ static inline int pgd_present(pgd_t pgd) > return !!(pgd_raw(pgd) & cpu_to_be64(_PAGE_PRESENT)); > } > > +#define pgd_leaf pgd_large > +static inline int pgd_large(pgd_t pgd) > +{ > + return !!(pgd_raw(pgd) & cpu_to_be64(_PAGE_PTE)); > +} > + > static inline pte_t pgd_pte(pgd_t pgd) > { > return __pte_raw(pgd_raw(pgd)); > @@ -1133,6 +1145,15 @@ static inline bool pmd_access_permitted(pmd_t pmd, bool write) > return pte_access_permitted(pmd_pte(pmd), write); > } > > +#define pmd_leaf pmd_large > +/* > + * returns true for pmd migration entries, THP, devmap, hugetlb > + */ > +static inline int pmd_large(pmd_t pmd) > +{ > + return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); > +} > + > #ifdef CONFIG_TRANSPARENT_HUGEPAGE > extern pmd_t pfn_pmd(unsigned long pfn, pgprot_t pgprot); > extern pmd_t mk_pmd(struct page *page, pgprot_t pgprot); > @@ -1159,15 +1180,6 @@ pmd_hugepage_update(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp, > return hash__pmd_hugepage_update(mm, addr, pmdp, clr, set); > } > > -/* > - * returns true for pmd migration entries, THP, devmap, hugetlb > - * But compile time dependent on THP config > - */ > -static inline int pmd_large(pmd_t pmd) > -{ > - return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); > -} > - > static inline pmd_t pmd_mknotpresent(pmd_t pmd) > { > return __pmd(pmd_val(pmd) & ~_PAGE_PRESENT); > -- > 2.20.1