book3s64/radix : Optimize vmemmap start alignment
authorDonet Tom <donettom@linux.ibm.com>
Sun, 22 Jun 2025 12:01:25 +0000 (07:01 -0500)
committerMadhavan Srinivasan <maddy@linux.ibm.com>
Mon, 23 Jun 2025 04:32:01 +0000 (10:02 +0530)
commitf5164797284da220c79d08d780c723f36e412e79
tree5e3718e20130827803613a683ba209eb719a9cce
parent58450938f771a2cd6eda614e666526556a158801
book3s64/radix : Optimize vmemmap start alignment

If we always align the vmemmap start to PAGE_SIZE, there is a
chance that we may end up allocating page-sized vmemmap backing
pages in RAM in the altmap not present case, because a PAGE_SIZE
aligned address is not PMD_SIZE-aligned.

In this patch, we are aligning the vmemmap start address to
PMD_SIZE if altmap is not present. This ensures that a PMD_SIZE
page is always allocated for the vmemmap mapping if altmap is
not present.

If altmap is present, Make sure we align the start vmemmap addr to
PAGE_SIZE so that we calculate the correct start_pfn in altmap
boundary check to decide whether we should use altmap or RAM based
backing memory allocation. Also the address need to be aligned for
set_pte operation. If the start addr is already PMD_SIZE aligned
and with in the altmap boundary then we will try to use a pmd size
altmap mapping else we go for page size  mapping.

So if altmap is present, we try to use the maximum number of
altmap pages; otherwise, we allocate a PMD_SIZE RAM page.

Signed-off-by: Donet Tom <donettom@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/895c4afd912c85d344a2065e348fac90529ed48f.1750593372.git.donettom@linux.ibm.com
arch/powerpc/mm/book3s64/radix_pgtable.c