@@ -1003,14 +1003,15 @@ int __meminit radix__vmemmap_create_mapping(unsigned long start,
10031003 return 0 ;
10041004}
10051005
1006-
1006+ #ifdef CONFIG_ARCH_WANT_OPTIMIZE_DAX_VMEMMAP
10071007bool vmemmap_can_optimize (struct vmem_altmap * altmap , struct dev_pagemap * pgmap )
10081008{
10091009 if (radix_enabled ())
10101010 return __vmemmap_can_optimize (altmap , pgmap );
10111011
10121012 return false;
10131013}
1014+ #endif
10141015
10151016int __meminit vmemmap_check_pmd (pmd_t * pmdp , int node ,
10161017 unsigned long addr , unsigned long next )
@@ -1147,6 +1148,19 @@ int __meminit radix__vmemmap_populate(unsigned long start, unsigned long end, in
11471148 pmd_t * pmd ;
11481149 pte_t * pte ;
11491150
1151+ /*
1152+ * Make sure we align the start vmemmap addr so that we calculate
1153+ * the correct start_pfn in altmap boundary check to decided whether
1154+ * we should use altmap or RAM based backing memory allocation. Also
1155+ * the address need to be aligned for set_pte operation.
1156+
1157+ * If the start addr is already PMD_SIZE aligned we will try to use
1158+ * a pmd mapping. We don't want to be too aggressive here beacause
1159+ * that will cause more allocations in RAM. So only if the namespace
1160+ * vmemmap start addr is PMD_SIZE aligned we will use PMD mapping.
1161+ */
1162+
1163+ start = ALIGN_DOWN (start , PAGE_SIZE );
11501164 for (addr = start ; addr < end ; addr = next ) {
11511165 next = pmd_addr_end (addr , end );
11521166
@@ -1172,8 +1186,8 @@ int __meminit radix__vmemmap_populate(unsigned long start, unsigned long end, in
11721186 * in altmap block allocation failures, in which case
11731187 * we fallback to RAM for vmemmap allocation.
11741188 */
1175- if (altmap && ( !IS_ALIGNED (addr , PMD_SIZE ) ||
1176- altmap_cross_boundary (altmap , addr , PMD_SIZE ))) {
1189+ if (!IS_ALIGNED (addr , PMD_SIZE ) || ( altmap &&
1190+ altmap_cross_boundary (altmap , addr , PMD_SIZE ))) {
11771191 /*
11781192 * make sure we don't create altmap mappings
11791193 * covering things outside the device.
0 commit comments