diff options
Diffstat (limited to 'include/asm-s390/pgalloc.h')
| -rw-r--r-- | include/asm-s390/pgalloc.h | 69 |
1 files changed, 35 insertions, 34 deletions
diff --git a/include/asm-s390/pgalloc.h b/include/asm-s390/pgalloc.h index 3002fda89d33..803bc7064418 100644 --- a/include/asm-s390/pgalloc.h +++ b/include/asm-s390/pgalloc.h | |||
| @@ -22,6 +22,16 @@ | |||
| 22 | extern void diag10(unsigned long addr); | 22 | extern void diag10(unsigned long addr); |
| 23 | 23 | ||
| 24 | /* | 24 | /* |
| 25 | * Page allocation orders. | ||
| 26 | */ | ||
| 27 | #ifndef __s390x__ | ||
| 28 | # define PGD_ALLOC_ORDER 1 | ||
| 29 | #else /* __s390x__ */ | ||
| 30 | # define PMD_ALLOC_ORDER 2 | ||
| 31 | # define PGD_ALLOC_ORDER 2 | ||
| 32 | #endif /* __s390x__ */ | ||
| 33 | |||
| 34 | /* | ||
| 25 | * Allocate and free page tables. The xxx_kernel() versions are | 35 | * Allocate and free page tables. The xxx_kernel() versions are |
| 26 | * used to allocate a kernel page table - this turns on ASN bits | 36 | * used to allocate a kernel page table - this turns on ASN bits |
| 27 | * if any. | 37 | * if any. |
| @@ -29,30 +39,23 @@ extern void diag10(unsigned long addr); | |||
| 29 | 39 | ||
| 30 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) | 40 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) |
| 31 | { | 41 | { |
| 32 | pgd_t *pgd; | 42 | pgd_t *pgd = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ALLOC_ORDER); |
| 33 | int i; | 43 | int i; |
| 34 | 44 | ||
| 45 | if (!pgd) | ||
| 46 | return NULL; | ||
| 47 | for (i = 0; i < PTRS_PER_PGD; i++) | ||
| 35 | #ifndef __s390x__ | 48 | #ifndef __s390x__ |
| 36 | pgd = (pgd_t *) __get_free_pages(GFP_KERNEL,1); | 49 | pmd_clear(pmd_offset(pgd + i, i*PGDIR_SIZE)); |
| 37 | if (pgd != NULL) | 50 | #else |
| 38 | for (i = 0; i < USER_PTRS_PER_PGD; i++) | 51 | pgd_clear(pgd + i); |
| 39 | pmd_clear(pmd_offset(pgd + i, i*PGDIR_SIZE)); | 52 | #endif |
| 40 | #else /* __s390x__ */ | ||
| 41 | pgd = (pgd_t *) __get_free_pages(GFP_KERNEL,2); | ||
| 42 | if (pgd != NULL) | ||
| 43 | for (i = 0; i < PTRS_PER_PGD; i++) | ||
| 44 | pgd_clear(pgd + i); | ||
| 45 | #endif /* __s390x__ */ | ||
| 46 | return pgd; | 53 | return pgd; |
| 47 | } | 54 | } |
| 48 | 55 | ||
| 49 | static inline void pgd_free(pgd_t *pgd) | 56 | static inline void pgd_free(pgd_t *pgd) |
| 50 | { | 57 | { |
| 51 | #ifndef __s390x__ | 58 | free_pages((unsigned long) pgd, PGD_ALLOC_ORDER); |
| 52 | free_pages((unsigned long) pgd, 1); | ||
| 53 | #else /* __s390x__ */ | ||
| 54 | free_pages((unsigned long) pgd, 2); | ||
| 55 | #endif /* __s390x__ */ | ||
| 56 | } | 59 | } |
| 57 | 60 | ||
| 58 | #ifndef __s390x__ | 61 | #ifndef __s390x__ |
| @@ -68,20 +71,19 @@ static inline void pgd_free(pgd_t *pgd) | |||
| 68 | #else /* __s390x__ */ | 71 | #else /* __s390x__ */ |
| 69 | static inline pmd_t * pmd_alloc_one(struct mm_struct *mm, unsigned long vmaddr) | 72 | static inline pmd_t * pmd_alloc_one(struct mm_struct *mm, unsigned long vmaddr) |
| 70 | { | 73 | { |
| 71 | pmd_t *pmd; | 74 | pmd_t *pmd = (pmd_t *) __get_free_pages(GFP_KERNEL, PMD_ALLOC_ORDER); |
| 72 | int i; | 75 | int i; |
| 73 | 76 | ||
| 74 | pmd = (pmd_t *) __get_free_pages(GFP_KERNEL, 2); | 77 | if (!pmd) |
| 75 | if (pmd != NULL) { | 78 | return NULL; |
| 76 | for (i=0; i < PTRS_PER_PMD; i++) | 79 | for (i=0; i < PTRS_PER_PMD; i++) |
| 77 | pmd_clear(pmd+i); | 80 | pmd_clear(pmd + i); |
| 78 | } | ||
| 79 | return pmd; | 81 | return pmd; |
| 80 | } | 82 | } |
| 81 | 83 | ||
| 82 | static inline void pmd_free (pmd_t *pmd) | 84 | static inline void pmd_free (pmd_t *pmd) |
| 83 | { | 85 | { |
| 84 | free_pages((unsigned long) pmd, 2); | 86 | free_pages((unsigned long) pmd, PMD_ALLOC_ORDER); |
| 85 | } | 87 | } |
| 86 | 88 | ||
| 87 | #define __pmd_free_tlb(tlb,pmd) \ | 89 | #define __pmd_free_tlb(tlb,pmd) \ |
| @@ -123,15 +125,14 @@ pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *page) | |||
| 123 | static inline pte_t * | 125 | static inline pte_t * |
| 124 | pte_alloc_one_kernel(struct mm_struct *mm, unsigned long vmaddr) | 126 | pte_alloc_one_kernel(struct mm_struct *mm, unsigned long vmaddr) |
| 125 | { | 127 | { |
| 126 | pte_t *pte; | 128 | pte_t *pte = (pte_t *) __get_free_page(GFP_KERNEL|__GFP_REPEAT); |
| 127 | int i; | 129 | int i; |
| 128 | 130 | ||
| 129 | pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT); | 131 | if (!pte) |
| 130 | if (pte != NULL) { | 132 | return NULL; |
| 131 | for (i=0; i < PTRS_PER_PTE; i++) { | 133 | for (i=0; i < PTRS_PER_PTE; i++) { |
| 132 | pte_clear(mm, vmaddr, pte+i); | 134 | pte_clear(mm, vmaddr, pte + i); |
| 133 | vmaddr += PAGE_SIZE; | 135 | vmaddr += PAGE_SIZE; |
| 134 | } | ||
| 135 | } | 136 | } |
| 136 | return pte; | 137 | return pte; |
| 137 | } | 138 | } |
| @@ -142,7 +143,7 @@ pte_alloc_one(struct mm_struct *mm, unsigned long vmaddr) | |||
| 142 | pte_t *pte = pte_alloc_one_kernel(mm, vmaddr); | 143 | pte_t *pte = pte_alloc_one_kernel(mm, vmaddr); |
| 143 | if (pte) | 144 | if (pte) |
| 144 | return virt_to_page(pte); | 145 | return virt_to_page(pte); |
| 145 | return 0; | 146 | return NULL; |
| 146 | } | 147 | } |
| 147 | 148 | ||
| 148 | static inline void pte_free_kernel(pte_t *pte) | 149 | static inline void pte_free_kernel(pte_t *pte) |
