mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-04-06 20:02:33 +07:00
mm/vmalloc: interchage the implementation of vmalloc_to_{pfn,page}
Currently we are implementing vmalloc_to_pfn() as a wrapper around vmalloc_to_page(), which is implemented as follow: 1. walks the page talbes to generates the corresponding pfn, 2. then converts the pfn to struct page, 3. returns it. And vmalloc_to_pfn() re-wraps vmalloc_to_page() to get the pfn. This seems too circuitous, so this patch reverses the way: implement vmalloc_to_page() as a wrapper around vmalloc_to_pfn(). This makes vmalloc_to_pfn() and vmalloc_to_page() slightly more efficient. No functional change. Signed-off-by: Jianyu Zhan <nasa4836@gmail.com> Cc: Vladimir Murzin <murzin.v@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
d80be7c751
commit
ece86e222d
28
mm/vmalloc.c
28
mm/vmalloc.c
@ -220,12 +220,12 @@ int is_vmalloc_or_module_addr(const void *x)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Walk a vmap address to the struct page it maps.
|
* Walk a vmap address to the physical pfn it maps to.
|
||||||
*/
|
*/
|
||||||
struct page *vmalloc_to_page(const void *vmalloc_addr)
|
unsigned long vmalloc_to_pfn(const void *vmalloc_addr)
|
||||||
{
|
{
|
||||||
unsigned long addr = (unsigned long) vmalloc_addr;
|
unsigned long addr = (unsigned long) vmalloc_addr;
|
||||||
struct page *page = NULL;
|
unsigned long pfn = 0;
|
||||||
pgd_t *pgd = pgd_offset_k(addr);
|
pgd_t *pgd = pgd_offset_k(addr);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -244,24 +244,24 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
|
|||||||
ptep = pte_offset_map(pmd, addr);
|
ptep = pte_offset_map(pmd, addr);
|
||||||
pte = *ptep;
|
pte = *ptep;
|
||||||
if (pte_present(pte))
|
if (pte_present(pte))
|
||||||
page = pte_page(pte);
|
pfn = pte_pfn(pte);
|
||||||
pte_unmap(ptep);
|
pte_unmap(ptep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return page;
|
return pfn;
|
||||||
}
|
|
||||||
EXPORT_SYMBOL(vmalloc_to_page);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Map a vmalloc()-space virtual address to the physical page frame number.
|
|
||||||
*/
|
|
||||||
unsigned long vmalloc_to_pfn(const void *vmalloc_addr)
|
|
||||||
{
|
|
||||||
return page_to_pfn(vmalloc_to_page(vmalloc_addr));
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(vmalloc_to_pfn);
|
EXPORT_SYMBOL(vmalloc_to_pfn);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Map a vmalloc()-space virtual address to the struct page.
|
||||||
|
*/
|
||||||
|
struct page *vmalloc_to_page(const void *vmalloc_addr)
|
||||||
|
{
|
||||||
|
return pfn_to_page(vmalloc_to_pfn(vmalloc_addr));
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(vmalloc_to_page);
|
||||||
|
|
||||||
|
|
||||||
/*** Global kva allocator ***/
|
/*** Global kva allocator ***/
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user