Core mm expects __PAGETABLE_{PUD,PMD}_FOLDED to be defined if these page table levels folded. Usually, these defines are provided by <asm-generic/pgtable-nopmd.h> and <asm-generic/pgtable-nopud.h>. But some architectures fold page table levels in a custom way. They need to define these macros themself. This patch adds missing defines. The patch fixes mm->nr_pmds underflow and eliminates dead __pmd_alloc() and __pud_alloc() on architectures without these page table levels.
Unified · Split
| @@ -123,12 +123,14 @@ extern unsigned long empty_zero_page; · 122 unmodified lines | |||
| 123 | #define PGDIR_MASK (~(PGDIR_SIZE - 1)) | 123 | #define PGDIR_MASK (~(PGDIR_SIZE - 1)) |
| 124 | #define PTRS_PER_PGD 64 | 124 | #define PTRS_PER_PGD 64 |
| 125 | 125 | ||
| 126 | #define __PAGETABLE_PUD_FOLDED | ||
| 126 | #define PUD_SHIFT 26 | 127 | #define PUD_SHIFT 26 |
| 127 | #define PTRS_PER_PUD 1 | 128 | #define PTRS_PER_PUD 1 |
| 128 | #define PUD_SIZE (1UL << PUD_SHIFT) | 129 | #define PUD_SIZE (1UL << PUD_SHIFT) |
| 129 | #define PUD_MASK (~(PUD_SIZE - 1)) | 130 | #define PUD_MASK (~(PUD_SIZE - 1)) |
| 130 | #define PUE_SIZE 256 | 131 | #define PUE_SIZE 256 |
| 131 | 132 | ||
| 133 | #define __PAGETABLE_PMD_FOLDED | ||
| 132 | #define PMD_SHIFT 26 | 134 | #define PMD_SHIFT 26 |
| 133 | #define PMD_SIZE (1UL << PMD_SHIFT) | 135 | #define PMD_SIZE (1UL << PMD_SHIFT) |
| 134 | #define PMD_MASK (~(PMD_SIZE - 1)) | 136 | #define PMD_MASK (~(PMD_SIZE - 1)) |
| @@ -13,6 +13,7 @@ · 12 unmodified lines | |||
| 13 | * the M32R is two-level, so we don't really have any | 13 | * the M32R is two-level, so we don't really have any |
| 14 | * PMD directory physically. | 14 | * PMD directory physically. |
| 15 | */ | 15 | */ |
| 16 | #define __PAGETABLE_PMD_FOLDED | ||
| 16 | #define PMD_SHIFT 22 | 17 | #define PMD_SHIFT 22 |
| 17 | #define PTRS_PER_PMD 1 | 18 | #define PTRS_PER_PMD 1 |
| 18 | 19 | ||
| @@ -54,10 +54,12 @@ · 53 unmodified lines | |||
| 54 | */ | 54 | */ |
| 55 | #ifdef CONFIG_SUN3 | 55 | #ifdef CONFIG_SUN3 |
| 56 | #define PTRS_PER_PTE 16 | 56 | #define PTRS_PER_PTE 16 |
| 57 | #define __PAGETABLE_PMD_FOLDED | ||
| 57 | #define PTRS_PER_PMD 1 | 58 | #define PTRS_PER_PMD 1 |
| 58 | #define PTRS_PER_PGD 2048 | 59 | #define PTRS_PER_PGD 2048 |
| 59 | #elif defined(CONFIG_COLDFIRE) | 60 | #elif defined(CONFIG_COLDFIRE) |
| 60 | #define PTRS_PER_PTE 512 | 61 | #define PTRS_PER_PTE 512 |
| 62 | #define __PAGETABLE_PMD_FOLDED | ||
| 61 | #define PTRS_PER_PMD 1 | 63 | #define PTRS_PER_PMD 1 |
| 62 | #define PTRS_PER_PGD 1024 | 64 | #define PTRS_PER_PGD 1024 |
| 63 | #else | 65 | #else |
| @@ -56,7 +56,9 @@ extern void paging_init(void); · 55 unmodified lines | |||
| 56 | #define PGDIR_SHIFT 22 | 56 | #define PGDIR_SHIFT 22 |
| 57 | #define PTRS_PER_PGD 1024 | 57 | #define PTRS_PER_PGD 1024 |
| 58 | #define PTRS_PER_PUD 1 /* we don't really have any PUD physically */ | 58 | #define PTRS_PER_PUD 1 /* we don't really have any PUD physically */ |
| 59 | #define __PAGETABLE_PUD_FOLDED | ||
| 59 | #define PTRS_PER_PMD 1 /* we don't really have any PMD physically */ | 60 | #define PTRS_PER_PMD 1 /* we don't really have any PMD physically */ |
| 61 | #define __PAGETABLE_PMD_FOLDED | ||
| 60 | #define PTRS_PER_PTE 1024 | 62 | #define PTRS_PER_PTE 1024 |
| 61 | 63 | ||
| 62 | #define PGD_SIZE PAGE_SIZE | 64 | #define PGD_SIZE PAGE_SIZE |
| @@ -96,6 +96,7 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long); · 95 unmodified lines | |||
| 96 | #if PT_NLEVELS == 3 | 96 | #if PT_NLEVELS == 3 |
| 97 | #define BITS_PER_PMD (PAGE_SHIFT + PMD_ORDER - BITS_PER_PMD_ENTRY) | 97 | #define BITS_PER_PMD (PAGE_SHIFT + PMD_ORDER - BITS_PER_PMD_ENTRY) |
| 98 | #else | 98 | #else |
| 99 | #define __PAGETABLE_PMD_FOLDED | ||
| 99 | #define BITS_PER_PMD 0 | 100 | #define BITS_PER_PMD 0 |
| 100 | #endif | 101 | #endif |
| 101 | #define PTRS_PER_PMD (1UL << BITS_PER_PMD) | 102 | #define PTRS_PER_PMD (1UL << BITS_PER_PMD) |
| @@ -91,7 +91,9 @@ extern unsigned long zero_page_mask; · 90 unmodified lines | |||
| 91 | */ | 91 | */ |
| 92 | #define PTRS_PER_PTE 256 | 92 | #define PTRS_PER_PTE 256 |
| 93 | #ifndef CONFIG_64BIT | 93 | #ifndef CONFIG_64BIT |
| 94 | #define __PAGETABLE_PUD_FOLDED | ||
| 94 | #define PTRS_PER_PMD 1 | 95 | #define PTRS_PER_PMD 1 |
| 96 | #define __PAGETABLE_PMD_FOLDED | ||
| 95 | #define PTRS_PER_PUD 1 | 97 | #define PTRS_PER_PUD 1 |
| 96 | #else /* CONFIG_64BIT */ | 98 | #else /* CONFIG_64BIT */ |
| 97 | #define PTRS_PER_PMD 2048 | 99 | #define PTRS_PER_PMD 2048 |