Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1556776

[PATCH v5 8/9] mm/swap: Enable swap slots cache usage

From Tim Chen <tim.c.chen@linux.intel.com>
Newsgroups linux.kernel
Subject [PATCH v5 8/9] mm/swap: Enable swap slots cache usage
Date 2017-01-11 19:00 +0100
Message-ID <sYvlL-1rB-17@gated-at.bofh.it> (permalink)
References <sYvlL-1rB-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
---
 mm/swapfile.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/mm/swapfile.c b/mm/swapfile.c
index e6c30ed..14d9ea2 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2181,6 +2181,8 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
 	spin_unlock(&p->lock);
 	spin_unlock(&swap_lock);
 
+	disable_swap_slots_cache_lock();
+
 	set_current_oom_origin();
 	err = try_to_unuse(p->type, false, 0); /* force unuse all pages */
 	clear_current_oom_origin();
@@ -2188,9 +2190,12 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
 	if (err) {
 		/* re-insert swap space back into swap_list */
 		reinsert_swap_info(p);
+		reenable_swap_slots_cache_unlock();
 		goto out_dput;
 	}
 
+	reenable_swap_slots_cache_unlock();
+
 	flush_work(&p->discard_work);
 
 	destroy_swap_extents(p);
@@ -2868,6 +2873,8 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
 		putname(name);
 	if (inode && S_ISREG(inode->i_mode))
 		inode_unlock(inode);
+	if (!error)
+		enable_swap_slots_cache();
 	return error;
 }
 
-- 
2.5.5

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH v5 8/9] mm/swap: Enable swap slots cache usage Tim Chen <tim.c.chen@linux.intel.com> - 2017-01-11 19:00 +0100

csiph-web