mm/page_ext: move functions around for minor cleanups to page_ext
1. move page_ext_get and page_ext_put down to remove forward declaration of lookup_page_ext. 2. move page_ext_init_flatmem_late down to existing non SPARS block to remove a new non SPARS block and to keep code for non SPARS tight. Link: https://lkml.kernel.org/r/20230714114749.1743032-4-shikemeng@huaweicloud.com Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
3c09be5a2b
commit
eb0da7f6e0
|
@ -90,7 +90,6 @@ static struct page_ext_operations *page_ext_ops[] __initdata = {
|
||||||
unsigned long page_ext_size;
|
unsigned long page_ext_size;
|
||||||
|
|
||||||
static unsigned long total_usage;
|
static unsigned long total_usage;
|
||||||
static struct page_ext *lookup_page_ext(const struct page *page);
|
|
||||||
|
|
||||||
bool early_page_ext __meminitdata;
|
bool early_page_ext __meminitdata;
|
||||||
static int __init setup_early_page_ext(char *str)
|
static int __init setup_early_page_ext(char *str)
|
||||||
|
@ -137,62 +136,16 @@ static void __init invoke_init_callbacks(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CONFIG_SPARSEMEM
|
|
||||||
void __init page_ext_init_flatmem_late(void)
|
|
||||||
{
|
|
||||||
invoke_init_callbacks();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline struct page_ext *get_entry(void *base, unsigned long index)
|
static inline struct page_ext *get_entry(void *base, unsigned long index)
|
||||||
{
|
{
|
||||||
return base + page_ext_size * index;
|
return base + page_ext_size * index;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* page_ext_get() - Get the extended information for a page.
|
|
||||||
* @page: The page we're interested in.
|
|
||||||
*
|
|
||||||
* Ensures that the page_ext will remain valid until page_ext_put()
|
|
||||||
* is called.
|
|
||||||
*
|
|
||||||
* Return: NULL if no page_ext exists for this page.
|
|
||||||
* Context: Any context. Caller may not sleep until they have called
|
|
||||||
* page_ext_put().
|
|
||||||
*/
|
|
||||||
struct page_ext *page_ext_get(struct page *page)
|
|
||||||
{
|
|
||||||
struct page_ext *page_ext;
|
|
||||||
|
|
||||||
rcu_read_lock();
|
|
||||||
page_ext = lookup_page_ext(page);
|
|
||||||
if (!page_ext) {
|
|
||||||
rcu_read_unlock();
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return page_ext;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* page_ext_put() - Working with page extended information is done.
|
|
||||||
* @page_ext: Page extended information received from page_ext_get().
|
|
||||||
*
|
|
||||||
* The page extended information of the page may not be valid after this
|
|
||||||
* function is called.
|
|
||||||
*
|
|
||||||
* Return: None.
|
|
||||||
* Context: Any context with corresponding page_ext_get() is called.
|
|
||||||
*/
|
|
||||||
void page_ext_put(struct page_ext *page_ext)
|
|
||||||
{
|
|
||||||
if (unlikely(!page_ext))
|
|
||||||
return;
|
|
||||||
|
|
||||||
rcu_read_unlock();
|
|
||||||
}
|
|
||||||
#ifndef CONFIG_SPARSEMEM
|
#ifndef CONFIG_SPARSEMEM
|
||||||
|
void __init page_ext_init_flatmem_late(void)
|
||||||
|
{
|
||||||
|
invoke_init_callbacks();
|
||||||
|
}
|
||||||
|
|
||||||
void __meminit pgdat_page_ext_init(struct pglist_data *pgdat)
|
void __meminit pgdat_page_ext_init(struct pglist_data *pgdat)
|
||||||
{
|
{
|
||||||
|
@ -536,3 +489,46 @@ void __meminit pgdat_page_ext_init(struct pglist_data *pgdat)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* page_ext_get() - Get the extended information for a page.
|
||||||
|
* @page: The page we're interested in.
|
||||||
|
*
|
||||||
|
* Ensures that the page_ext will remain valid until page_ext_put()
|
||||||
|
* is called.
|
||||||
|
*
|
||||||
|
* Return: NULL if no page_ext exists for this page.
|
||||||
|
* Context: Any context. Caller may not sleep until they have called
|
||||||
|
* page_ext_put().
|
||||||
|
*/
|
||||||
|
struct page_ext *page_ext_get(struct page *page)
|
||||||
|
{
|
||||||
|
struct page_ext *page_ext;
|
||||||
|
|
||||||
|
rcu_read_lock();
|
||||||
|
page_ext = lookup_page_ext(page);
|
||||||
|
if (!page_ext) {
|
||||||
|
rcu_read_unlock();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return page_ext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* page_ext_put() - Working with page extended information is done.
|
||||||
|
* @page_ext: Page extended information received from page_ext_get().
|
||||||
|
*
|
||||||
|
* The page extended information of the page may not be valid after this
|
||||||
|
* function is called.
|
||||||
|
*
|
||||||
|
* Return: None.
|
||||||
|
* Context: Any context with corresponding page_ext_get() is called.
|
||||||
|
*/
|
||||||
|
void page_ext_put(struct page_ext *page_ext)
|
||||||
|
{
|
||||||
|
if (unlikely(!page_ext))
|
||||||
|
return;
|
||||||
|
|
||||||
|
rcu_read_unlock();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue