diff options
author | Christoph Lameter <clameter@sgi.com> | 2008-02-05 01:28:31 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-05 12:44:13 -0500 |
commit | 48667e7a43c1a1e0ba743f93ae946f8cb34ff2f9 (patch) | |
tree | b2fb79d16fbac46a859f8332cf95852b73839e07 /mm/vmalloc.c | |
parent | eebd2aa355692afaf9906f62118620f1a1c19dbb (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/vmalloc.c')
-rw-r--r-- | mm/vmalloc.c | 38 |
1 files changed, 38 insertions, 0 deletions
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 | } |
167 | EXPORT_SYMBOL_GPL(map_vm_area); | 167 | EXPORT_SYMBOL_GPL(map_vm_area); |
168 | 168 | ||
169 | /* | ||
170 | * Map a vmalloc()-space virtual address to the physical page. | ||
171 | */ | ||
172 | struct 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 | } | ||
196 | EXPORT_SYMBOL(vmalloc_to_page); | ||
197 | |||
198 | /* | ||
199 | * Map a vmalloc()-space virtual address to the physical page frame number. | ||
200 | */ | ||
201 | unsigned long vmalloc_to_pfn(void *vmalloc_addr) | ||
202 | { | ||
203 | return page_to_pfn(vmalloc_to_page(vmalloc_addr)); | ||
204 | } | ||
205 | EXPORT_SYMBOL(vmalloc_to_pfn); | ||
206 | |||
169 | static struct vm_struct *__get_vm_area_node(unsigned long size, unsigned long flags, | 207 | static 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) |