提交 14e07298 编写于 作者: A Andy Whitcroft 提交者: Linus Torvalds

add pfn_valid_within helper for sub-MAX_ORDER hole detection

Generally we work under the assumption that memory the mem_map array is
contigious and valid out to MAX_ORDER_NR_PAGES block of pages, ie.  that if we
have validated any page within this MAX_ORDER_NR_PAGES block we need not check
any other.  This is not true when CONFIG_HOLES_IN_ZONE is set and we must
check each and every reference we make from a pfn.

Add a pfn_valid_within() helper which should be used when scanning pages
within a MAX_ORDER_NR_PAGES block when we have already checked the validility
of the block normally with pfn_valid().  This can then be optimised away when
we do not have holes within a MAX_ORDER_NR_PAGES block of pages.
Signed-off-by: NAndy Whitcroft <apw@shadowen.org>
Acked-by: NMel Gorman <mel@csn.ul.ie>
Acked-by: NBob Picco <bob.picco@hp.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 ac267728
...@@ -784,6 +784,18 @@ void sparse_init(void); ...@@ -784,6 +784,18 @@ void sparse_init(void);
void memory_present(int nid, unsigned long start, unsigned long end); void memory_present(int nid, unsigned long start, unsigned long end);
unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long); unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long);
/*
* If it is possible to have holes within a MAX_ORDER_NR_PAGES, then we
* need to check pfn validility within that MAX_ORDER_NR_PAGES block.
* pfn_valid_within() should be used in this case; we optimise this away
* when we have no holes within a MAX_ORDER_NR_PAGES block.
*/
#ifdef CONFIG_HOLES_IN_ZONE
#define pfn_valid_within(pfn) pfn_valid(pfn)
#else
#define pfn_valid_within(pfn) (1)
#endif
#endif /* !__ASSEMBLY__ */ #endif /* !__ASSEMBLY__ */
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* _LINUX_MMZONE_H */ #endif /* _LINUX_MMZONE_H */
...@@ -156,10 +156,8 @@ static int page_outside_zone_boundaries(struct zone *zone, struct page *page) ...@@ -156,10 +156,8 @@ static int page_outside_zone_boundaries(struct zone *zone, struct page *page)
static int page_is_consistent(struct zone *zone, struct page *page) static int page_is_consistent(struct zone *zone, struct page *page)
{ {
#ifdef CONFIG_HOLES_IN_ZONE if (!pfn_valid_within(page_to_pfn(page)))
if (!pfn_valid(page_to_pfn(page)))
return 0; return 0;
#endif
if (zone != page_zone(page)) if (zone != page_zone(page))
return 0; return 0;
...@@ -346,10 +344,8 @@ __find_combined_index(unsigned long page_idx, unsigned int order) ...@@ -346,10 +344,8 @@ __find_combined_index(unsigned long page_idx, unsigned int order)
static inline int page_is_buddy(struct page *page, struct page *buddy, static inline int page_is_buddy(struct page *page, struct page *buddy,
int order) int order)
{ {
#ifdef CONFIG_HOLES_IN_ZONE if (!pfn_valid_within(page_to_pfn(buddy)))
if (!pfn_valid(page_to_pfn(buddy)))
return 0; return 0;
#endif
if (page_zone_id(page) != page_zone_id(buddy)) if (page_zone_id(page) != page_zone_id(buddy))
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册