diff options
author | Tim Chen <tim.c.chen@linux.intel.com> | 2017-02-22 18:45:43 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-02-22 19:41:30 -0500 |
commit | 039939a65059852242c823ece685579370bc574f (patch) | |
tree | 8a708bb7fbca5552aad3f43032b3ff65ae62b28c /mm/swapfile.c | |
parent | 67afa38e012e9581b9b42f2a41dfc56b1280794d (diff) |
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.com
Signed-off-by: Tim 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r-- | mm/swapfile.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c index 30a90fd140b7..2cac12cc9abe 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c | |||
@@ -2190,6 +2190,8 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) | |||
2190 | spin_unlock(&p->lock); | 2190 | spin_unlock(&p->lock); |
2191 | spin_unlock(&swap_lock); | 2191 | spin_unlock(&swap_lock); |
2192 | 2192 | ||
2193 | disable_swap_slots_cache_lock(); | ||
2194 | |||
2193 | set_current_oom_origin(); | 2195 | set_current_oom_origin(); |
2194 | err = try_to_unuse(p->type, false, 0); /* force unuse all pages */ | 2196 | err = try_to_unuse(p->type, false, 0); /* force unuse all pages */ |
2195 | clear_current_oom_origin(); | 2197 | clear_current_oom_origin(); |
@@ -2197,9 +2199,12 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) | |||
2197 | if (err) { | 2199 | if (err) { |
2198 | /* re-insert swap space back into swap_list */ | 2200 | /* re-insert swap space back into swap_list */ |
2199 | reinsert_swap_info(p); | 2201 | reinsert_swap_info(p); |
2202 | reenable_swap_slots_cache_unlock(); | ||
2200 | goto out_dput; | 2203 | goto out_dput; |
2201 | } | 2204 | } |
2202 | 2205 | ||
2206 | reenable_swap_slots_cache_unlock(); | ||
2207 | |||
2203 | flush_work(&p->discard_work); | 2208 | flush_work(&p->discard_work); |
2204 | 2209 | ||
2205 | destroy_swap_extents(p); | 2210 | destroy_swap_extents(p); |
@@ -2886,6 +2891,8 @@ out: | |||
2886 | putname(name); | 2891 | putname(name); |
2887 | if (inode && S_ISREG(inode->i_mode)) | 2892 | if (inode && S_ISREG(inode->i_mode)) |
2888 | inode_unlock(inode); | 2893 | inode_unlock(inode); |
2894 | if (!error) | ||
2895 | enable_swap_slots_cache(); | ||
2889 | return error; | 2896 | return error; |
2890 | } | 2897 | } |
2891 | 2898 | ||