Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4072376ybl; Mon, 9 Dec 2019 05:07:13 -0800 (PST) X-Google-Smtp-Source: APXvYqyIIRR46mpOkOmtyjWqvXAdgCktshT3NVctPJfRn0GvzsneAgzCvdqLQZh/eCC8b7EMYMQU X-Received: by 2002:a05:6808:35a:: with SMTP id j26mr18439012oie.163.1575896833493; Mon, 09 Dec 2019 05:07:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575896833; cv=none; d=google.com; s=arc-20160816; b=FkDTK6JdLKFd129E2wUM40UKNH33yfLN3ZaTfBX5oXOpdmXeOtz1Z3nu0UytbCeKjb xFaFyh7hNERj3myUHZfCYmfyhuSKXnupIfBRd176Ks5AVPj7FzlqeANJcx+Z3XlU2ScB wRDh8jLrgo9LZT5QA/0chxZ1eWl3tn0p/BrQZiZcDSWug9er17taxxfWd6Xo2eiEbnW8 IK6w+sfn1R8xa8faNogpblAOzBTvSdwcAD0CIWcNtV/rlOlvQFBpBVu1S+xRNffc30sq mbUQtl6LhZQP6A/n1QkDZyw+InAUb2RSLjcFEw+dae2DLJZYT5y5shVkOAWkMBmjDUCu 7eGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=qj/E9EuqXfPICL5WU0qY+CIlbehJJWDxtw+cJ+T/oXs=; b=H8QA8S01kPISWR8+eTU6vSjSbfxWvz8FbVOIhO+2Nj+Dgb4ImexW1QgsuvJyhhvTiN BNT2lYfnxCoZE72W+6YUmfer81dl9LuXae44RLz5VieL7ooIN61xzXR0LW7toiQv14fO BSI7DjIUXF0MUDN7Xb0bK0QluEB3OeMWB4i7F2APRGloXentKfgHAfjegoiZfjX1kM+z 1cG0DNem3dfnTEBDWq3srk9tV1lwMQLYmlCrQ/0GUaQ7eDJFhlzKG/m9HzNBr43RARn1 /hZWrhVCMvBo8tJg3OzHoeKJsDAGoZOI/jhbbB605H7FVk0KnABLTl6i6gCvqHXz0ImJ cOYA== 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 t195si9663189oih.209.2019.12.09.05.07.01; Mon, 09 Dec 2019 05:07:13 -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; 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 S1727495AbfLINGe (ORCPT + 99 others); Mon, 9 Dec 2019 08:06:34 -0500 Received: from foss.arm.com ([217.140.110.172]:59892 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727388AbfLINGe (ORCPT ); Mon, 9 Dec 2019 08:06:34 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D6538328; Mon, 9 Dec 2019 05:06:30 -0800 (PST) Received: from [10.1.194.43] (e112269-lin.cambridge.arm.com [10.1.194.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E43BF3F718; Mon, 9 Dec 2019 05:06:27 -0800 (PST) Subject: Re: [PATCH v16 06/25] powerpc: mm: Add p?d_leaf() definitions To: Michael Ellerman , Andrew Morton , linux-mm@kvack.org Cc: Mark Rutland , Peter Zijlstra , Benjamin Herrenschmidt , Dave Hansen , Paul Mackerras , "H. Peter Anvin" , Will Deacon , "Liang, Kan" , x86@kernel.org, Ingo Molnar , Catalin Marinas , Arnd Bergmann , kvm-ppc@vger.kernel.org, =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , linux-kernel@vger.kernel.org, James Morse , linuxppc-dev@lists.ozlabs.org References: <20191206135316.47703-1-steven.price@arm.com> <20191206135316.47703-7-steven.price@arm.com> <875ziprc27.fsf@mpe.ellerman.id.au> From: Steven Price Message-ID: <6dec1a22-963a-226e-c7c8-c445daa35d29@arm.com> Date: Mon, 9 Dec 2019 13:06:26 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <875ziprc27.fsf@mpe.ellerman.id.au> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/12/2019 11:08, Michael Ellerman wrote: > 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. Thanks for pointing this out - these didn't exist when I started this patch series, but yes it would be a good idea to make use of them now. Followed by cleaning up to use the shorter p?d_leaf() versions in a later patch. Thanks, Steve > 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 > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel >