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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0F8B9E95A77 for ; Sat, 7 Oct 2023 22:55:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:References :In-Reply-To:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NV7A1uka+VUVZo0z37pEp2k4AFucndbEQc1ck5Msnj8=; b=t/Oigo7qkRDjjh HNd4whG7+LYUz+HOX85RDhY60AjuctBBVl5cmE5VM2iZpy5BZF2/I/PUlv94IA+pOP4hhXGkn3Y9b iJxwjm4UTMaoklQuY4Pdp0/AVW3zwTn1TBR+I3uF+GszV3xIi9BOWQKqsUWD6rPc6qJXjkkjRWNZ2 1zEDHLSvoJc4r2jA3+2Q0MUb1G1X1FUGAGtqOgRzjc/nKaD1v6cInQjBLinzbu1Wmvw8sNsvAH3LK Y8jW2PPof3ol3Jl2a6DxQYIc2Ul9FkKZpwOjDmkwK+WTRX/p4HZx+Zgy+JMG23Zk5xNYGyWzar7jU HMI5HBhX+LcIldj0S3LQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpGC3-0080rl-1R; Sat, 07 Oct 2023 22:54:43 +0000 Received: from gandalf.ozlabs.org ([150.107.74.76]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpGBu-0080pw-2E for linux-arm-kernel@lists.infradead.org; Sat, 07 Oct 2023 22:54:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1696719265; bh=nbk6q9Yf8RtraLdUwwm6uSKRHWkNNpARqVFKgzAyVkY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=CyilkWGntWBxGsb8/XLbizmV96t6hMY+W0oQpxspY3WK2Zh0/R+joh7+C88GFimV3 6I5g2B4Dt2Xy+wj9DW/HuxK8tyxrSKxDPP7oNzaxvdscosPR/vDjlFPma8eZgFv6+G uQ/RHEyrZOZ4Ga1RPNBGnPQAKoEcdrniyh0eOgpfh44rH+bJaeiBGUPMx8MWSQU7UY LNh2tKDZ5Hn1nHnyTit7RGBb6gLwaex8nvFzsEQxmBY98k0X6xlE+Ot6LEQwu9o8dz tlT32psHUtCIwAtIXIHSWPGI1WDqRVZQnxpg6bO5PFz5v8KTolLpb8r45OssLtfpBu Ejp+7pALj8xzQ== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4S30wb2SbSz4x7V; Sun, 8 Oct 2023 09:54:23 +1100 (AEDT) From: Michael Ellerman To: Andrew Morton , Ryan Roberts , "Aneesh Kumar K.V" Cc: Matthew Wilcox , Yin Fengwei , David Hildenbrand , Yu Zhao , Catalin Marinas , Anshuman Khandual , Yang Shi , "Huang, Ying" , Zi Yan , Luis Chamberlain , Itaru Kitayama , "Kirill A. Shutemov" , John Hubbard , David Rientjes , Vlastimil Babka , Hugh Dickins , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH v6 4/9] mm: thp: Introduce anon_orders and anon_always_mask sysfs files In-Reply-To: <20230929155530.a51e68e03e47a06b6b84c689@linux-foundation.org> References: <20230929114421.3761121-1-ryan.roberts@arm.com> <20230929114421.3761121-5-ryan.roberts@arm.com> <20230929155530.a51e68e03e47a06b6b84c689@linux-foundation.org> Date: Sun, 08 Oct 2023 09:54:22 +1100 Message-ID: <87fs2mrqld.fsf@mail.lhotse> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231007_155435_041839_FA870751 X-CRM114-Status: GOOD ( 25.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list 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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Andrew Morton writes: > On Fri, 29 Sep 2023 12:44:15 +0100 Ryan Roberts wrote: > >> In preparation for adding support for anonymous large folios that are >> smaller than the PMD-size, introduce 2 new sysfs files that will be used >> to control the new behaviours via the transparent_hugepage interface. >> For now, the kernel still only supports PMD-order anonymous THP, so when >> reading back anon_orders, it will reflect that. Therefore there are no >> behavioural changes intended here. > > powerpc strikes again. ARCH=powerpc allmodconfig: > > > In file included from ./include/linux/bits.h:6, > from ./include/linux/ratelimit_types.h:5, > from ./include/linux/printk.h:9, > from ./include/asm-generic/bug.h:22, > from ./arch/powerpc/include/asm/bug.h:116, > from ./include/linux/bug.h:5, > from ./include/linux/mmdebug.h:5, > from ./include/linux/mm.h:6, > from mm/huge_memory.c:8: > ./include/vdso/bits.h:7:33: error: initializer element is not constant > 7 | #define BIT(nr) (UL(1) << (nr)) > | ^ > mm/huge_memory.c:77:47: note: in expansion of macro 'BIT' > 77 | unsigned int huge_anon_orders __read_mostly = BIT(PMD_ORDER); > | ^~~ > > We keep tripping over this. I wish there was a way to fix it. I can't think of any solution, other than ripping the code out. To catch it earlier we'd need a generic compile-time test that all values derived from the page table geometry are only used in places that don't require a constant. I can't think of a way to write a test for that. Or submitters could compile-test for powerpc - one can dream :D > Style whine: an all-caps identifier is supposed to be a constant, > dammit. > > #define PTE_INDEX_SIZE __pte_index_size > > Nope. I agree it's ugly. It was done that way because PTE_INDEX_SIZE used to be constant, and still is for 32-bit PPC and 64-bit Book3E PPC. We could rename PTE_INDEX_SIZE itself, but we'd still have eg. PTE_TABLE_SIZE which is used in generic code, and which would be sometimes constant and sometimes not for different powerpc subarches. > I did this: > > --- a/mm/huge_memory.c~mm-thp-introduce-anon_orders-and-anon_always_mask-sysfs-files-fix > +++ a/mm/huge_memory.c > @@ -74,7 +74,7 @@ static unsigned long deferred_split_scan > static atomic_t huge_zero_refcount; > struct page *huge_zero_page __read_mostly; > unsigned long huge_zero_pfn __read_mostly = ~0UL; > -unsigned int huge_anon_orders __read_mostly = BIT(PMD_ORDER); > +unsigned int huge_anon_orders __read_mostly; > static unsigned int huge_anon_always_mask __read_mostly; > > /** > @@ -528,6 +528,9 @@ static int __init hugepage_init_sysfs(st > { > int err; > > + /* powerpc's PMD_ORDER isn't a compile-time constant */ > + huge_anon_orders = BIT(PMD_ORDER); > + > *hugepage_kobj = kobject_create_and_add("transparent_hugepage", mm_kobj); > if (unlikely(!*hugepage_kobj)) { > pr_err("failed to create transparent hugepage kobject\n"); > _ > > > I assume this is set up early enough. Yes it should be. > I don't know why powerpc's PTE_INDEX_SIZE is variable. To allow a single vmlinux to boot using either the Hashed Page Table MMU, or Radix Tree MMU, which have different page table geometry. That's a pretty crucial feature for distros, so that they can build a single kernel to boot on Power8/9/10. cheers _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel