aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorAndy Whitcroft <apw@shadowen.org>2006-06-23 05:03:12 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-23 10:42:47 -0400
commit67de648211fa041fe08a0c25241a4980bbb90698 (patch)
tree94f737e0fed7c40dc59e94f05d6851e490082068 /mm
parent6811378e7d8b9aa4fca2a1ca73d24c9d67c9cb12 (diff)
[PATCH] squash duplicate page_to_pfn and pfn_to_page
We have architectures where the size of page_to_pfn and pfn_to_page are significant enough to overall image size that they wish to push them out of line. However, in the process we have grown a second copy of the implementation of each of these routines for each memory model. Share the implmentation exposing it either inline or out-of-line as required. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/page_alloc.c32
1 files changed, 2 insertions, 30 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 9dfbe6b7d1c8..5af33186a25f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2879,42 +2879,14 @@ void *__init alloc_large_system_hash(const char *tablename,
2879} 2879}
2880 2880
2881#ifdef CONFIG_OUT_OF_LINE_PFN_TO_PAGE 2881#ifdef CONFIG_OUT_OF_LINE_PFN_TO_PAGE
2882/*
2883 * pfn <-> page translation. out-of-line version.
2884 * (see asm-generic/memory_model.h)
2885 */
2886#if defined(CONFIG_FLATMEM)
2887struct page *pfn_to_page(unsigned long pfn)
2888{
2889 return mem_map + (pfn - ARCH_PFN_OFFSET);
2890}
2891unsigned long page_to_pfn(struct page *page)
2892{
2893 return (page - mem_map) + ARCH_PFN_OFFSET;
2894}
2895#elif defined(CONFIG_DISCONTIGMEM)
2896struct page *pfn_to_page(unsigned long pfn) 2882struct page *pfn_to_page(unsigned long pfn)
2897{ 2883{
2898 int nid = arch_pfn_to_nid(pfn); 2884 return __pfn_to_page(pfn);
2899 return NODE_DATA(nid)->node_mem_map + arch_local_page_offset(pfn,nid);
2900} 2885}
2901unsigned long page_to_pfn(struct page *page) 2886unsigned long page_to_pfn(struct page *page)
2902{ 2887{
2903 struct pglist_data *pgdat = NODE_DATA(page_to_nid(page)); 2888 return __page_to_pfn(page);
2904 return (page - pgdat->node_mem_map) + pgdat->node_start_pfn;
2905}
2906#elif defined(CONFIG_SPARSEMEM)
2907struct page *pfn_to_page(unsigned long pfn)
2908{
2909 return __section_mem_map_addr(__pfn_to_section(pfn)) + pfn;
2910}
2911
2912unsigned long page_to_pfn(struct page *page)
2913{
2914 long section_id = page_to_section(page);
2915 return page - __section_mem_map_addr(__nr_to_section(section_id));
2916} 2889}
2917#endif /* CONFIG_FLATMEM/DISCONTIGMME/SPARSEMEM */
2918EXPORT_SYMBOL(pfn_to_page); 2890EXPORT_SYMBOL(pfn_to_page);
2919EXPORT_SYMBOL(page_to_pfn); 2891EXPORT_SYMBOL(page_to_pfn);
2920#endif /* CONFIG_OUT_OF_LINE_PFN_TO_PAGE */ 2892#endif /* CONFIG_OUT_OF_LINE_PFN_TO_PAGE */