mm, THP, swap: unify swap slot free functions to put_swap_page
Now, get_swap_page takes struct page and allocates swap space according to page size(ie, normal or THP) so it would be more cleaner to introduce put_swap_page which is a counter function of get_swap_page. Then, it calls right swap slot free function depending on page's size. [ying.huang@intel.com: minor cleanup and fix] Link: http://lkml.kernel.org/r/20170515112522.32457-3-ying.huang@intel.com Signed-off-by: Minchan Kim <minchan@kernel.org> Signed-off-by: "Huang, Ying" <ying.huang@intel.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Ebru Akagunduz <ebru.akagunduz@gmail.com> Cc: Hugh Dickins <hughd@google.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Michal Hocko <mhocko@kernel.org> Cc: Rik van Riel <riel@redhat.com> Cc: Shaohua Li <shli@kernel.org> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
38d8b4e6bd
commit
75f6d6d29a
+14
-2
@@ -1148,7 +1148,7 @@ void swap_free(swp_entry_t entry)
|
||||
/*
|
||||
* Called after dropping swapcache to decrease refcnt to swap entries.
|
||||
*/
|
||||
void swapcache_free(swp_entry_t entry)
|
||||
static void swapcache_free(swp_entry_t entry)
|
||||
{
|
||||
struct swap_info_struct *p;
|
||||
|
||||
@@ -1160,7 +1160,7 @@ void swapcache_free(swp_entry_t entry)
|
||||
}
|
||||
|
||||
#ifdef CONFIG_THP_SWAP
|
||||
void swapcache_free_cluster(swp_entry_t entry)
|
||||
static void swapcache_free_cluster(swp_entry_t entry)
|
||||
{
|
||||
unsigned long offset = swp_offset(entry);
|
||||
unsigned long idx = offset / SWAPFILE_CLUSTER;
|
||||
@@ -1184,8 +1184,20 @@ void swapcache_free_cluster(swp_entry_t entry)
|
||||
swap_free_cluster(si, idx);
|
||||
spin_unlock(&si->lock);
|
||||
}
|
||||
#else
|
||||
static inline void swapcache_free_cluster(swp_entry_t entry)
|
||||
{
|
||||
}
|
||||
#endif /* CONFIG_THP_SWAP */
|
||||
|
||||
void put_swap_page(struct page *page, swp_entry_t entry)
|
||||
{
|
||||
if (!PageTransHuge(page))
|
||||
swapcache_free(entry);
|
||||
else
|
||||
swapcache_free_cluster(entry);
|
||||
}
|
||||
|
||||
void swapcache_free_entries(swp_entry_t *entries, int n)
|
||||
{
|
||||
struct swap_info_struct *p, *prev;
|
||||
|
||||
Reference in New Issue
Block a user