Commit 039939a6 authored by Tim Chen's avatar Tim Chen Committed by Linus Torvalds

mm/swap: enable swap slots cache usage

Initialize swap slots cache and enable it on swap on.  Drain all swap
slots on swap off.

Link: http://lkml.kernel.org/r/07cbc94882fa95d4ac3cfc50b8dce0b1ec231b93.1484082593.git.tim.c.chen@linux.intel.comSigned-off-by: default avatarTim Chen <tim.c.chen@linux.intel.com>
Cc: "Huang, Ying" <ying.huang@intel.com>
Cc: Aaron Lu <aaron.lu@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Hillf Danton <hillf.zj@alibaba-inc.com>
Cc: Huang Ying <ying.huang@intel.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Jonathan Corbet <corbet@lwn.net> escreveu:
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Shaohua Li <shli@kernel.org>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 67afa38e
...@@ -2190,6 +2190,8 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) ...@@ -2190,6 +2190,8 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
spin_unlock(&p->lock); spin_unlock(&p->lock);
spin_unlock(&swap_lock); spin_unlock(&swap_lock);
disable_swap_slots_cache_lock();
set_current_oom_origin(); set_current_oom_origin();
err = try_to_unuse(p->type, false, 0); /* force unuse all pages */ err = try_to_unuse(p->type, false, 0); /* force unuse all pages */
clear_current_oom_origin(); clear_current_oom_origin();
...@@ -2197,9 +2199,12 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) ...@@ -2197,9 +2199,12 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
if (err) { if (err) {
/* re-insert swap space back into swap_list */ /* re-insert swap space back into swap_list */
reinsert_swap_info(p); reinsert_swap_info(p);
reenable_swap_slots_cache_unlock();
goto out_dput; goto out_dput;
} }
reenable_swap_slots_cache_unlock();
flush_work(&p->discard_work); flush_work(&p->discard_work);
destroy_swap_extents(p); destroy_swap_extents(p);
...@@ -2886,6 +2891,8 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) ...@@ -2886,6 +2891,8 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
putname(name); putname(name);
if (inode && S_ISREG(inode->i_mode)) if (inode && S_ISREG(inode->i_mode))
inode_unlock(inode); inode_unlock(inode);
if (!error)
enable_swap_slots_cache();
return error; return error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment