mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
mm: add swap cache interface for swap reference
In a following patch, the usage of swap cache is recorded into swap_map. This patch is for necessary interface changes to do that. 2 interfaces: - swapcache_prepare() - swapcache_free() are added for allocating/freeing refcnt from swap-cache to existing swap entries. But implementation itself is not changed under this patch. At adding swapcache_free(), memcg's hook code is moved under swapcache_free(). This is better than using scattered hooks. Signed-off-by: KAMEZAWA Hiroyuki <[email protected]> Reviewed-by: Daisuke Nishimura <[email protected]> Acked-by: Balbir Singh <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Li Zefan <[email protected]> Cc: Dhaval Giani <[email protected]> Cc: YAMAMOTO Takashi <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
6837765963
commit
cb4b86ba47
5 changed files with 33 additions and 9 deletions
|
|
@ -509,6 +509,16 @@ void swap_free(swp_entry_t entry)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called after dropping swapcache to decrease refcnt to swap entries.
|
||||
*/
|
||||
void swapcache_free(swp_entry_t entry, struct page *page)
|
||||
{
|
||||
if (page)
|
||||
mem_cgroup_uncharge_swapcache(page, entry);
|
||||
return swap_free(entry);
|
||||
}
|
||||
|
||||
/*
|
||||
* How many references to page are currently swapped out?
|
||||
*/
|
||||
|
|
@ -1979,6 +1989,15 @@ bad_file:
|
|||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when allocating swap cache for exising swap entry,
|
||||
*/
|
||||
int swapcache_prepare(swp_entry_t entry)
|
||||
{
|
||||
return swap_duplicate(entry);
|
||||
}
|
||||
|
||||
|
||||
struct swap_info_struct *
|
||||
get_swap_info_struct(unsigned type)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue