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.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 BEC66C2D0D2 for ; Sat, 21 Dec 2019 10:36:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8399E2070C for ; Sat, 21 Dec 2019 10:36:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ellerman.id.au header.i=@ellerman.id.au header.b="ep41QhtA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8399E2070C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 18CDE8E01ED; Sat, 21 Dec 2019 05:36:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 116478E01DF; Sat, 21 Dec 2019 05:36:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF8AF8E01ED; Sat, 21 Dec 2019 05:36:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0111.hostedemail.com [216.40.44.111]) by kanga.kvack.org (Postfix) with ESMTP id D4BA58E01DF for ; Sat, 21 Dec 2019 05:36:09 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8CC898249980 for ; Sat, 21 Dec 2019 10:36:09 +0000 (UTC) X-FDA: 76288793658.01.idea00_52bcde7eb4117 X-HE-Tag: idea00_52bcde7eb4117 X-Filterd-Recvd-Size: 5212 Received: from ozlabs.org (ozlabs.org [203.11.71.1]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Sat, 21 Dec 2019 10:36:08 +0000 (UTC) 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 47g28K257Sz9sP3; Sat, 21 Dec 2019 21:36:00 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ellerman.id.au; s=201909; t=1576924564; bh=J7LUOTE/TlZOLs6A/wa+UANDkPEn7Eg1zFTj8wUajJI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ep41QhtAkIMLmb7QDcQVXIPZu6eWAkKvUoCMT0vcG19lbSzTpQrhOY0RxwufoQWlr LQ1BmfV7J1TETBUuG4Zte4C+sy844RNzMmdObEjG1Hn78EWxQ6MrZ2BO6a2QJ7arOB WNWwjt5PYt4vaCuR7fXbXeF/YzH0MXc6/DVIUe3pj3pV5riIbedpKaUKpriN7JhrAQ jG/xg31T7EuVHMhRJNGQEhdDgK+H6xZ3tIc509ldRJQ6hcK7vKbpuSq9803rqVIGg1 qnNNuaS7Xhk8LN6WkdwrrJPegHM9vgRPBBTYCnI8MEDt3bBsz0Mrp4ILMK/QIYhWkn FuaJbuiHRMeFg== From: Michael Ellerman To: Steven Price , Andrew Morton , linux-mm@kvack.org Cc: Mark Rutland , x86@kernel.org, Arnd Bergmann , Ard Biesheuvel , Peter Zijlstra , Catalin Marinas , Dave Hansen , linux-kernel@vger.kernel.org, =?utf-8?B?SsOpcsO0bWU=?= Glisse , Ingo Molnar , Borislav Petkov , Andy Lutomirski , "H. Peter Anvin" , James Morse , Thomas Gleixner , Will Deacon , linux-arm-kernel@lists.infradead.org, "Liang\, Kan" Subject: Re: [PATCH v17 01/23] mm: Add generic p?d_leaf() macros In-Reply-To: <0951d79f-919a-4a9d-00f7-b40be96af118@arm.com> References: <20191218162402.45610-1-steven.price@arm.com> <20191218162402.45610-2-steven.price@arm.com> <878sn8mtgt.fsf@mpe.ellerman.id.au> <0951d79f-919a-4a9d-00f7-b40be96af118@arm.com> Date: Sat, 21 Dec 2019 21:35:58 +1100 Message-ID: <87v9qakltd.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain 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 writes: > On 19/12/2019 11:43, Michael Ellerman wrote: >> Steven Price writes: >>> Exposing the pud/pgd levels of the page tables to walk_page_range() means >>> we may come across the exotic large mappings that come with large areas >>> of contiguous memory (such as the kernel's linear map). >>> >>> For architectures that don't provide all p?d_leaf() macros, provide >>> generic do nothing default that are suitable where there cannot be leaf >>> pages at that level. Futher patches will add implementations for >>> individual architectures. >>> >>> The name p?d_leaf() is chosen to minimize the confusion with existing >>> uses of "large" pages and "huge" pages which do not necessary mean that >>> the entry is a leaf (for example it may be a set of contiguous entries >>> that only take 1 TLB slot). For the purpose of walking the page tables >>> we don't need to know how it will be represented in the TLB, but we do >>> need to know for sure if it is a leaf of the tree. >>> >>> Signed-off-by: Steven Price >>> Acked-by: Mark Rutland >>> --- >>> include/asm-generic/pgtable.h | 20 ++++++++++++++++++++ >>> 1 file changed, 20 insertions(+) >>> >>> diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h >>> index 798ea36a0549..e2e2bef07dd2 100644 >>> --- a/include/asm-generic/pgtable.h >>> +++ b/include/asm-generic/pgtable.h >>> @@ -1238,4 +1238,24 @@ static inline bool arch_has_pfn_modify_check(void) >>> #define mm_pmd_folded(mm) __is_defined(__PAGETABLE_PMD_FOLDED) >>> #endif >>> >>> +/* >>> + * p?d_leaf() - true if this entry is a final mapping to a physical address. >>> + * This differs from p?d_huge() by the fact that they are always available (if >>> + * the architecture supports large pages at the appropriate level) even >>> + * if CONFIG_HUGETLB_PAGE is not defined. >>> + * Only meaningful when called on a valid entry. >>> + */ >>> +#ifndef pgd_leaf >>> +#define pgd_leaf(x) 0 >>> +#endif >>> +#ifndef p4d_leaf >>> +#define p4d_leaf(x) 0 >>> +#endif >>> +#ifndef pud_leaf >>> +#define pud_leaf(x) 0 >>> +#endif >>> +#ifndef pmd_leaf >>> +#define pmd_leaf(x) 0 >>> +#endif >> >> Any reason you made these #defines rather than static inlines? > > No strong reason - but these have to be #defines in the arch overrides > so the #ifndef works, so I was being consistent here. We handle that usually just with eg: static inline bool pgd_leaf(pgd_t pgd) { ... } #define pgd_leaf pgd_leaf > I guess a static inline might avoid warnings although I haven't seen > any. If anything I'd expect it to cause warnings, for example if someone is doing pgd_leaf(pmd), but that would be good to catch. cheers