diff options
Diffstat (limited to 'mm/internal.h')
-rw-r--r-- | mm/internal.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/mm/internal.h b/mm/internal.h index e4e728bdf324..f482460de3e6 100644 --- a/mm/internal.h +++ b/mm/internal.h | |||
@@ -176,6 +176,34 @@ static inline void free_page_mlock(struct page *page) { } | |||
176 | #endif /* CONFIG_UNEVICTABLE_LRU */ | 176 | #endif /* CONFIG_UNEVICTABLE_LRU */ |
177 | 177 | ||
178 | /* | 178 | /* |
179 | * Return the mem_map entry representing the 'offset' subpage within | ||
180 | * the maximally aligned gigantic page 'base'. Handle any discontiguity | ||
181 | * in the mem_map at MAX_ORDER_NR_PAGES boundaries. | ||
182 | */ | ||
183 | static inline struct page *mem_map_offset(struct page *base, int offset) | ||
184 | { | ||
185 | if (unlikely(offset >= MAX_ORDER_NR_PAGES)) | ||
186 | return pfn_to_page(page_to_pfn(base) + offset); | ||
187 | return base + offset; | ||
188 | } | ||
189 | |||
190 | /* | ||
191 | * Iterator over all subpages withing the maximally aligned gigantic | ||
192 | * page 'base'. Handle any discontiguity in the mem_map. | ||
193 | */ | ||
194 | static inline struct page *mem_map_next(struct page *iter, | ||
195 | struct page *base, int offset) | ||
196 | { | ||
197 | if (unlikely((offset & (MAX_ORDER_NR_PAGES - 1)) == 0)) { | ||
198 | unsigned long pfn = page_to_pfn(base) + offset; | ||
199 | if (!pfn_valid(pfn)) | ||
200 | return NULL; | ||
201 | return pfn_to_page(pfn); | ||
202 | } | ||
203 | return iter + 1; | ||
204 | } | ||
205 | |||
206 | /* | ||
179 | * FLATMEM and DISCONTIGMEM configurations use alloc_bootmem_node, | 207 | * FLATMEM and DISCONTIGMEM configurations use alloc_bootmem_node, |
180 | * so all functions starting at paging_init should be marked __init | 208 | * so all functions starting at paging_init should be marked __init |
181 | * in those cases. SPARSEMEM, however, allows for memory hotplug, | 209 | * in those cases. SPARSEMEM, however, allows for memory hotplug, |