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=-12.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 5A57EC433E2 for ; Tue, 8 Sep 2020 05:19:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EB6C72177B for ; Tue, 8 Sep 2020 05:19:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB6C72177B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=csgroup.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 66D8C6B0002; Tue, 8 Sep 2020 01:19:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F7926B0037; Tue, 8 Sep 2020 01:19:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 498A46B0055; Tue, 8 Sep 2020 01:19:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id 30FC66B0002 for ; Tue, 8 Sep 2020 01:19:49 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id DF5AF1EF3 for ; Tue, 8 Sep 2020 05:19:48 +0000 (UTC) X-FDA: 77238742056.12.eyes88_630ca42270d2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id B1F3918012738 for ; Tue, 8 Sep 2020 05:19:48 +0000 (UTC) X-HE-Tag: eyes88_630ca42270d2 X-Filterd-Recvd-Size: 6629 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Tue, 8 Sep 2020 05:19:47 +0000 (UTC) Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4BltkT4qvvz9tyfH; Tue, 8 Sep 2020 07:19:45 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id mF_Z1FlHMh_F; Tue, 8 Sep 2020 07:19:45 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4BltkT3c0Rz9tyfG; Tue, 8 Sep 2020 07:19:45 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 48B608B793; Tue, 8 Sep 2020 07:19:46 +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 G7-bMta_Fa-y; Tue, 8 Sep 2020 07:19:46 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 0B4918B768; Tue, 8 Sep 2020 07:19:44 +0200 (CEST) Subject: Re: [RFC PATCH v2 3/3] mm: make generic pXd_addr_end() macros inline functions To: Gerald Schaefer , Jason Gunthorpe , John Hubbard Cc: Peter Zijlstra , Dave Hansen , linux-mm , Paul Mackerras , linux-sparc , Alexander Gordeev , Claudio Imbrenda , Will Deacon , linux-arch , linux-s390 , Vasily Gorbik , Richard Weinberger , linux-x86 , Russell King , Christian Borntraeger , Ingo Molnar , Catalin Marinas , Andrey Ryabinin , Heiko Carstens , Arnd Bergmann , Jeff Dike , linux-um , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , linux-arm , linux-power , LKML , Andrew Morton , Linus Torvalds , Mike Rapoport References: <20200907180058.64880-1-gerald.schaefer@linux.ibm.com> <20200907180058.64880-4-gerald.schaefer@linux.ibm.com> From: Christophe Leroy Message-ID: <4c101685-5b29-dace-9dd2-b6f0ae193a9c@csgroup.eu> Date: Tue, 8 Sep 2020 07:19:38 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200907180058.64880-4-gerald.schaefer@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr X-Rspamd-Queue-Id: B1F3918012738 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 Content-Transfer-Encoding: quoted-printable 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: Le 07/09/2020 =C3=A0 20:00, Gerald Schaefer a =C3=A9crit=C2=A0: > From: Alexander Gordeev >=20 > Since pXd_addr_end() macros take pXd page-table entry as a > parameter it makes sense to check the entry type on compile. > Even though most archs do not make use of page-table entries > in pXd_addr_end() calls, checking the type in traversal code > paths could help to avoid subtle bugs. >=20 > Signed-off-by: Alexander Gordeev > Signed-off-by: Gerald Schaefer > --- > include/linux/pgtable.h | 36 ++++++++++++++++++++---------------- > 1 file changed, 20 insertions(+), 16 deletions(-) >=20 > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > index 67ebc22cf83d..d9e7d16c2263 100644 > --- a/include/linux/pgtable.h > +++ b/include/linux/pgtable.h > @@ -656,31 +656,35 @@ static inline int arch_unmap_one(struct mm_struct= *mm, > */ > =20 > #ifndef pgd_addr_end > -#define pgd_addr_end(pgd, addr, end) \ > -({ unsigned long __boundary =3D ((addr) + PGDIR_SIZE) & PGDIR_MASK; \ > - (__boundary - 1 < (end) - 1)? __boundary: (end); \ > -}) > +#define pgd_addr_end pgd_addr_end I think that #define is pointless, usually there is no such #define for=20 the default case. > +static inline unsigned long pgd_addr_end(pgd_t pgd, unsigned long addr= , unsigned long end) > +{ unsigned long __boundary =3D (addr + PGDIR_SIZE) & PGDIR_MASK; > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} Please use the standard layout, ie entry { and exit } alone on their=20 line, and space between local vars declaration and the rest. Also remove the leading __ in front of var names as it's not needed once=20 it is not macros anymore. f_name() { some_local_var; do_something(); } > #endif > =20 > #ifndef p4d_addr_end > -#define p4d_addr_end(p4d, addr, end) \ > -({ unsigned long __boundary =3D ((addr) + P4D_SIZE) & P4D_MASK; \ > - (__boundary - 1 < (end) - 1)? __boundary: (end); \ > -}) > +#define p4d_addr_end p4d_addr_end > +static inline unsigned long p4d_addr_end(p4d_t p4d, unsigned long addr= , unsigned long end) > +{ unsigned long __boundary =3D (addr + P4D_SIZE) & P4D_MASK; > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > =20 > #ifndef pud_addr_end > -#define pud_addr_end(pud, addr, end) \ > -({ unsigned long __boundary =3D ((addr) + PUD_SIZE) & PUD_MASK; \ > - (__boundary - 1 < (end) - 1)? __boundary: (end); \ > -}) > +#define pud_addr_end pud_addr_end > +static inline unsigned long pud_addr_end(pud_t pud, unsigned long addr= , unsigned long end) > +{ unsigned long __boundary =3D (addr + PUD_SIZE) & PUD_MASK; > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > =20 > #ifndef pmd_addr_end > -#define pmd_addr_end(pmd, addr, end) \ > -({ unsigned long __boundary =3D ((addr) + PMD_SIZE) & PMD_MASK; \ > - (__boundary - 1 < (end) - 1)? __boundary: (end); \ > -}) > +#define pmd_addr_end pmd_addr_end > +static inline unsigned long pmd_addr_end(pmd_t pmd, unsigned long addr= , unsigned long end) > +{ unsigned long __boundary =3D (addr + PMD_SIZE) & PMD_MASK; > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > =20 > /* >=20