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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 A9D95C4743D for ; Tue, 8 Jun 2021 06:59:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E5616124C for ; Tue, 8 Jun 2021 06:59:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230349AbhFHHBE (ORCPT ); Tue, 8 Jun 2021 03:01:04 -0400 Received: from mail-vs1-f44.google.com ([209.85.217.44]:34685 "EHLO mail-vs1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229657AbhFHHBD (ORCPT ); Tue, 8 Jun 2021 03:01:03 -0400 Received: by mail-vs1-f44.google.com with SMTP id q2so2934789vsr.1; Mon, 07 Jun 2021 23:58:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+FZhDB5g+zrC7pU7NdoL3gO/mOIESA4Y/Utk2Yrzo0M=; b=NvfXJUbbLSGU718P0YPLgPztu2uiWzB/vehF0IeReh1ZwCPgvc/09vYgqrrtvW18Gx DJeGkwgkzi3X+4QikyL9tmp8YtI+X0CBa3sWX4IgUWPAQ2PKg2pRqCt8Hiwd3zEeUQJy F2QxxtDFJ01qGT8arvLcaWFHWMXqCIavTOL2ZUURILQLUanlg6/eO3v9oohZIPJWbMp1 7SLpbO9dbHleDkstQImlfu7Zwq9/GeL85aXLjP1zc9GzMlVpqWqm1+kegYIg8sdfQ8EE vgOw+Us+W8YjgY2n+aAKQDJo0rAPEovRNV53tDc99Nwx9xaqzqhxsB0+on8apOighcN7 NF2w== X-Gm-Message-State: AOAM5308i+KxuYn6Fwmy8aw+JVEnOdIbWcKPxT3/qv2jiMkmSYS2G8hJ npaCk5I5U///use82aDjQBX4Kqu5OhykA4VnwgY= X-Google-Smtp-Source: ABdhPJz+kLqwZnPCS0BrIEbrML2xAox56vYXpHSSbBiyrAEZD83tbPAAws3L+b0gWUN+eb7OrpWA3ibw2diJNui3SYU= X-Received: by 2002:a05:6102:c4c:: with SMTP id y12mr7383918vss.18.1623135534863; Mon, 07 Jun 2021 23:58:54 -0700 (PDT) MIME-Version: 1.0 References: <1623130327-13325-1-git-send-email-anshuman.khandual@arm.com> In-Reply-To: <1623130327-13325-1-git-send-email-anshuman.khandual@arm.com> From: Geert Uytterhoeven Date: Tue, 8 Jun 2021 08:58:43 +0200 Message-ID: Subject: Re: [PATCH] mm/thp: Define default pmd_pgtable() To: Anshuman Khandual Cc: Linux MM , Andrew Morton , Nick Hu , Richard Henderson , Vineet Gupta , Catalin Marinas , Will Deacon , Guo Ren , Brian Cain , Michal Simek , Thomas Bogendoerfer , Ley Foon Tan , Jonas Bonn , Stefan Kristiansson , Stafford Horne , "James E.J. Bottomley" , Michael Ellerman , Christophe Leroy , Paul Walmsley , Palmer Dabbelt , Heiko Carstens , Yoshinori Sato , "David S. Miller" , Jeff Dike , Thomas Gleixner , Chris Zankel , Linux-Arch , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Anshuman, On Tue, Jun 8, 2021 at 7:31 AM Anshuman Khandual wrote: > Currently most platforms define pmd_pgtable() as pmd_page() duplicating the > same code all over. Instead just define a default value i.e pmd_page() for > pmd_pgtable() and let platforms override when required via . > All the existing platform that override pmd_pgtable() have been moved into > their respective header in order to precede before the new > generic definition. This makes it much cleaner with reduced code. > Signed-off-by: Anshuman Khandual Thanks for your patch! > This patch has been built tested across multiple platforms. But the m68k > changes in particular might not be optimal, followed the existing switch > from (arch/m68k/include/asm/pgalloc.h). Indeed. Why not move them to the existing arch/m68k/asm/{sun3,mcf,motorola}_pgtable.h>, instead of introducing yet another #if/#elif/#else/#endif block? > --- a/arch/m68k/include/asm/mcf_pgalloc.h > +++ b/arch/m68k/include/asm/mcf_pgalloc.h > @@ -32,8 +32,6 @@ extern inline pmd_t *pmd_alloc_kernel(pgd_t *pgd, unsigned long address) > > #define pmd_populate_kernel pmd_populate > > -#define pmd_pgtable(pmd) pfn_to_virt(pmd_val(pmd) >> PAGE_SHIFT) > - > static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pgtable, > unsigned long address) > { > diff --git a/arch/m68k/include/asm/motorola_pgalloc.h b/arch/m68k/include/asm/motorola_pgalloc.h > index b4fc3b4f6bb3..74a817d9387f 100644 > --- a/arch/m68k/include/asm/motorola_pgalloc.h > +++ b/arch/m68k/include/asm/motorola_pgalloc.h > @@ -88,7 +88,6 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t page > { > pmd_set(pmd, page); > } > -#define pmd_pgtable(pmd) ((pgtable_t)pmd_page_vaddr(pmd)) > > static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd) > { > diff --git a/arch/m68k/include/asm/pgtable.h b/arch/m68k/include/asm/pgtable.h > index ad15d655a9bf..7be5e5e712b2 100644 > --- a/arch/m68k/include/asm/pgtable.h > +++ b/arch/m68k/include/asm/pgtable.h > @@ -4,3 +4,12 @@ > #else > #include > #endif > + > + > +#if defined(CONFIG_COLDFIRE) > +#define pmd_pgtable(pmd) pfn_to_virt(pmd_val(pmd) >> PAGE_SHIFT) > +#elif defined(CONFIG_SUN3) > +#define pmd_pgtable(pmd) pmd_page(pmd) > +#else > +#define pmd_pgtable(pmd) ((pgtable_t)pmd_page_vaddr(pmd)) > +#endif > diff --git a/arch/m68k/include/asm/sun3_pgalloc.h b/arch/m68k/include/asm/sun3_pgalloc.h > index 000f64869b91..198036aff519 100644 > --- a/arch/m68k/include/asm/sun3_pgalloc.h > +++ b/arch/m68k/include/asm/sun3_pgalloc.h > @@ -32,7 +32,6 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t page > { > pmd_val(*pmd) = __pa((unsigned long)page_address(page)); > } > -#define pmd_pgtable(pmd) pmd_page(pmd) > > /* > * allocating and freeing a pmd is trivial: the 1-entry pmd is Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds 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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 4C64FC4743D for ; Tue, 8 Jun 2021 06:58:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F213F61263 for ; Tue, 8 Jun 2021 06:58:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F213F61263 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 84EB86B006C; Tue, 8 Jun 2021 02:58:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 825486B006E; Tue, 8 Jun 2021 02:58:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C6166B0070; Tue, 8 Jun 2021 02:58:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0197.hostedemail.com [216.40.44.197]) by kanga.kvack.org (Postfix) with ESMTP id 3BF1D6B006C for ; Tue, 8 Jun 2021 02:58:56 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C7C5C180AD804 for ; Tue, 8 Jun 2021 06:58:55 +0000 (UTC) X-FDA: 78229654230.05.784294C Received: from mail-vs1-f46.google.com (mail-vs1-f46.google.com [209.85.217.46]) by imf20.hostedemail.com (Postfix) with ESMTP id D186E541 for ; Tue, 8 Jun 2021 06:58:51 +0000 (UTC) Received: by mail-vs1-f46.google.com with SMTP id b1so8589936vsh.7 for ; Mon, 07 Jun 2021 23:58:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+FZhDB5g+zrC7pU7NdoL3gO/mOIESA4Y/Utk2Yrzo0M=; b=Ie0pU+4Bt58Yec4ohM9g4cqK7VYi78cd1mxH/qaXMqYeCK302mtBkYOut15NT+BAxc 5BkiYx67IFwvqsvo9+L2/w/qu7aCCf1jtr0NoNreiixHZog//M5b0HuK2JW4C9pfmR/r UdSWosJAgEhlgEqaQw5vc1MfgNJ1mZASY8KHq2Fhx13FL9MMI0bklbUabUgOZQyQMSdO IQRGwFHsZhLBghUESOWK91cJgqM7RWM0U4WsP/7lZs4VHud3qbvGUVDD65y2kkEXpWB+ qKUfEt5C0omDGDEPM22Q2A9y42Xt3iand5eWNzdp52JH+eikhZt5OVjWxMiXvwfpOOv5 eRCw== X-Gm-Message-State: AOAM531LkA+VbukRZLmy3speUAlD1XojZSeBE9XBKNicyUtle+xGPYGP 6+5Xte0w4U4lyvoGj+x9qRrd8Zr8MeigVG9r+F4= X-Google-Smtp-Source: ABdhPJz+kLqwZnPCS0BrIEbrML2xAox56vYXpHSSbBiyrAEZD83tbPAAws3L+b0gWUN+eb7OrpWA3ibw2diJNui3SYU= X-Received: by 2002:a05:6102:c4c:: with SMTP id y12mr7383918vss.18.1623135534863; Mon, 07 Jun 2021 23:58:54 -0700 (PDT) MIME-Version: 1.0 References: <1623130327-13325-1-git-send-email-anshuman.khandual@arm.com> In-Reply-To: <1623130327-13325-1-git-send-email-anshuman.khandual@arm.com> From: Geert Uytterhoeven Date: Tue, 8 Jun 2021 08:58:43 +0200 Message-ID: Subject: Re: [PATCH] mm/thp: Define default pmd_pgtable() To: Anshuman Khandual Cc: Linux MM , Andrew Morton , Nick Hu , Richard Henderson , Vineet Gupta , Catalin Marinas , Will Deacon , Guo Ren , Brian Cain , Michal Simek , Thomas Bogendoerfer , Ley Foon Tan , Jonas Bonn , Stefan Kristiansson , Stafford Horne , "James E.J. Bottomley" , Michael Ellerman , Christophe Leroy , Paul Walmsley , Palmer Dabbelt , Heiko Carstens , Yoshinori Sato , "David S. Miller" , Jeff Dike , Thomas Gleixner , Chris Zankel , Linux-Arch , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: D186E541 Authentication-Results: imf20.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf20.hostedemail.com: domain of geertuytterhoeven@gmail.com designates 209.85.217.46 as permitted sender) smtp.mailfrom=geertuytterhoeven@gmail.com X-Stat-Signature: 8mi6qpmz4mj68kecm6j5c16rhkx4zu8w X-HE-Tag: 1623135531-76515 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: Hi Anshuman, On Tue, Jun 8, 2021 at 7:31 AM Anshuman Khandual wrote: > Currently most platforms define pmd_pgtable() as pmd_page() duplicating the > same code all over. Instead just define a default value i.e pmd_page() for > pmd_pgtable() and let platforms override when required via . > All the existing platform that override pmd_pgtable() have been moved into > their respective header in order to precede before the new > generic definition. This makes it much cleaner with reduced code. > Signed-off-by: Anshuman Khandual Thanks for your patch! > This patch has been built tested across multiple platforms. But the m68k > changes in particular might not be optimal, followed the existing switch > from (arch/m68k/include/asm/pgalloc.h). Indeed. Why not move them to the existing arch/m68k/asm/{sun3,mcf,motorola}_pgtable.h>, instead of introducing yet another #if/#elif/#else/#endif block? > --- a/arch/m68k/include/asm/mcf_pgalloc.h > +++ b/arch/m68k/include/asm/mcf_pgalloc.h > @@ -32,8 +32,6 @@ extern inline pmd_t *pmd_alloc_kernel(pgd_t *pgd, unsigned long address) > > #define pmd_populate_kernel pmd_populate > > -#define pmd_pgtable(pmd) pfn_to_virt(pmd_val(pmd) >> PAGE_SHIFT) > - > static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pgtable, > unsigned long address) > { > diff --git a/arch/m68k/include/asm/motorola_pgalloc.h b/arch/m68k/include/asm/motorola_pgalloc.h > index b4fc3b4f6bb3..74a817d9387f 100644 > --- a/arch/m68k/include/asm/motorola_pgalloc.h > +++ b/arch/m68k/include/asm/motorola_pgalloc.h > @@ -88,7 +88,6 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t page > { > pmd_set(pmd, page); > } > -#define pmd_pgtable(pmd) ((pgtable_t)pmd_page_vaddr(pmd)) > > static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd) > { > diff --git a/arch/m68k/include/asm/pgtable.h b/arch/m68k/include/asm/pgtable.h > index ad15d655a9bf..7be5e5e712b2 100644 > --- a/arch/m68k/include/asm/pgtable.h > +++ b/arch/m68k/include/asm/pgtable.h > @@ -4,3 +4,12 @@ > #else > #include > #endif > + > + > +#if defined(CONFIG_COLDFIRE) > +#define pmd_pgtable(pmd) pfn_to_virt(pmd_val(pmd) >> PAGE_SHIFT) > +#elif defined(CONFIG_SUN3) > +#define pmd_pgtable(pmd) pmd_page(pmd) > +#else > +#define pmd_pgtable(pmd) ((pgtable_t)pmd_page_vaddr(pmd)) > +#endif > diff --git a/arch/m68k/include/asm/sun3_pgalloc.h b/arch/m68k/include/asm/sun3_pgalloc.h > index 000f64869b91..198036aff519 100644 > --- a/arch/m68k/include/asm/sun3_pgalloc.h > +++ b/arch/m68k/include/asm/sun3_pgalloc.h > @@ -32,7 +32,6 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t page > { > pmd_val(*pmd) = __pa((unsigned long)page_address(page)); > } > -#define pmd_pgtable(pmd) pmd_page(pmd) > > /* > * allocating and freeing a pmd is trivial: the 1-entry pmd is Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds