Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp448403pxb; Sat, 18 Sep 2021 07:27:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweXp9gQNxUHuboIbJNF7m8eXIirfY2BPFqjcQHmHTKbRTtIIPKf5UhcoxLu6mXnhMOrllP X-Received: by 2002:a05:6602:2211:: with SMTP id n17mr12603517ion.142.1631975250508; Sat, 18 Sep 2021 07:27:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631975250; cv=none; d=google.com; s=arc-20160816; b=tlghK4PQJB74VhOZ7ktqQhE4GkhicwGfuNzhDhb6or+/RQ/xcABOdXcNEgsm3YVStH dYj/KDzzD6nKIb9OrXMfnnlNna8bTIHNyGHJ78dCj76qGQERrA9LfKZRvItGvlSXoVp3 0qptRQVYe5JtBspNwLX1UwOWUpewLAKKRCmPX/GQRqeqJMlEN2kUmMTMJFS1E5KiVbZU yJTVtgbg2tZDXUpGo2cFvuJ9BFQcgKlq/oeMnFs5BHL7gf9pPpd04V9C0+lWHz3dm4tz /TGallP7q2Mqqb5M3Nwd73j5qNJoUwwxpiMfS5k3ZqQPWcWwE518fMqnYc9cvHIARGQQ jbFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=EObPP0LByc7dqMhzZ3SCM5dzh5PRw2FMlzoi6zylknE=; b=xiFEm3sAIUtYN9sinjaErKU8hWRCNH0JhTk/r61q0IL4+/73HVQpekYB71giEPOh2R Y9rP1SsB96iPZHlTWlzXJW/V1TM5tszEMZEL2uOeSMZ8jdWx42gef4wACmbdUNavK7up XihviI4nThktHS3LB09JKMNV9ElPMu1kiedoBCR1gr8TkYjEYqarVCDWxm6aEu3+U/Ql HtbWgg5s4OA9LpPsDf3KL4Q5X4pNFHMGnjsShWxB4mtRpAJCtNWAo5XmW/sGBJHDg74M JOEuShvS2SwuI1cTiJflBdDIM5p9QU/UBmiqkG/NwB3+wKT3sjTJGsl2Cy3cUXcAS+OX Hhvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a7si9588675ila.148.2021.09.18.07.27.19; Sat, 18 Sep 2021 07:27:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237937AbhIRIsk (ORCPT + 99 others); Sat, 18 Sep 2021 04:48:40 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:42601 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237811AbhIRIsj (ORCPT ); Sat, 18 Sep 2021 04:48:39 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4HBPZq2GbFz9sTp; Sat, 18 Sep 2021 10:47:15 +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 Yf6k13u2YIhg; Sat, 18 Sep 2021 10:47:15 +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 4HBPZq18Bgz9sTK; Sat, 18 Sep 2021 10:47:15 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 0B3C08B768; Sat, 18 Sep 2021 10:47:15 +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 YWRbRl4cy6C5; Sat, 18 Sep 2021 10:47:14 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (unknown [192.168.202.70]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 6AE278B764; Sat, 18 Sep 2021 10:47:14 +0200 (CEST) Subject: Re: [PATCH v2] powerpc/32: Don't use a struct based type for pte_t To: David Laight , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: "linuxppc-dev@lists.ozlabs.org" , "linux-kernel@vger.kernel.org" References: <505920070e5f4bf8ad7ccaa12f346469@AcuMS.aculab.com> From: Christophe Leroy Message-ID: <07fea205-ffb2-dc32-a56d-1cce51d5f931@csgroup.eu> Date: Sat, 18 Sep 2021 10:47:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <505920070e5f4bf8ad7ccaa12f346469@AcuMS.aculab.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr-FR Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 17/09/2021 à 16:32, David Laight a écrit : > From: Christophe Leroy >> Sent: 17 September 2021 14:58 >> >> Long time ago we had a config item called STRICT_MM_TYPECHECKS >> to build the kernel with pte_t defined as a structure in order >> to perform additional build checks or build it with pte_t >> defined as a simple type in order to get simpler generated code. >> > ... >> diff --git a/arch/powerpc/include/asm/pgtable-types.h b/arch/powerpc/include/asm/pgtable-types.h >> index d11b4c61d686..c60199fc6fa6 100644 >> --- a/arch/powerpc/include/asm/pgtable-types.h >> +++ b/arch/powerpc/include/asm/pgtable-types.h >> @@ -5,14 +5,26 @@ >> /* PTE level */ >> #if defined(CONFIG_PPC_8xx) && defined(CONFIG_PPC_16K_PAGES) >> typedef struct { pte_basic_t pte, pte1, pte2, pte3; } pte_t; >> -#else >> +#elif defined(__CHECKER__) || !defined(CONFIG_PPC32) >> typedef struct { pte_basic_t pte; } pte_t; >> +#else >> +typedef pte_basic_t pte_t; >> #endif >> + >> +#if defined(__CHECKER__) || !defined(CONFIG_PPC32) || \ >> + (defined(CONFIG_PPC_8xx) && defined(CONFIG_PPC_16K_PAGES)) >> #define __pte(x) ((pte_t) { (x) }) >> static inline pte_basic_t pte_val(pte_t x) >> { >> return x.pte; >> } >> +#else >> +#define __pte(x) ((pte_t)(x)) >> +static inline pte_basic_t pte_val(pte_t x) >> +{ >> + return x; >> +} >> +#endif > > Would it be better to define: > static inline pte_basic_*pte_basic(pte_t *x) > { > #if xxx > return x; > #else > return &x->pte; > #endif > } > > Then pte_val(x) is always *pt_basic(x) > and the casts like: > >> - pte_basic_t *entry = &ptep->pte; >> + pte_basic_t *entry = (pte_basic_t *)ptep; > > can go away. > I don't like that idea too much, because it means going through a pointer of something which is not in memory at the begining. Doing that forces GCC to put the pte_t object on stack. And that's exactly the purpose of this patch: avoid having to go via memory. Allthough recent versions of GCC optimise it away at the end, I don't like it in principle. And the only two places (pte_update() and set_huge_pte_at() where this cast is required are really two places very special which deal with real page tables. So IMHO it makes sense to explicitely show that what we use is the address of the entry in the page table. Christophe