linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: Kelley Nielsen <kelleynnn@gmail.com>
Cc: linux-mm@kvack.org, riel@surriel.com, riel@redhat.com,
	opw-kernel@googlegroups.com, hughd@google.com,
	akpm@linux-foundation.org, jamieliu@google.com,
	sjenning@linux.vnet.ibm.com, sarah.a.sharp@intel.com
Subject: Re: [RFC v4] mm: prototype: rid swapoff of quadratic complexity
Date: Sun, 23 Mar 2014 12:32:03 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LSU.2.11.1403231218530.22062@eggly.anvils> (raw)
In-Reply-To: <20140321194141.GA14361@kelleynnn-virtual-machine>

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@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

       reply	other threads:[~2014-03-23 19:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20140321194141.GA14361@kelleynnn-virtual-machine>
2014-03-23 19:32 ` Hugh Dickins [this message]
2014-03-21 19:49 Kelley Nielsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LSU.2.11.1403231218530.22062@eggly.anvils \
    --to=hughd@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=jamieliu@google.com \
    --cc=kelleynnn@gmail.com \
    --cc=linux-mm@kvack.org \
    --cc=opw-kernel@googlegroups.com \
    --cc=riel@redhat.com \
    --cc=riel@surriel.com \
    --cc=sarah.a.sharp@intel.com \
    --cc=sjenning@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox