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=-10.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 97B6EC2BB84 for ; Mon, 7 Sep 2020 20:16:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48059215A4 for ; Mon, 7 Sep 2020 20:16:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599509769; bh=RAEHj8xYfuFWI4Y+q/aFyLQ3Y81fPmwq73CuPlLtuLo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=GAOBpqSFolK6tt71vOhGMmYJztMrDnA2rr7nGTU1Gm8NVG4NFT9qawWAmlWHHxwwP 6JhQ5b5GhssHRfVIfqLfhHWLaf6b10S1AL2JxpaEHrKrE9aLry+ihqGHpk1AZMmqVq TMRLtdsDNAxcJner6MhN5auDstmXnJ3M+0FhNC68= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729378AbgIGUQH (ORCPT ); Mon, 7 Sep 2020 16:16:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:38550 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728834AbgIGUQF (ORCPT ); Mon, 7 Sep 2020 16:16:05 -0400 Received: from kernel.org (unknown [87.71.73.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BEEA721556; Mon, 7 Sep 2020 20:15:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599509764; bh=RAEHj8xYfuFWI4Y+q/aFyLQ3Y81fPmwq73CuPlLtuLo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=He38jwjTrF8JsybKdtpkafn6I41PVh9VCu45Rcex2vcAXxwQSXaRmFllsBPIYZ+VL vZjgVN2gASyM9VlZJ8s1FxZ73kaEMYdfXeCRo2+tYgHnkcL0pV9msWK3FqjY2+hfQ4 WUxdkaZyDiiR1eOPP4BI2bi8sU1hW+gyy5K8utdc= Date: Mon, 7 Sep 2020 23:15:47 +0300 From: Mike Rapoport To: Gerald Schaefer Cc: Jason Gunthorpe , John Hubbard , LKML , linux-mm , linux-arch , Andrew Morton , Linus Torvalds , Russell King , Catalin Marinas , Will Deacon , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Jeff Dike , Richard Weinberger , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Arnd Bergmann , Andrey Ryabinin , linux-x86 , linux-arm , linux-power , linux-sparc , linux-um , linux-s390 , Alexander Gordeev , Vasily Gorbik , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda Subject: Re: [RFC PATCH v2 3/3] mm: make generic pXd_addr_end() macros inline functions Message-ID: <20200907201547.GD1976319@kernel.org> References: <20200907180058.64880-1-gerald.schaefer@linux.ibm.com> <20200907180058.64880-4-gerald.schaefer@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200907180058.64880-4-gerald.schaefer@linux.ibm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Some style comments below. On Mon, Sep 07, 2020 at 08:00:58PM +0200, Gerald Schaefer wrote: > From: Alexander Gordeev > > 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. > > Signed-off-by: Alexander Gordeev > Signed-off-by: Gerald Schaefer > --- > include/linux/pgtable.h | 36 ++++++++++++++++++++---------------- > 1 file changed, 20 insertions(+), 16 deletions(-) > > 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, > */ > > #ifndef pgd_addr_end > -#define pgd_addr_end(pgd, addr, end) \ > -({ unsigned long __boundary = ((addr) + PGDIR_SIZE) & PGDIR_MASK; \ > - (__boundary - 1 < (end) - 1)? __boundary: (end); \ > -}) > +#define pgd_addr_end pgd_addr_end > +static inline unsigned long pgd_addr_end(pgd_t pgd, unsigned long addr, unsigned long end) > +{ unsigned long __boundary = (addr + PGDIR_SIZE) & PGDIR_MASK; The code should be on a separate line from the curly brace. Besides, since this is not a macro anymore, I think it would be nicer to use 'boundary' without underscores. This applies to the changes below as well. > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > > #ifndef p4d_addr_end > -#define p4d_addr_end(p4d, addr, end) \ > -({ unsigned long __boundary = ((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 = (addr + P4D_SIZE) & P4D_MASK; > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > > #ifndef pud_addr_end > -#define pud_addr_end(pud, addr, end) \ > -({ unsigned long __boundary = ((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 = (addr + PUD_SIZE) & PUD_MASK; > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > > #ifndef pmd_addr_end > -#define pmd_addr_end(pmd, addr, end) \ > -({ unsigned long __boundary = ((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 = (addr + PMD_SIZE) & PMD_MASK; > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > > /* > -- > 2.17.1 > -- Sincerely yours, Mike. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Rapoport Date: Mon, 07 Sep 2020 20:15:47 +0000 Subject: Re: [RFC PATCH v2 3/3] mm: make generic pXd_addr_end() macros inline functions Message-Id: <20200907201547.GD1976319@kernel.org> List-Id: References: <20200907180058.64880-1-gerald.schaefer@linux.ibm.com> <20200907180058.64880-4-gerald.schaefer@linux.ibm.com> In-Reply-To: <20200907180058.64880-4-gerald.schaefer@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Gerald Schaefer Cc: Jason Gunthorpe , John Hubbard , LKML , linux-mm , linux-arch , Andrew Morton , Linus Torvalds , Russell King , Catalin Marinas , Will Deacon , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Jeff Dike , Richard Weinberger , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Arnd Bergmann , Andrey Ryabinin , linux-x86 , linux-arm , linux-power , linux-sparc , linux-um , linux-s390 , Alexander Gordeev , Vasily Gorbik , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda Hi, Some style comments below. On Mon, Sep 07, 2020 at 08:00:58PM +0200, Gerald Schaefer wrote: > From: Alexander Gordeev > > 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. > > Signed-off-by: Alexander Gordeev > Signed-off-by: Gerald Schaefer > --- > include/linux/pgtable.h | 36 ++++++++++++++++++++---------------- > 1 file changed, 20 insertions(+), 16 deletions(-) > > 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, > */ > > #ifndef pgd_addr_end > -#define pgd_addr_end(pgd, addr, end) \ > -({ unsigned long __boundary = ((addr) + PGDIR_SIZE) & PGDIR_MASK; \ > - (__boundary - 1 < (end) - 1)? __boundary: (end); \ > -}) > +#define pgd_addr_end pgd_addr_end > +static inline unsigned long pgd_addr_end(pgd_t pgd, unsigned long addr, unsigned long end) > +{ unsigned long __boundary = (addr + PGDIR_SIZE) & PGDIR_MASK; The code should be on a separate line from the curly brace. Besides, since this is not a macro anymore, I think it would be nicer to use 'boundary' without underscores. This applies to the changes below as well. > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > > #ifndef p4d_addr_end > -#define p4d_addr_end(p4d, addr, end) \ > -({ unsigned long __boundary = ((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 = (addr + P4D_SIZE) & P4D_MASK; > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > > #ifndef pud_addr_end > -#define pud_addr_end(pud, addr, end) \ > -({ unsigned long __boundary = ((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 = (addr + PUD_SIZE) & PUD_MASK; > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > > #ifndef pmd_addr_end > -#define pmd_addr_end(pmd, addr, end) \ > -({ unsigned long __boundary = ((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 = (addr + PMD_SIZE) & PMD_MASK; > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > > /* > -- > 2.17.1 > -- Sincerely yours, Mike. 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=-9.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 2C989C433E2 for ; Mon, 7 Sep 2020 20:17:47 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 89EF721556 for ; Mon, 7 Sep 2020 20:17:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="He38jwjT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 89EF721556 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4Blfj41Rz5zDqQf for ; Tue, 8 Sep 2020 06:17:44 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=198.145.29.99; helo=mail.kernel.org; envelope-from=rppt@kernel.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=default header.b=He38jwjT; dkim-atps=neutral Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4BlfgD0TBpzDq5f for ; Tue, 8 Sep 2020 06:16:07 +1000 (AEST) Received: from kernel.org (unknown [87.71.73.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BEEA721556; Mon, 7 Sep 2020 20:15:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599509764; bh=RAEHj8xYfuFWI4Y+q/aFyLQ3Y81fPmwq73CuPlLtuLo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=He38jwjTrF8JsybKdtpkafn6I41PVh9VCu45Rcex2vcAXxwQSXaRmFllsBPIYZ+VL vZjgVN2gASyM9VlZJ8s1FxZ73kaEMYdfXeCRo2+tYgHnkcL0pV9msWK3FqjY2+hfQ4 WUxdkaZyDiiR1eOPP4BI2bi8sU1hW+gyy5K8utdc= Date: Mon, 7 Sep 2020 23:15:47 +0300 From: Mike Rapoport To: Gerald Schaefer Subject: Re: [RFC PATCH v2 3/3] mm: make generic pXd_addr_end() macros inline functions Message-ID: <20200907201547.GD1976319@kernel.org> References: <20200907180058.64880-1-gerald.schaefer@linux.ibm.com> <20200907180058.64880-4-gerald.schaefer@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200907180058.64880-4-gerald.schaefer@linux.ibm.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Zijlstra , Dave Hansen , linux-mm , Paul Mackerras , linux-sparc , Alexander Gordeev , Claudio Imbrenda , Will Deacon , linux-arch , linux-s390 , Vasily Gorbik , Christian Borntraeger , Richard Weinberger , linux-x86 , Russell King , Jason Gunthorpe , Ingo Molnar , Catalin Marinas , Andrey Ryabinin , Heiko Carstens , Arnd Bergmann , John Hubbard , Jeff Dike , linux-um , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , linux-arm , linux-power , LKML , Andrew Morton , Linus Torvalds Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Hi, Some style comments below. On Mon, Sep 07, 2020 at 08:00:58PM +0200, Gerald Schaefer wrote: > From: Alexander Gordeev > > 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. > > Signed-off-by: Alexander Gordeev > Signed-off-by: Gerald Schaefer > --- > include/linux/pgtable.h | 36 ++++++++++++++++++++---------------- > 1 file changed, 20 insertions(+), 16 deletions(-) > > 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, > */ > > #ifndef pgd_addr_end > -#define pgd_addr_end(pgd, addr, end) \ > -({ unsigned long __boundary = ((addr) + PGDIR_SIZE) & PGDIR_MASK; \ > - (__boundary - 1 < (end) - 1)? __boundary: (end); \ > -}) > +#define pgd_addr_end pgd_addr_end > +static inline unsigned long pgd_addr_end(pgd_t pgd, unsigned long addr, unsigned long end) > +{ unsigned long __boundary = (addr + PGDIR_SIZE) & PGDIR_MASK; The code should be on a separate line from the curly brace. Besides, since this is not a macro anymore, I think it would be nicer to use 'boundary' without underscores. This applies to the changes below as well. > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > > #ifndef p4d_addr_end > -#define p4d_addr_end(p4d, addr, end) \ > -({ unsigned long __boundary = ((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 = (addr + P4D_SIZE) & P4D_MASK; > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > > #ifndef pud_addr_end > -#define pud_addr_end(pud, addr, end) \ > -({ unsigned long __boundary = ((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 = (addr + PUD_SIZE) & PUD_MASK; > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > > #ifndef pmd_addr_end > -#define pmd_addr_end(pmd, addr, end) \ > -({ unsigned long __boundary = ((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 = (addr + PMD_SIZE) & PMD_MASK; > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > > /* > -- > 2.17.1 > -- Sincerely yours, Mike. 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=-10.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 802F1C433E2 for ; Mon, 7 Sep 2020 20:17:33 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 28ADD21556 for ; Mon, 7 Sep 2020 20:17:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="nKqe4L8R"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="He38jwjT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 28ADD21556 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Amj259D+lwduWiVrTpQYntHeG2vBIiGAhvXFeM7HCfc=; b=nKqe4L8RtGtU9347GSy7r23rq 6f0HNr4yJdAYlff6IAntzXmw20v0H54U8w+HZ1fQbVwL9Vw9R0rEv83xX5mRLX0EQDVWxwQEyhqPd qf6H9uq68LO/BCk6GupGG+rcSXV9NeWe2TQiqx0iteTGgfkpA+bnYtjr6P/SZWjyAdM5jjxM01+k+ PJx+c+2UXUTC8I230ppwSh6tRGCd17unOPybYNR/bnxK3x8nJ6vzI6hQMd2k989Q4qThwLjbhmnip xdOKlcd7SHlj111fFLPjOmSDEEZoikhjmhrqQs1rJJDRH4GxpIftwH152umdlCyTwT6MP5PqM26Uv v+QF2lBew==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFNYk-0005jI-PX; Mon, 07 Sep 2020 20:16:16 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFNYb-0005hs-UU; Mon, 07 Sep 2020 20:16:06 +0000 Received: from kernel.org (unknown [87.71.73.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BEEA721556; Mon, 7 Sep 2020 20:15:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599509764; bh=RAEHj8xYfuFWI4Y+q/aFyLQ3Y81fPmwq73CuPlLtuLo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=He38jwjTrF8JsybKdtpkafn6I41PVh9VCu45Rcex2vcAXxwQSXaRmFllsBPIYZ+VL vZjgVN2gASyM9VlZJ8s1FxZ73kaEMYdfXeCRo2+tYgHnkcL0pV9msWK3FqjY2+hfQ4 WUxdkaZyDiiR1eOPP4BI2bi8sU1hW+gyy5K8utdc= Date: Mon, 7 Sep 2020 23:15:47 +0300 From: Mike Rapoport To: Gerald Schaefer Subject: Re: [RFC PATCH v2 3/3] mm: make generic pXd_addr_end() macros inline functions Message-ID: <20200907201547.GD1976319@kernel.org> References: <20200907180058.64880-1-gerald.schaefer@linux.ibm.com> <20200907180058.64880-4-gerald.schaefer@linux.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200907180058.64880-4-gerald.schaefer@linux.ibm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200907_161606_280671_3E55AA1B X-CRM114-Status: GOOD ( 26.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Zijlstra , Benjamin Herrenschmidt , Dave Hansen , linux-mm , Paul Mackerras , linux-sparc , Alexander Gordeev , Claudio Imbrenda , Will Deacon , linux-arch , linux-s390 , Vasily Gorbik , Christian Borntraeger , Richard Weinberger , linux-x86 , Russell King , Jason Gunthorpe , Ingo Molnar , Catalin Marinas , Andrey Ryabinin , Heiko Carstens , Arnd Bergmann , John Hubbard , Jeff Dike , linux-um , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , linux-arm , linux-power , LKML , Michael Ellerman , Andrew Morton , Linus Torvalds Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, Some style comments below. On Mon, Sep 07, 2020 at 08:00:58PM +0200, Gerald Schaefer wrote: > From: Alexander Gordeev > > 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. > > Signed-off-by: Alexander Gordeev > Signed-off-by: Gerald Schaefer > --- > include/linux/pgtable.h | 36 ++++++++++++++++++++---------------- > 1 file changed, 20 insertions(+), 16 deletions(-) > > 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, > */ > > #ifndef pgd_addr_end > -#define pgd_addr_end(pgd, addr, end) \ > -({ unsigned long __boundary = ((addr) + PGDIR_SIZE) & PGDIR_MASK; \ > - (__boundary - 1 < (end) - 1)? __boundary: (end); \ > -}) > +#define pgd_addr_end pgd_addr_end > +static inline unsigned long pgd_addr_end(pgd_t pgd, unsigned long addr, unsigned long end) > +{ unsigned long __boundary = (addr + PGDIR_SIZE) & PGDIR_MASK; The code should be on a separate line from the curly brace. Besides, since this is not a macro anymore, I think it would be nicer to use 'boundary' without underscores. This applies to the changes below as well. > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > > #ifndef p4d_addr_end > -#define p4d_addr_end(p4d, addr, end) \ > -({ unsigned long __boundary = ((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 = (addr + P4D_SIZE) & P4D_MASK; > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > > #ifndef pud_addr_end > -#define pud_addr_end(pud, addr, end) \ > -({ unsigned long __boundary = ((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 = (addr + PUD_SIZE) & PUD_MASK; > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > > #ifndef pmd_addr_end > -#define pmd_addr_end(pmd, addr, end) \ > -({ unsigned long __boundary = ((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 = (addr + PMD_SIZE) & PMD_MASK; > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > > /* > -- > 2.17.1 > -- Sincerely yours, Mike. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Mon, 7 Sep 2020 23:15:47 +0300 From: Mike Rapoport Subject: Re: [RFC PATCH v2 3/3] mm: make generic pXd_addr_end() macros inline functions Message-ID: <20200907201547.GD1976319@kernel.org> References: <20200907180058.64880-1-gerald.schaefer@linux.ibm.com> <20200907180058.64880-4-gerald.schaefer@linux.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200907180058.64880-4-gerald.schaefer@linux.ibm.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-um" Errors-To: linux-um-bounces+geert=linux-m68k.org@lists.infradead.org To: Gerald Schaefer Cc: Peter Zijlstra , Benjamin Herrenschmidt , Dave Hansen , linux-mm , Paul Mackerras , linux-sparc , Alexander Gordeev , Claudio Imbrenda , Will Deacon , linux-arch , linux-s390 , Vasily Gorbik , Christian Borntraeger , Richard Weinberger , linux-x86 , Russell King , Jason Gunthorpe , Ingo Molnar , Catalin Marinas , Andrey Ryabinin , Heiko Carstens , Arnd Bergmann , John Hubbard , Jeff Dike , linux-um , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , linux-arm , linux-power , LKML , Michael Ellerman , Andrew Morton , Linus Torvalds Hi, Some style comments below. On Mon, Sep 07, 2020 at 08:00:58PM +0200, Gerald Schaefer wrote: > From: Alexander Gordeev > > 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. > > Signed-off-by: Alexander Gordeev > Signed-off-by: Gerald Schaefer > --- > include/linux/pgtable.h | 36 ++++++++++++++++++++---------------- > 1 file changed, 20 insertions(+), 16 deletions(-) > > 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, > */ > > #ifndef pgd_addr_end > -#define pgd_addr_end(pgd, addr, end) \ > -({ unsigned long __boundary = ((addr) + PGDIR_SIZE) & PGDIR_MASK; \ > - (__boundary - 1 < (end) - 1)? __boundary: (end); \ > -}) > +#define pgd_addr_end pgd_addr_end > +static inline unsigned long pgd_addr_end(pgd_t pgd, unsigned long addr, unsigned long end) > +{ unsigned long __boundary = (addr + PGDIR_SIZE) & PGDIR_MASK; The code should be on a separate line from the curly brace. Besides, since this is not a macro anymore, I think it would be nicer to use 'boundary' without underscores. This applies to the changes below as well. > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > > #ifndef p4d_addr_end > -#define p4d_addr_end(p4d, addr, end) \ > -({ unsigned long __boundary = ((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 = (addr + P4D_SIZE) & P4D_MASK; > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > > #ifndef pud_addr_end > -#define pud_addr_end(pud, addr, end) \ > -({ unsigned long __boundary = ((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 = (addr + PUD_SIZE) & PUD_MASK; > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > > #ifndef pmd_addr_end > -#define pmd_addr_end(pmd, addr, end) \ > -({ unsigned long __boundary = ((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 = (addr + PMD_SIZE) & PMD_MASK; > + return (__boundary - 1 < end - 1) ? __boundary : end; > +} > #endif > > /* > -- > 2.17.1 > -- Sincerely yours, Mike. _______________________________________________ linux-um mailing list linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-um