[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c3aa4e27-5b00-4511-8130-29c8b8a5b6d9@redhat.com>
Date: Tue, 15 Jul 2025 16:06:29 +0200
From: David Hildenbrand <david@...hat.com>
To: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
Pankaj Raghav <kernel@...kajraghav.com>
Cc: Zi Yan <ziy@...dia.com>, Suren Baghdasaryan <surenb@...gle.com>,
Ryan Roberts <ryan.roberts@....com>,
Baolin Wang <baolin.wang@...ux.alibaba.com>, Borislav Petkov <bp@...en8.de>,
Ingo Molnar <mingo@...hat.com>, "H . Peter Anvin" <hpa@...or.com>,
Vlastimil Babka <vbabka@...e.cz>, Mike Rapoport <rppt@...nel.org>,
Dave Hansen <dave.hansen@...ux.intel.com>, Michal Hocko <mhocko@...e.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Thomas Gleixner <tglx@...utronix.de>, Nico Pache <npache@...hat.com>,
Dev Jain <dev.jain@....com>, "Liam R . Howlett" <Liam.Howlett@...cle.com>,
Jens Axboe <axboe@...nel.dk>, linux-kernel@...r.kernel.org,
willy@...radead.org, linux-mm@...ck.org, x86@...nel.org,
linux-block@...r.kernel.org, linux-fsdevel@...r.kernel.org,
"Darrick J . Wong" <djwong@...nel.org>, mcgrof@...nel.org,
gost.dev@...sung.com, hch@....de, Pankaj Raghav <p.raghav@...sung.com>
Subject: Re: [PATCH v2 0/5] add static PMD zero page support
On 15.07.25 16:02, Lorenzo Stoakes wrote:
> On Wed, Jul 09, 2025 at 10:03:51AM +0200, Pankaj Raghav wrote:
>> Hi Zi,
>>
>>>> Add a config option STATIC_PMD_ZERO_PAGE that will always allocate the huge_zero_folio via
>>>> memblock, and it will never be freed.
>>>
>>> Do the above users want a PMD sized zero page or a 2MB zero page? Because on systems with non
>>> 4KB base page size, e.g., ARM64 with 64KB base page, PMD size is different. ARM64 with 64KB base
>>> page has 512MB PMD sized pages. Having STATIC_PMD_ZERO_PAGE means losing half GB memory. I am
>>> not sure if it is acceptable.
>>>
>>
>> That is a good point. My intial RFC patches allocated 2M instead of a PMD sized
>> page.
>>
>> But later David wanted to reuse the memory we allocate here with huge_zero_folio. So
>> if this config is enabled, we simply just use the same pointer for huge_zero_folio.
>>
>> Since that happened, I decided to go with PMD sized page.
>>
>> This config is still opt in and I would expect the users with 64k page size systems to not enable
>> this.
>>
>> But to make sure we don't enable this for those architecture, I could do a per-arch opt in with
>> something like this[1] that I did in my previous patch:
>>
>> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
>> index 340e5468980e..c3a9d136ec0a 100644
>> --- a/arch/x86/Kconfig
>> +++ b/arch/x86/Kconfig
>> @@ -153,6 +153,7 @@ config X86
>> select ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP if X86_64
>> select ARCH_WANT_HUGETLB_VMEMMAP_PREINIT if X86_64
>> select ARCH_WANTS_THP_SWAP if X86_64
>> + select ARCH_HAS_STATIC_PMD_ZERO_PAGE if X86_64
>> select ARCH_HAS_PARANOID_L1D_FLUSH
>> select ARCH_WANT_IRQS_OFF_ACTIVATE_MM
>> select BUILDTIME_TABLE_SORT
>>
>>
>> diff --git a/mm/Kconfig b/mm/Kconfig
>> index 781be3240e21..fd1c51995029 100644
>> --- a/mm/Kconfig
>> +++ b/mm/Kconfig
>> @@ -826,6 +826,19 @@ config ARCH_WANTS_THP_SWAP
>> config MM_ID
>> def_bool n
>>
>> +config ARCH_HAS_STATIC_PMD_ZERO_PAGE
>> + def_bool n
>
> Hm is this correct? arm64 supports mutliple page tables sizes, so while the
> architecture might 'support' it, it will vary based on page size, so actually we
> don't care about arch at all?
>
>> +
>> +config STATIC_PMD_ZERO_PAGE
>> + bool "Allocate a PMD page for zeroing"
>> + depends on ARCH_HAS_STATIC_PMD_ZERO_PAGE
>
> Maybe need to just make this depend on !CONFIG_PAGE_SIZE_xx?
I think at some point we discussed "when does the PMD-sized zeropage
make *any* sense on these weird arch configs" (512MiB on arm64 64bit)
No idea who wants to waste half a gig on that at runtime either.
But yeah, we should let the arch code opt in whether it wants it or not
(in particular, maybe only on arm64 with CONFIG_PAGE_SIZE_4K)
--
Cheers,
David / dhildenb
Powered by blists - more mailing lists