From: Michael Ellerman <mpe@ellerman.id.au>
To: Andrew Morton <akpm@linux-foundation.org>,
Ryan Roberts <ryan.roberts@arm.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Cc: linux-arm-kernel@lists.infradead.org,
David Rientjes <rientjes@google.com>, Yu Zhao <yuzhao@google.com>,
John Hubbard <jhubbard@nvidia.com>,
Anshuman Khandual <anshuman.khandual@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Yang Shi <shy828301@gmail.com>,
David Hildenbrand <david@redhat.com>,
Hugh Dickins <hughd@google.com>,
Yin Fengwei <fengwei.yin@intel.com>,
Matthew Wilcox <willy@infradead.org>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Luis Chamberlain <mcgrof@kernel.org>,
Vlastimil Babka <vbabka@suse.cz>, Zi Yan <ziy@nvidia.com>,
"Huang, Ying" <ying.huang@intel.com>,
Itaru Kitayama <itaru.kitayama@gmail.com>,
linuxppc-dev@lists.ozlabs.org,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Subject: Re: [PATCH v6 4/9] mm: thp: Introduce anon_orders and anon_always_mask sysfs files
Date: Sun, 08 Oct 2023 09:54:22 +1100 [thread overview]
Message-ID: <87fs2mrqld.fsf@mail.lhotse> (raw)
In-Reply-To: <20230929155530.a51e68e03e47a06b6b84c689@linux-foundation.org>
Andrew Morton <akpm@linux-foundation.org> writes:
> On Fri, 29 Sep 2023 12:44:15 +0100 Ryan Roberts <ryan.roberts@arm.com> 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
next prev parent reply other threads:[~2023-10-07 22:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230929114421.3761121-1-ryan.roberts@arm.com>
[not found] ` <20230929114421.3761121-5-ryan.roberts@arm.com>
2023-09-29 22:55 ` [PATCH v6 4/9] mm: thp: Introduce anon_orders and anon_always_mask sysfs files Andrew Morton
2023-10-02 10:15 ` Ryan Roberts
2023-10-07 22:54 ` Michael Ellerman [this message]
2023-10-10 0:20 ` Andrew Morton
2023-10-12 9:31 ` David Hildenbrand
2023-10-12 11:07 ` Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fs2mrqld.fsf@mail.lhotse \
--to=mpe@ellerman.id.au \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.ibm.com \
--cc=anshuman.khandual@arm.com \
--cc=catalin.marinas@arm.com \
--cc=david@redhat.com \
--cc=fengwei.yin@intel.com \
--cc=hughd@google.com \
--cc=itaru.kitayama@gmail.com \
--cc=jhubbard@nvidia.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mcgrof@kernel.org \
--cc=rientjes@google.com \
--cc=ryan.roberts@arm.com \
--cc=shy828301@gmail.com \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
--cc=ying.huang@intel.com \
--cc=yuzhao@google.com \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).