Re: [RFC v4] mm: prototype: rid swapoff of quadratic complexity

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 21 Mar 2014, Kelley Nielsen wrote:

> The function try_to_unuse() is of quadratic complexity, with a lot of
> wasted effort. It unuses swap entries one by one, potentially iterating
> over all the page tables for all the processes in the system for each
> one.
> 
> This new proposed implementation of try_to_unuse simplifies its
> complexity to linear. It iterates over the system's mms once, unusing
> all the affected entries as it walks each set of page tables. It also
> makes similar changes to shmem_unuse.
> 
> Improvement
> 
> Time took by swapoff on a swap partition containing about 240M of data,
> with about 1.1G free memory and about 520M swap available. Swap
> partition was on a laptop with a hard disk drive (not SSD).
> 
> Present implementation....about 13.8s
> Prototype.................about  5.5s

I haven't studied the patch yet (and won't manage to do so in the week
ahead), nor examined its performance; but I have taken it out for a
spin, and I'm impressed by its robustness - swap being as racy as it
is, I had expected plenty of trouble, but very little - well done.

Just three little self-explanatory fixes needed so far, all down
at the out_put end: please fold in to your next version whenever.

Hugh

--- 3.14-rc7-kn/mm/swapfile.c	2014-03-22 12:22:46.420136358 -0700
+++ linux/mm/swapfile.c	2014-03-23 07:29:59.852002968 -0700
@@ -1479,12 +1479,14 @@ out_put:
 		 * that we must not delete, since it may not have been written
 		 * out to swap yet.
 		 */
+		lock_page(page);
 		if (PageSwapCache(page) &&
-		    likely(page_private(page) == entry.val)){
-			lock_page(page);
+		    likely(page_private(page) == entry.val)) {
+			wait_on_page_writeback(page);
 			delete_from_swap_cache(page);
-			unlock_page(page);
 		}
+		unlock_page(page);
+		page_cache_release(page);
 	}
 out:
 	return retval;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]