Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4453219ybp; Mon, 7 Oct 2019 08:39:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqzlRESOdHanKyBpLJIjibVyJL35vF2lg206rCyHc4gyBSbpSd5pW87b1ofi+rjYEP7Iz3x6 X-Received: by 2002:a50:9e26:: with SMTP id z35mr29487892ede.265.1570462761940; Mon, 07 Oct 2019 08:39:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570462761; cv=none; d=google.com; s=arc-20160816; b=MYsBUnOCBN/I3O84QwobHKxX3Z9JUcrrqqr5EHFqJ8TUB3NwNZrBSBhpxzIzwfnA8T ls8eaC6Cq/WBQCpm63GrGGI49FAnM7heaWlFEt4Io5F6MFdiyJk1TaMqjZSK98QVdfLw N4/jhwp8rAd9T4urukccWePiuW+EqyrazZtJlV+iAAXHqM/X6HsNSR0qNadpF3K67cal JhMuaIMvQ4Wj8Tir3R5UkXlxC/VnT1sA6bLM0XOftC1vOinJ3q1/FeU2c/jJ51FLC6VJ zctQgDs2pSOCn2XsC3Qo4mwinnaMpiHIe6cJ0XsPcvw4J8egSjk0BOQkU0vYGM/Qg2Te wp2Q== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=9SqGl5CrTKprCTfXLRy7V0fEcdpEU1lW3cyJ8+roEes=; b=XyGXPFSr2NMJ17ctu8Zu5qgxEVh8BMFnrpbYWgMwtxPgoW0lJqdcL5xOPuj6mEo90t 2QxGH7BEusIq8H6LxgEq8Ga8Vimh8Vtz3+ykq32GRJ4RevSGG05yGmOxPM12UqNGh/bJ erBGccFLNA6ZxvKeTXN46ns5J61k0ZvpzWcZvKAupDve82v9yxElBGgY+Je6hsqK3xlx 5Y5v34jgxGTdI7piEwH7CfcHlRnTq7hMxeOsA3T28oFicM0Rwmbg0I4jLPKIl/tQKwnT elNFpD9820FTbIavO+BuH4+QTPtyD3xXV9J5Sbr8ONymgOpcHEB24eCW1zV63OhjsLUo i5Lw== 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 i40si8799616eda.225.2019.10.07.08.38.58; Mon, 07 Oct 2019 08:39:21 -0700 (PDT) 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 S1728588AbfJGPiq (ORCPT + 99 others); Mon, 7 Oct 2019 11:38:46 -0400 Received: from foss.arm.com ([217.140.110.172]:38220 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727745AbfJGPio (ORCPT ); Mon, 7 Oct 2019 11:38:44 -0400 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 3B16F1576; Mon, 7 Oct 2019 08:38:44 -0700 (PDT) Received: from e112269-lin.arm.com (unknown [10.1.197.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 899273F6C4; Mon, 7 Oct 2019 08:38:41 -0700 (PDT) From: Steven Price To: 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?q?J=C3=A9r=C3=B4me=20Glisse?= , 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" , Andrew Morton , Mark Rutland Subject: [PATCH v11 01/22] mm: Add generic p?d_leaf() macros Date: Mon, 7 Oct 2019 16:38:01 +0100 Message-Id: <20191007153822.16518-2-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191007153822.16518-1-steven.price@arm.com> References: <20191007153822.16518-1-steven.price@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 818691846c90..7f9eced287b7 100644 --- a/include/asm-generic/pgtable.h +++ b/include/asm-generic/pgtable.h @@ -1187,4 +1187,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 + #endif /* _ASM_GENERIC_PGTABLE_H */ -- 2.20.1