Skip to content

Commit f516479

Browse files
donettom-1maddy-kerneldev
authored andcommitted
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 <[email protected]> Signed-off-by: Madhavan Srinivasan <[email protected]> Link: https://patch.msgid.link/895c4afd912c85d344a2065e348fac90529ed48f.1750593372.git.donettom@linux.ibm.com
1 parent 5845093 commit f516479

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

arch/powerpc/mm/book3s64/radix_pgtable.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,18 +1122,25 @@ int __meminit radix__vmemmap_populate(unsigned long start, unsigned long end, in
11221122
pte_t *pte;
11231123

11241124
/*
1125-
* Make sure we align the start vmemmap addr so that we calculate
1126-
* the correct start_pfn in altmap boundary check to decided whether
1127-
* we should use altmap or RAM based backing memory allocation. Also
1128-
* the address need to be aligned for set_pte operation.
1129-
1130-
* If the start addr is already PMD_SIZE aligned we will try to use
1131-
* a pmd mapping. We don't want to be too aggressive here beacause
1132-
* that will cause more allocations in RAM. So only if the namespace
1133-
* vmemmap start addr is PMD_SIZE aligned we will use PMD mapping.
1125+
* If altmap is present, Make sure we align the start vmemmap addr
1126+
* to PAGE_SIZE so that we calculate the correct start_pfn in
1127+
* altmap boundary check to decide whether we should use altmap or
1128+
* RAM based backing memory allocation. Also the address need to be
1129+
* aligned for set_pte operation. If the start addr is already
1130+
* PMD_SIZE aligned and with in the altmap boundary then we will
1131+
* try to use a pmd size altmap mapping else we go for page size
1132+
* mapping.
1133+
*
1134+
* If altmap is not present, align the vmemmap addr to PMD_SIZE and
1135+
* always allocate a PMD size page for vmemmap backing.
1136+
*
11341137
*/
11351138

1136-
start = ALIGN_DOWN(start, PAGE_SIZE);
1139+
if (altmap)
1140+
start = ALIGN_DOWN(start, PAGE_SIZE);
1141+
else
1142+
start = ALIGN_DOWN(start, PMD_SIZE);
1143+
11371144
for (addr = start; addr < end; addr = next) {
11381145
next = pmd_addr_end(addr, end);
11391146

@@ -1159,7 +1166,7 @@ int __meminit radix__vmemmap_populate(unsigned long start, unsigned long end, in
11591166
* in altmap block allocation failures, in which case
11601167
* we fallback to RAM for vmemmap allocation.
11611168
*/
1162-
if (!IS_ALIGNED(addr, PMD_SIZE) || (altmap &&
1169+
if (altmap && (!IS_ALIGNED(addr, PMD_SIZE) ||
11631170
altmap_cross_boundary(altmap, addr, PMD_SIZE))) {
11641171
/*
11651172
* make sure we don't create altmap mappings

0 commit comments

Comments
 (0)