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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E630E95A77 for ; Sat, 7 Oct 2023 22:54:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 600B28D0015; Sat, 7 Oct 2023 18:54:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B0978D0001; Sat, 7 Oct 2023 18:54:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 478AD8D0015; Sat, 7 Oct 2023 18:54:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 33D5A8D0001 for ; Sat, 7 Oct 2023 18:54:32 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 116E91CA600 for ; Sat, 7 Oct 2023 22:54:32 +0000 (UTC) X-FDA: 81320171184.17.EF07DAC Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by imf06.hostedemail.com (Postfix) with ESMTP id 945F1180009 for ; Sat, 7 Oct 2023 22:54:29 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=ellerman.id.au header.s=201909 header.b=CyilkWGn; spf=pass (imf06.hostedemail.com: domain of mpe@ellerman.id.au designates 150.107.74.76 as permitted sender) smtp.mailfrom=mpe@ellerman.id.au; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696719270; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nbk6q9Yf8RtraLdUwwm6uSKRHWkNNpARqVFKgzAyVkY=; b=tB4DutTpoGdTeHcz/JrxIMTexYhGIcdd4Ws2PTx0ceyB8Cmg/3c6a9B15qlmuepyDRhm0I sSV9g5CVS6H2Bb2wNkgP7A+5lgveD0WOrBAnD63SyIcGZHICFyYbxncCZzw/Q7FdJ45N2N fxJFHtf/3unny1uBneO6n2xFeAO6BDQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696719270; a=rsa-sha256; cv=none; b=7FzkQra8VUHdRLGEII9qwnac0hY/Su1pDEFhVpOQ12OwEoMtdCgNJDGHty67STUMSFMYGx ATMiWIsDRQ70DvhxiX9oYYZCVzDfOt6SvnfZxTkE5fUyPFAGOg50ya+AYY5qBCf0KprAuc Gu9J5Iq6jqPkCegGgV6BfBzSO9Qido4= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=ellerman.id.au header.s=201909 header.b=CyilkWGn; spf=pass (imf06.hostedemail.com: domain of mpe@ellerman.id.au designates 150.107.74.76 as permitted sender) smtp.mailfrom=mpe@ellerman.id.au; dmarc=none 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 Content-Type: text/plain X-Rspamd-Queue-Id: 945F1180009 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: gsj5rtq3gfz49gykqti6uynxyiobyjmh X-HE-Tag: 1696719269-984931 X-HE-Meta: U2FsdGVkX1/4ptpWMGa82oFkTXYTuiTAvJKQi81hRrWX8jM0ChHyRhzIhRtIzWx2HnxLljFq5bOIb0KKkRSIPcIWhG7T+RP7p0AVqKmaw35K3zGzApJ0QFWbvahWdb6c0vHAc+Xx5EKejZwexD0NAKu8yvQSQDwuRQiTFTKigf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iaiFJ5eZG8xIlGFRWQOvYC0SPaOcmt1CGGSJh3/VcGb/H9D08Upu+0LrC3y3EWXKE3cCi03Ng= 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: 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