All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rik van Riel <riel@surriel.com>
To: Hugh Dickins <hughd@google.com>, Kelley Nielsen <kelleynnn@gmail.com>
Cc: akpm@linux-foundation.org, gnomes@lxorguk.ukuu.org.uk,
	josh@joshtriplett.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, opw-kernel@googlegroups.com,
	jamieliu@google.com, sjenning@linux.vnet.ibm.com
Subject: Re: [RFC] mm:prototype for the updated swapoff implementation
Date: Fri, 28 Feb 2014 13:07:28 -0500	[thread overview]
Message-ID: <5310D060.1090504@surriel.com> (raw)
In-Reply-To: <alpine.LSU.2.11.1402271054390.7000@eggly.anvils>

On 02/27/2014 07:33 PM, Hugh Dickins wrote:
> On Tue, 18 Feb 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.
> 
> You've chosen a good target, and I like the look of what you've done.
> But I'm afraid it will have to get uglier before it's ready, and I'm
> unsure whether your approach will prove to be a clear win or not.

I am more optimistic than you, because I have seen swapoff
on my Nehalem system proceed at under 1MB/s for several hours,
to clear maybe 3-4GB of stuff out of swap :)

>> 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
>>
>> swapoff was called on a swap partition containing about 50M of data,
>> and calls to the function unuse_pte_range were counted.
>>
>> Present implementation....about 22.5M calls.
>> Prototype.................about  7.0K   calls.
> 
> That's nice, but mostly it's the time spent that matters.
> 
> I should explain why we've left the try_to_unuse() implementation as is
> for so many years: it's a matter of tradeoff between fast cpu and slow
> seeking disk.

> I'll be surprised if your approach does not improve swapoff from SSD
> (and brd and zram and zswap) very significantly; but the case to worry
> about is swapoff from hard disk.  You are changing swapoff to use the
> cpu much more efficiently; but now that you no longer move linearly up
> the swap_map, you are making the disk head seek around very much more.

I suspect proper read-around of the swap area should take care of
IO patterns well enough. The quadratic nature of the current
try_to_unuse search can easily slow things down to comically low
speeds...

-- 
All rights reversed.

--
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>

WARNING: multiple messages have this Message-ID (diff)
From: Rik van Riel <riel@surriel.com>
To: Hugh Dickins <hughd@google.com>, Kelley Nielsen <kelleynnn@gmail.com>
Cc: akpm@linux-foundation.org, gnomes@lxorguk.ukuu.org.uk,
	josh@joshtriplett.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, opw-kernel@googlegroups.com,
	jamieliu@google.com, sjenning@linux.vnet.ibm.com
Subject: Re: [RFC] mm:prototype for the updated swapoff implementation
Date: Fri, 28 Feb 2014 13:07:28 -0500	[thread overview]
Message-ID: <5310D060.1090504@surriel.com> (raw)
In-Reply-To: <alpine.LSU.2.11.1402271054390.7000@eggly.anvils>

On 02/27/2014 07:33 PM, Hugh Dickins wrote:
> On Tue, 18 Feb 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.
> 
> You've chosen a good target, and I like the look of what you've done.
> But I'm afraid it will have to get uglier before it's ready, and I'm
> unsure whether your approach will prove to be a clear win or not.

I am more optimistic than you, because I have seen swapoff
on my Nehalem system proceed at under 1MB/s for several hours,
to clear maybe 3-4GB of stuff out of swap :)

>> 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
>>
>> swapoff was called on a swap partition containing about 50M of data,
>> and calls to the function unuse_pte_range were counted.
>>
>> Present implementation....about 22.5M calls.
>> Prototype.................about  7.0K   calls.
> 
> That's nice, but mostly it's the time spent that matters.
> 
> I should explain why we've left the try_to_unuse() implementation as is
> for so many years: it's a matter of tradeoff between fast cpu and slow
> seeking disk.

> I'll be surprised if your approach does not improve swapoff from SSD
> (and brd and zram and zswap) very significantly; but the case to worry
> about is swapoff from hard disk.  You are changing swapoff to use the
> cpu much more efficiently; but now that you no longer move linearly up
> the swap_map, you are making the disk head seek around very much more.

I suspect proper read-around of the swap area should take care of
IO patterns well enough. The quadratic nature of the current
try_to_unuse search can easily slow things down to comically low
speeds...

-- 
All rights reversed.

  reply	other threads:[~2014-02-28 18:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-19  0:35 [RFC] mm:prototype for the updated swapoff implementation Kelley Nielsen
2014-02-19  0:35 ` Kelley Nielsen
2014-02-19 21:27 ` Andrew Morton
2014-02-19 21:27   ` Andrew Morton
2014-02-19 21:39   ` Rik van Riel
2014-02-19 21:39     ` Rik van Riel
2014-02-19 23:08     ` [OPW kernel] " Josh Triplett
2014-02-19 23:08       ` Josh Triplett
2014-02-19 23:42   ` One Thousand Gnomes
2014-02-19 23:42     ` One Thousand Gnomes
2014-02-25 20:14 ` Rik van Riel
2014-02-25 20:14   ` Rik van Riel
2014-02-28  0:33 ` Hugh Dickins
2014-02-28  0:33   ` Hugh Dickins
2014-02-28 18:07   ` Rik van Riel [this message]
2014-02-28 18:07     ` Rik van Riel

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=5310D060.1090504@surriel.com \
    --to=riel@surriel.com \
    --cc=akpm@linux-foundation.org \
    --cc=gnomes@lxorguk.ukuu.org.uk \
    --cc=hughd@google.com \
    --cc=jamieliu@google.com \
    --cc=josh@joshtriplett.org \
    --cc=kelleynnn@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=opw-kernel@googlegroups.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.