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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE36BC2BD09 for ; Tue, 9 Jul 2024 19:48:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DD6A6B0083; Tue, 9 Jul 2024 15:48:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 28A8D6B0085; Tue, 9 Jul 2024 15:48:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 12B786B008C; Tue, 9 Jul 2024 15:48:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E82FC6B0083 for ; Tue, 9 Jul 2024 15:48:32 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 532771419BB for ; Tue, 9 Jul 2024 19:48:32 +0000 (UTC) X-FDA: 82321251264.03.957D17C Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by imf11.hostedemail.com (Postfix) with ESMTP id B3E554002A for ; Tue, 9 Jul 2024 19:48:29 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; spf=pass (imf11.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.235.10 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720554487; a=rsa-sha256; cv=none; b=rszTIFnlHG9QZ1YP1WVWWJw2TvZzF84JD6u4AOWpCbY+sjGNXYNAfx08c3GiFrVdH6z5pz peCAhqb/p20NL1J2x405mlIZhjmREU7VuMeFxTTaLSGPhtqO4oPkhiitkv559DVYg8NQg8 VEdA7fP1sMBQ5EgYMeWN6fgVBcEekO0= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; spf=pass (imf11.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.235.10 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720554487; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gFWUNLplJSvJYOa2rqxGfX+QIVbmn3754x9pV3QMB38=; b=DuuM9/7cZ8CfBVlfAng1zt/Ua66WX3GuQml++c9LgRavLTHGTa+79RcAVS9qISTTD8JJDu ShQ+94j/0nO/IcArgE4/cslu0Gv4Khopx6BiXAKEDKjOT9VHvZxLtMCqPMJxM2idGHHHI0 BONCmbNXCievIxucdCqhnZiIBxvqJGU= Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4WJWkg1HkPz9sSr; Tue, 9 Jul 2024 21:48:27 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xf_IeGqSmWKy; Tue, 9 Jul 2024 21:48:27 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4WJWkg01nkz9sSq; Tue, 9 Jul 2024 21:48:26 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A3C098B778; Tue, 9 Jul 2024 21:48:26 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id NiN-SJ2v4SUl; Tue, 9 Jul 2024 21:48:26 +0200 (CEST) Received: from [192.168.233.17] (unknown [192.168.233.17]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 4FBE08B773; Tue, 9 Jul 2024 21:48:26 +0200 (CEST) Message-ID: <56a0340a-2534-4d2e-92e4-cf27a6358b23@csgroup.eu> Date: Tue, 9 Jul 2024 21:48:24 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/3] mm: Add p{g/4}d_leaf() in asm-generic/pgtable-nop{4/u}d.h To: Peter Xu Cc: Andrew Morton , Arnd Bergmann , linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org, linux-riscv@lists.infradead.org, Oscar Salvador References: Content-Language: fr-FR From: Christophe Leroy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B3E554002A X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 4k3no7sjibwo1guyayo4g9m84semnkxh X-HE-Tag: 1720554509-51508 X-HE-Meta: U2FsdGVkX18ZDRnhTuZDWdQgh3D8nGbBilPbFW408md/6beWzfgMrmrdgAF0dXPzmQTJEdOiP2lMj0pAGOeatkwzQspiyh8hbV939AzE8yrDmz3qXrgpBIoIhmprUiwaNYyR3LM5HZLRti6J7R6O9SqXsj+CvC6wqJZQq/OqDekv1/kzBxuW6WQ5NzI25LbvVQLJz2UOnV9dl0iTntl45nlQKsNoo2j+4QwKj8rzSBwfem+ogxBg3NB9n5e512gMzXu7WslyzXHfXdAygXD3LUxjxjcoW7XgTC8IGgy2XISamG7xegTblbpkY0bFYzO0JPtnpiUSVE1wArPUdm9RSlcb9S9TV6P0qazpVTBi6uNeXQxfhdRavFS7h0ZSE1EwRn5jMXAZ4yVdL2YlkAUU/JKz4hVXfFEBRVjlEpo7+RVmdltUovtvftV9sUxJ39PT0cbLfG2/jYIKJ9vYa4lZknOcWpk10RGICN9T7xdHlTfPQJXtvca9Ah0z25CCyrvU8Af7lbPM6/i5mTX98iY23oAN39J3lBw0+k3yUta4vAEJbajNcnYDg6HaipCmQRQm+3hC9+9Rq2GAAXWbcNbCKfrWhWepTDr+8abhBXLTKtI7SvxCCZ8M/8Dxl/FsK756doWa6kywJDzUNAEjf+WsTLyQkYDsnwe162qf/SK2GDCmQ6ZhV72pvOTKo8oTkOHm4CaSqONHdXLYpZipPL14ALal2w3E/xxcgZMVwws8/KSA5yXmOPuutkiGhhf4Sm1GtSZjjlZsg05aIE3XoTc3Gg3RvOQAomSa1oZbuqYUmCzrn4Fe/xZZlKVDMKo1j27y5gtbsmxe2cC7TdorkHWTvzp0T1uvAGhHhz9kywGI/zBbswqlU2t4OpXJ9/gV03yOQvCDDjOTq+zl6hca3hCeG36sft7Uia1iN3/4sKa2xmFhlMVjREbrn2nPpY9ErAEdbOtrSfraT625VA/TONa m/g18Dmj 5V2J0/xv1aDSTGGKx3O+qoVGAqfMUDyVv3rEPjSp2HrUEi/STR5ibzwMdYbj5O8x47D5KTT3KaVDzKI8gOj2l0zgiml3LbpIut3ljWjBdhaD5midln54bTZecNTSPWt+b52xuFRzVwdZfhjRZeJL0UgW6TvDMpl1E+SwHloWFthEu0MGqgOXmRIxC+KoQzN0Zerlki82uDjK6R0WzgDhDZsd7hkZmz/2XqhjWABt+jiXHWDW9+HGb29yt+w== 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: List-Subscribe: List-Unsubscribe: Le 04/07/2024 à 16:48, Peter Xu a écrit : > On Thu, Jul 04, 2024 at 08:30:05AM +0200, Christophe Leroy wrote: >> Commit 2c8a81dc0cc5 ("riscv/mm: fix two page table check related >> issues") added pud_leaf() in include/asm-generic/pgtable-nopmd.h >> >> Do the same for p4d_leaf() and pgd_leaf() to avoid getting them >> erroneously defined by architectures that do not implement the >> related page level. >> >> Signed-off-by: Christophe Leroy >> --- >> include/asm-generic/pgtable-nop4d.h | 1 + >> include/asm-generic/pgtable-nopud.h | 1 + >> include/linux/pgtable.h | 6 +++--- >> 3 files changed, 5 insertions(+), 3 deletions(-) >> >> diff --git a/include/asm-generic/pgtable-nop4d.h b/include/asm-generic/pgtable-nop4d.h >> index 03b7dae47dd4..75c96bbc5a96 100644 >> --- a/include/asm-generic/pgtable-nop4d.h >> +++ b/include/asm-generic/pgtable-nop4d.h >> @@ -21,6 +21,7 @@ typedef struct { pgd_t pgd; } p4d_t; >> static inline int pgd_none(pgd_t pgd) { return 0; } >> static inline int pgd_bad(pgd_t pgd) { return 0; } >> static inline int pgd_present(pgd_t pgd) { return 1; } >> +static inline int pgd_leaf(pgd_t pgd) { return 0; } >> static inline void pgd_clear(pgd_t *pgd) { } >> #define p4d_ERROR(p4d) (pgd_ERROR((p4d).pgd)) >> >> diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h >> index eb70c6d7ceff..14aeb8ef2d8a 100644 >> --- a/include/asm-generic/pgtable-nopud.h >> +++ b/include/asm-generic/pgtable-nopud.h >> @@ -28,6 +28,7 @@ typedef struct { p4d_t p4d; } pud_t; >> static inline int p4d_none(p4d_t p4d) { return 0; } >> static inline int p4d_bad(p4d_t p4d) { return 0; } >> static inline int p4d_present(p4d_t p4d) { return 1; } >> +static inline int p4d_leaf(p4d_t p4d) { return 0; } >> static inline void p4d_clear(p4d_t *p4d) { } >> #define pud_ERROR(pud) (p4d_ERROR((pud).p4d)) >> >> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h >> index 2a6a3cccfc36..b27e66f542d6 100644 >> --- a/include/linux/pgtable.h >> +++ b/include/linux/pgtable.h >> @@ -1882,13 +1882,13 @@ typedef unsigned int pgtbl_mod_mask; >> * - It should cover all kinds of huge mappings (e.g., pXd_trans_huge(), >> * pXd_devmap(), or hugetlb mappings). >> */ >> -#ifndef pgd_leaf >> +#if !defined(__PAGETABLE_P4D_FOLDED) && !defined(pgd_leaf) >> #define pgd_leaf(x) false >> #endif >> -#ifndef p4d_leaf >> +#if !defined(__PAGETABLE_PUD_FOLDED) && !defined(p4d_leaf) >> #define p4d_leaf(x) false >> #endif >> -#ifndef pud_leaf >> +#if !defined(__PAGETABLE_PMD_FOLDED) && !defined(pud_leaf) >> #define pud_leaf(x) false >> #endif >> #ifndef pmd_leaf > > Is it possible to do it the other way round, so that we can still rely on > "ifdef pxx_leaf" to decide whether to provide a fallback, and define them > properly when needed? What do you mean by the "other way round" ? Did I do a mistake ? I can't see it. The purpose here is: - If the architecture has the said level and implements pXd_leaf(), that's fine - If the architecture has the said level and doesn't implement pXd_leaf(), that's also fine, a fallback is provided. - If the architecture doesn't have the said level but implements pXd_leaf(), it will conflict with the definition in include/asm-generic/pgtable-nopXd.h and the build will fail. The purpose is to make sure architectures don't implement pXd_leaf() at the wrong level, for instance: - an architecture without PMDs shall not implement anything else than pmd_leaf() - an architecture without P4Ds shall not implement pgd_leaf(). > > IMHO it was a neat way to avoid worrying on any macro defined; it'll be as > simple as "if function xxx not defined, let's define a fallback for xxx". > Per my limited experience it helped a lot on avoid compile issues here and > there.. That will still be the case. This patch adds: "if function xxx is defined for wrong level, break the build" Christophe