diff options
author | Andy Whitcroft <apw@shadowen.org> | 2006-06-23 05:03:12 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-23 10:42:47 -0400 |
commit | 67de648211fa041fe08a0c25241a4980bbb90698 (patch) | |
tree | 94f737e0fed7c40dc59e94f05d6851e490082068 /include | |
parent | 6811378e7d8b9aa4fca2a1ca73d24c9d67c9cb12 (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 'include')
-rw-r--r-- | include/asm-generic/memory_model.h | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/include/asm-generic/memory_model.h b/include/asm-generic/memory_model.h index 0cfb086dd373..8078cbd2c016 100644 --- a/include/asm-generic/memory_model.h +++ b/include/asm-generic/memory_model.h | |||
@@ -23,29 +23,23 @@ | |||
23 | 23 | ||
24 | #endif /* CONFIG_DISCONTIGMEM */ | 24 | #endif /* CONFIG_DISCONTIGMEM */ |
25 | 25 | ||
26 | #ifdef CONFIG_OUT_OF_LINE_PFN_TO_PAGE | ||
27 | struct page; | ||
28 | /* this is useful when inlined pfn_to_page is too big */ | ||
29 | extern struct page *pfn_to_page(unsigned long pfn); | ||
30 | extern unsigned long page_to_pfn(struct page *page); | ||
31 | #else | ||
32 | /* | 26 | /* |
33 | * supports 3 memory models. | 27 | * supports 3 memory models. |
34 | */ | 28 | */ |
35 | #if defined(CONFIG_FLATMEM) | 29 | #if defined(CONFIG_FLATMEM) |
36 | 30 | ||
37 | #define pfn_to_page(pfn) (mem_map + ((pfn) - ARCH_PFN_OFFSET)) | 31 | #define __pfn_to_page(pfn) (mem_map + ((pfn) - ARCH_PFN_OFFSET)) |
38 | #define page_to_pfn(page) ((unsigned long)((page) - mem_map) + \ | 32 | #define __page_to_pfn(page) ((unsigned long)((page) - mem_map) + \ |
39 | ARCH_PFN_OFFSET) | 33 | ARCH_PFN_OFFSET) |
40 | #elif defined(CONFIG_DISCONTIGMEM) | 34 | #elif defined(CONFIG_DISCONTIGMEM) |
41 | 35 | ||
42 | #define pfn_to_page(pfn) \ | 36 | #define __pfn_to_page(pfn) \ |
43 | ({ unsigned long __pfn = (pfn); \ | 37 | ({ unsigned long __pfn = (pfn); \ |
44 | unsigned long __nid = arch_pfn_to_nid(pfn); \ | 38 | unsigned long __nid = arch_pfn_to_nid(pfn); \ |
45 | NODE_DATA(__nid)->node_mem_map + arch_local_page_offset(__pfn, __nid);\ | 39 | NODE_DATA(__nid)->node_mem_map + arch_local_page_offset(__pfn, __nid);\ |
46 | }) | 40 | }) |
47 | 41 | ||
48 | #define page_to_pfn(pg) \ | 42 | #define __page_to_pfn(pg) \ |
49 | ({ struct page *__pg = (pg); \ | 43 | ({ struct page *__pg = (pg); \ |
50 | struct pglist_data *__pgdat = NODE_DATA(page_to_nid(__pg)); \ | 44 | struct pglist_data *__pgdat = NODE_DATA(page_to_nid(__pg)); \ |
51 | (unsigned long)(__pg - __pgdat->node_mem_map) + \ | 45 | (unsigned long)(__pg - __pgdat->node_mem_map) + \ |
@@ -57,18 +51,27 @@ extern unsigned long page_to_pfn(struct page *page); | |||
57 | * Note: section's mem_map is encorded to reflect its start_pfn. | 51 | * Note: section's mem_map is encorded to reflect its start_pfn. |
58 | * section[i].section_mem_map == mem_map's address - start_pfn; | 52 | * section[i].section_mem_map == mem_map's address - start_pfn; |
59 | */ | 53 | */ |
60 | #define page_to_pfn(pg) \ | 54 | #define __page_to_pfn(pg) \ |
61 | ({ struct page *__pg = (pg); \ | 55 | ({ struct page *__pg = (pg); \ |
62 | int __sec = page_to_section(__pg); \ | 56 | int __sec = page_to_section(__pg); \ |
63 | __pg - __section_mem_map_addr(__nr_to_section(__sec)); \ | 57 | __pg - __section_mem_map_addr(__nr_to_section(__sec)); \ |
64 | }) | 58 | }) |
65 | 59 | ||
66 | #define pfn_to_page(pfn) \ | 60 | #define __pfn_to_page(pfn) \ |
67 | ({ unsigned long __pfn = (pfn); \ | 61 | ({ unsigned long __pfn = (pfn); \ |
68 | struct mem_section *__sec = __pfn_to_section(__pfn); \ | 62 | struct mem_section *__sec = __pfn_to_section(__pfn); \ |
69 | __section_mem_map_addr(__sec) + __pfn; \ | 63 | __section_mem_map_addr(__sec) + __pfn; \ |
70 | }) | 64 | }) |
71 | #endif /* CONFIG_FLATMEM/DISCONTIGMEM/SPARSEMEM */ | 65 | #endif /* CONFIG_FLATMEM/DISCONTIGMEM/SPARSEMEM */ |
66 | |||
67 | #ifdef CONFIG_OUT_OF_LINE_PFN_TO_PAGE | ||
68 | struct page; | ||
69 | /* this is useful when inlined pfn_to_page is too big */ | ||
70 | extern struct page *pfn_to_page(unsigned long pfn); | ||
71 | extern unsigned long page_to_pfn(struct page *page); | ||
72 | #else | ||
73 | #define page_to_pfn __page_to_pfn | ||
74 | #define pfn_to_page __pfn_to_page | ||
72 | #endif /* CONFIG_OUT_OF_LINE_PFN_TO_PAGE */ | 75 | #endif /* CONFIG_OUT_OF_LINE_PFN_TO_PAGE */ |
73 | 76 | ||
74 | #endif /* __ASSEMBLY__ */ | 77 | #endif /* __ASSEMBLY__ */ |