login
Header Space

 
 

[13/14] vcompound: Use vcompound for swap_map

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-mm@...>
Cc: <linux-kernel@...>
Date: Friday, March 21, 2008 - 2:17 am

Use virtual compound pages for the large swap maps. This only works for
swap maps that are smaller than a MAX_ORDER block though. If the swap map
is larger then there is no way around the use of vmalloc.

Signed-off-by: Christoph Lameter <clameter@sgi.com>

---
 mm/swapfile.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: linux-2.6.25-rc5-mm1/mm/swapfile.c
===================================================================
--- linux-2.6.25-rc5-mm1.orig/mm/swapfile.c	2008-03-20 20:32:12.793950570 -0700
+++ linux-2.6.25-rc5-mm1/mm/swapfile.c	2008-03-20 20:37:43.367821147 -0700
@@ -1312,7 +1312,7 @@ asmlinkage long sys_swapoff(const char _
 	p->flags = 0;
 	spin_unlock(&swap_lock);
 	mutex_unlock(&swapon_mutex);
-	vfree(swap_map);
+	__free_vcompound(swap_map);
 	inode = mapping->host;
 	if (S_ISBLK(inode->i_mode)) {
 		struct block_device *bdev = I_BDEV(inode);
@@ -1636,13 +1636,13 @@ asmlinkage long sys_swapon(const char __
 			goto bad_swap;
 
 		/* OK, set up the swap map and apply the bad block list */
-		if (!(p->swap_map = vmalloc(maxpages * sizeof(short)))) {
+		if (!(p->swap_map = __alloc_vcompound(GFP_KERNEL | __GFP_ZERO,
+					get_order(maxpages * sizeof(short))))) {
 			error = -ENOMEM;
 			goto bad_swap;
 		}
 
 		error = 0;
-		memset(p->swap_map, 0, maxpages * sizeof(short));
 		for (i = 0; i < swap_header->info.nr_badpages; i++) {
 			int page_nr = swap_header->info.badpages[i];
 			if (page_nr <= 0 || page_nr >= swap_header->info.last_page)
@@ -1718,7 +1718,7 @@ bad_swap_2:
 	if (!(swap_flags & SWAP_FLAG_PREFER))
 		++least_priority;
 	spin_unlock(&swap_lock);
-	vfree(swap_map);
+	__free_vcompound(swap_map);
 	if (swap_file)
 		filp_close(swap_file, NULL);
 out:

-- 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[13/14] vcompound: Use vcompound for swap_map, Christoph Lameter, (Fri Mar 21, 2:17 am)
Re: [13/14] vcompound: Use vcompound for swap_map, Andi Kleen, (Fri Mar 21, 5:25 pm)
Re: [13/14] vcompound: Use vcompound for swap_map, Christoph Lameter, (Mon Mar 24, 3:54 pm)
Re: [13/14] vcompound: Use vcompound for swap_map, Andi Kleen, (Tue Mar 25, 3:52 am)
Re: [13/14] vcompound: Use vcompound for swap_map, Christoph Lameter, (Tue Mar 25, 1:45 pm)
Re: [13/14] vcompound: Use vcompound for swap_map, Andi Kleen, (Tue Mar 25, 1:55 pm)
Re: [13/14] vcompound: Use vcompound for swap_map, Christoph Lameter, (Tue Mar 25, 1:51 pm)
Re: [13/14] vcompound: Use vcompound for swap_map, Christoph Lameter, (Fri Mar 21, 5:33 pm)
speck-geostationary