diff options
author | Vineet Gupta <vgupta@synopsys.com> | 2015-07-09 07:52:44 -0400 |
---|---|---|
committer | Vineet Gupta <vgupta@synopsys.com> | 2015-10-17 08:18:20 -0400 |
commit | bd5e88ad72b26ebf7ecb231bc22ceecd6cbdb951 (patch) | |
tree | cb9da0478c769d706cec2e9fbd140172e05b5366 /mm/pgtable-generic.c | |
parent | 52585bcc2505d6f888d4ac68ca6c55f6d1ad736a (diff) |
mm,thp: reduce ifdef'ery for THP in generic code
- pgtable-generic.c: Fold individual #ifdef for each helper into a top
level #ifdef. Makes code more readable
- Converted the stub helpers for !THP to BUILD_BUG() vs. runtime BUG()
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Link: http://lkml.kernel.org/r/20151009133450.GA8597@node
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Diffstat (limited to 'mm/pgtable-generic.c')
-rw-r--r-- | mm/pgtable-generic.c | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c index 48851894e699..c9c59bb75a17 100644 --- a/mm/pgtable-generic.c +++ b/mm/pgtable-generic.c | |||
@@ -82,12 +82,13 @@ pte_t ptep_clear_flush(struct vm_area_struct *vma, unsigned long address, | |||
82 | } | 82 | } |
83 | #endif | 83 | #endif |
84 | 84 | ||
85 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
86 | |||
85 | #ifndef __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS | 87 | #ifndef __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS |
86 | int pmdp_set_access_flags(struct vm_area_struct *vma, | 88 | int pmdp_set_access_flags(struct vm_area_struct *vma, |
87 | unsigned long address, pmd_t *pmdp, | 89 | unsigned long address, pmd_t *pmdp, |
88 | pmd_t entry, int dirty) | 90 | pmd_t entry, int dirty) |
89 | { | 91 | { |
90 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
91 | int changed = !pmd_same(*pmdp, entry); | 92 | int changed = !pmd_same(*pmdp, entry); |
92 | VM_BUG_ON(address & ~HPAGE_PMD_MASK); | 93 | VM_BUG_ON(address & ~HPAGE_PMD_MASK); |
93 | if (changed) { | 94 | if (changed) { |
@@ -95,10 +96,6 @@ int pmdp_set_access_flags(struct vm_area_struct *vma, | |||
95 | flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE); | 96 | flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE); |
96 | } | 97 | } |
97 | return changed; | 98 | return changed; |
98 | #else /* CONFIG_TRANSPARENT_HUGEPAGE */ | ||
99 | BUG(); | ||
100 | return 0; | ||
101 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ | ||
102 | } | 99 | } |
103 | #endif | 100 | #endif |
104 | 101 | ||
@@ -107,11 +104,7 @@ int pmdp_clear_flush_young(struct vm_area_struct *vma, | |||
107 | unsigned long address, pmd_t *pmdp) | 104 | unsigned long address, pmd_t *pmdp) |
108 | { | 105 | { |
109 | int young; | 106 | int young; |
110 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
111 | VM_BUG_ON(address & ~HPAGE_PMD_MASK); | 107 | VM_BUG_ON(address & ~HPAGE_PMD_MASK); |
112 | #else | ||
113 | BUG(); | ||
114 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ | ||
115 | young = pmdp_test_and_clear_young(vma, address, pmdp); | 108 | young = pmdp_test_and_clear_young(vma, address, pmdp); |
116 | if (young) | 109 | if (young) |
117 | flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE); | 110 | flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE); |
@@ -120,7 +113,6 @@ int pmdp_clear_flush_young(struct vm_area_struct *vma, | |||
120 | #endif | 113 | #endif |
121 | 114 | ||
122 | #ifndef __HAVE_ARCH_PMDP_HUGE_CLEAR_FLUSH | 115 | #ifndef __HAVE_ARCH_PMDP_HUGE_CLEAR_FLUSH |
123 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
124 | pmd_t pmdp_huge_clear_flush(struct vm_area_struct *vma, unsigned long address, | 116 | pmd_t pmdp_huge_clear_flush(struct vm_area_struct *vma, unsigned long address, |
125 | pmd_t *pmdp) | 117 | pmd_t *pmdp) |
126 | { | 118 | { |
@@ -131,11 +123,9 @@ pmd_t pmdp_huge_clear_flush(struct vm_area_struct *vma, unsigned long address, | |||
131 | flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE); | 123 | flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE); |
132 | return pmd; | 124 | return pmd; |
133 | } | 125 | } |
134 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ | ||
135 | #endif | 126 | #endif |
136 | 127 | ||
137 | #ifndef __HAVE_ARCH_PMDP_SPLITTING_FLUSH | 128 | #ifndef __HAVE_ARCH_PMDP_SPLITTING_FLUSH |
138 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
139 | void pmdp_splitting_flush(struct vm_area_struct *vma, unsigned long address, | 129 | void pmdp_splitting_flush(struct vm_area_struct *vma, unsigned long address, |
140 | pmd_t *pmdp) | 130 | pmd_t *pmdp) |
141 | { | 131 | { |
@@ -145,11 +135,9 @@ void pmdp_splitting_flush(struct vm_area_struct *vma, unsigned long address, | |||
145 | /* tlb flush only to serialize against gup-fast */ | 135 | /* tlb flush only to serialize against gup-fast */ |
146 | flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE); | 136 | flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE); |
147 | } | 137 | } |
148 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ | ||
149 | #endif | 138 | #endif |
150 | 139 | ||
151 | #ifndef __HAVE_ARCH_PGTABLE_DEPOSIT | 140 | #ifndef __HAVE_ARCH_PGTABLE_DEPOSIT |
152 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
153 | void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp, | 141 | void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp, |
154 | pgtable_t pgtable) | 142 | pgtable_t pgtable) |
155 | { | 143 | { |
@@ -162,11 +150,9 @@ void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp, | |||
162 | list_add(&pgtable->lru, &pmd_huge_pte(mm, pmdp)->lru); | 150 | list_add(&pgtable->lru, &pmd_huge_pte(mm, pmdp)->lru); |
163 | pmd_huge_pte(mm, pmdp) = pgtable; | 151 | pmd_huge_pte(mm, pmdp) = pgtable; |
164 | } | 152 | } |
165 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ | ||
166 | #endif | 153 | #endif |
167 | 154 | ||
168 | #ifndef __HAVE_ARCH_PGTABLE_WITHDRAW | 155 | #ifndef __HAVE_ARCH_PGTABLE_WITHDRAW |
169 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
170 | /* no "address" argument so destroys page coloring of some arch */ | 156 | /* no "address" argument so destroys page coloring of some arch */ |
171 | pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp) | 157 | pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp) |
172 | { | 158 | { |
@@ -185,11 +171,9 @@ pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp) | |||
185 | } | 171 | } |
186 | return pgtable; | 172 | return pgtable; |
187 | } | 173 | } |
188 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ | ||
189 | #endif | 174 | #endif |
190 | 175 | ||
191 | #ifndef __HAVE_ARCH_PMDP_INVALIDATE | 176 | #ifndef __HAVE_ARCH_PMDP_INVALIDATE |
192 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
193 | void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, | 177 | void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, |
194 | pmd_t *pmdp) | 178 | pmd_t *pmdp) |
195 | { | 179 | { |
@@ -197,11 +181,9 @@ void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, | |||
197 | set_pmd_at(vma->vm_mm, address, pmdp, pmd_mknotpresent(entry)); | 181 | set_pmd_at(vma->vm_mm, address, pmdp, pmd_mknotpresent(entry)); |
198 | flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE); | 182 | flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE); |
199 | } | 183 | } |
200 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ | ||
201 | #endif | 184 | #endif |
202 | 185 | ||
203 | #ifndef pmdp_collapse_flush | 186 | #ifndef pmdp_collapse_flush |
204 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
205 | pmd_t pmdp_collapse_flush(struct vm_area_struct *vma, unsigned long address, | 187 | pmd_t pmdp_collapse_flush(struct vm_area_struct *vma, unsigned long address, |
206 | pmd_t *pmdp) | 188 | pmd_t *pmdp) |
207 | { | 189 | { |
@@ -217,5 +199,5 @@ pmd_t pmdp_collapse_flush(struct vm_area_struct *vma, unsigned long address, | |||
217 | flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE); | 199 | flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE); |
218 | return pmd; | 200 | return pmd; |
219 | } | 201 | } |
220 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ | ||
221 | #endif | 202 | #endif |
203 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ | ||