mm/swap: Enable swap slots cache usage
Subsystems (2)
PATCH 8/8 mm/swap: Enable swap slots cache usage
Initialize swap slots cache and enable it on swap on. Drain swap slots on swap off.
Signed-off-by Tim Chen <[email protected]>
--- mm/swapfile.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
mm/swapfile.c +6 -1
@@ -2132,7 +2132,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)struct address_space *mapping;struct inode *inode;struct filename *pathname; -int err, found =0 ; +int err, found =0 , has_swap =0 ;unsigned int old_block_size;if (!capable (CAP_SYS_ADMIN ))
@@ -2144,6 +2144,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)if (IS_ERR (pathname))return PTR_ERR (pathname); +disable_swap_slots_cache (); victim =file_open_name (pathname,O_RDWR |O_LARGEFILE ,0 ); err =PTR_ERR (victim);if (IS_ERR (victim))
@@ -2152,6 +2153,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) mapping = victim->f_mapping;spin_lock (&swap_lock);plist_for_each_entry (p, &swap_active_head, list) { + has_swap =1 ;if (p->flags &SWP_WRITEOK ) {if (p->swap_file->f_mapping == mapping) { found =1 ;
@@ -2275,6 +2277,8 @@ out_dput:filp_close (victim,NULL ); out:putname (pathname); +if (has_swap) +reenable_swap_slots_cache ();return err; }
@@ -2692,6 +2696,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)if (!capable (CAP_SYS_ADMIN ))return -EPERM ; +init_swap_slot_caches (); p =alloc_swap_info ();if (IS_ERR (p))return PTR_ERR (p);
Signature · 7 lines
2.5.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>