ANDROID: mm: export swap_type_to_swap_info

The function swap_type_to_swap_info is exported to access the
swap_info_struct of the specified swap, which is regarded as
reserved extended memory.

Bug: 234214858
Signed-off-by: Bing Han <bing.han@transsion.com>
Change-Id: I0107e7d561150f1945a4c161e886e9e03383fff6
This commit is contained in:
Bing Han 2022-06-10 19:29:05 +08:00 committed by Treehugger Robot
parent ed2b11d639
commit 4506bcbba5

View File

@ -99,7 +99,7 @@ static atomic_t proc_poll_event = ATOMIC_INIT(0);
atomic_t nr_rotate_swap = ATOMIC_INIT(0); atomic_t nr_rotate_swap = ATOMIC_INIT(0);
static struct swap_info_struct *swap_type_to_swap_info(int type) struct swap_info_struct *swap_type_to_swap_info(int type)
{ {
if (type >= READ_ONCE(nr_swapfiles)) if (type >= READ_ONCE(nr_swapfiles))
return NULL; return NULL;
@ -107,6 +107,7 @@ static struct swap_info_struct *swap_type_to_swap_info(int type)
smp_rmb(); /* Pairs with smp_wmb in alloc_swap_info. */ smp_rmb(); /* Pairs with smp_wmb in alloc_swap_info. */
return READ_ONCE(swap_info[type]); return READ_ONCE(swap_info[type]);
} }
EXPORT_SYMBOL_GPL(swap_type_to_swap_info);
static inline unsigned char swap_count(unsigned char ent) static inline unsigned char swap_count(unsigned char ent)
{ {