aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorChristoph Lameter <clameter@sgi.com>2008-02-05 01:28:31 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-05 12:44:13 -0500
commit48667e7a43c1a1e0ba743f93ae946f8cb34ff2f9 (patch)
treeb2fb79d16fbac46a859f8332cf95852b73839e07 /mm
parenteebd2aa355692afaf9906f62118620f1a1c19dbb (diff)
Move vmalloc_to_page() to mm/vmalloc.
We already have page table manipulation for vmalloc in vmalloc.c. Move the vmalloc_to_page() function there as well. Move the definitions for vmalloc related functions in mm.h to a newly created section. A better place would be vmalloc.h but mm.h is basic and may depend on these functions. An alternative would be to include vmalloc.h in mm.h (like done for vmstat.h). Signed-off-by: Christoph Lameter <clameter@sgi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/memory.c40
-rw-r--r--mm/vmalloc.c38
2 files changed, 38 insertions, 40 deletions
diff --git a/mm/memory.c b/mm/memory.c
index d902d0e25edc..1b8ca160f1d0 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2618,46 +2618,6 @@ int make_pages_present(unsigned long addr, unsigned long end)
2618 return ret == len ? 0 : -1; 2618 return ret == len ? 0 : -1;
2619} 2619}
2620 2620
2621/*
2622 * Map a vmalloc()-space virtual address to the physical page.
2623 */
2624struct page * vmalloc_to_page(void * vmalloc_addr)
2625{
2626 unsigned long addr = (unsigned long) vmalloc_addr;
2627 struct page *page = NULL;
2628 pgd_t *pgd = pgd_offset_k(addr);
2629 pud_t *pud;
2630 pmd_t *pmd;
2631 pte_t *ptep, pte;
2632
2633 if (!pgd_none(*pgd)) {
2634 pud = pud_offset(pgd, addr);
2635 if (!pud_none(*pud)) {
2636 pmd = pmd_offset(pud, addr);
2637 if (!pmd_none(*pmd)) {
2638 ptep = pte_offset_map(pmd, addr);
2639 pte = *ptep;
2640 if (pte_present(pte))
2641 page = pte_page(pte);
2642 pte_unmap(ptep);
2643 }
2644 }
2645 }
2646 return page;
2647}
2648
2649EXPORT_SYMBOL(vmalloc_to_page);
2650
2651/*
2652 * Map a vmalloc()-space virtual address to the physical page frame number.
2653 */
2654unsigned long vmalloc_to_pfn(void * vmalloc_addr)
2655{
2656 return page_to_pfn(vmalloc_to_page(vmalloc_addr));
2657}
2658
2659EXPORT_SYMBOL(vmalloc_to_pfn);
2660
2661#if !defined(__HAVE_ARCH_GATE_AREA) 2621#if !defined(__HAVE_ARCH_GATE_AREA)
2662 2622
2663#if defined(AT_SYSINFO_EHDR) 2623#if defined(AT_SYSINFO_EHDR)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index af77e171e339..e4c59a30835b 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -166,6 +166,44 @@ int map_vm_area(struct vm_struct *area, pgprot_t prot, struct page ***pages)
166} 166}
167EXPORT_SYMBOL_GPL(map_vm_area); 167EXPORT_SYMBOL_GPL(map_vm_area);
168 168
169/*
170 * Map a vmalloc()-space virtual address to the physical page.
171 */
172struct page *vmalloc_to_page(void *vmalloc_addr)
173{
174 unsigned long addr = (unsigned long) vmalloc_addr;
175 struct page *page = NULL;
176 pgd_t *pgd = pgd_offset_k(addr);
177 pud_t *pud;
178 pmd_t *pmd;
179 pte_t *ptep, pte;
180
181 if (!pgd_none(*pgd)) {
182 pud = pud_offset(pgd, addr);
183 if (!pud_none(*pud)) {
184 pmd = pmd_offset(pud, addr);
185 if (!pmd_none(*pmd)) {
186 ptep = pte_offset_map(pmd, addr);
187 pte = *ptep;
188 if (pte_present(pte))
189 page = pte_page(pte);
190 pte_unmap(ptep);
191 }
192 }
193 }
194 return page;
195}
196EXPORT_SYMBOL(vmalloc_to_page);
197
198/*
199 * Map a vmalloc()-space virtual address to the physical page frame number.
200 */
201unsigned long vmalloc_to_pfn(void *vmalloc_addr)
202{
203 return page_to_pfn(vmalloc_to_page(vmalloc_addr));
204}
205EXPORT_SYMBOL(vmalloc_to_pfn);
206
169static struct vm_struct *__get_vm_area_node(unsigned long size, unsigned long flags, 207static struct vm_struct *__get_vm_area_node(unsigned long size, unsigned long flags,
170 unsigned long start, unsigned long end, 208 unsigned long start, unsigned long end,
171 int node, gfp_t gfp_mask) 209 int node, gfp_t gfp_mask)