linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Raymond Jennings <shentino@gmail.com>
Cc: Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: Swap defragging
Date: Thu, 7 Mar 2013 21:35:11 -0500	[thread overview]
Message-ID: <20130308023511.GD23767@cmpxchg.org> (raw)
In-Reply-To: <CAGDaZ_rvfrBVCKMuEdPcSod684xwbUf9Aj4nbas4_vcG3V9yfg@mail.gmail.com>

On Thu, Mar 07, 2013 at 06:07:23PM -0800, Raymond Jennings wrote:
> Just a two cent question, but is there any merit to having the kernel
> defragment swap space?

That is a good question.

Swap does fragment quite a bit, and there are several reasons for
that.

We swap pages in our LRU list order, but this list is sorted by first
access, not by access frequency (not quite that cookie cutter, but the
ordering is certainly fairly coarse).  This means that the pages may
already be in suboptimal order for swap in at the time of swap out.

Once written to disk, the layout tends to stick.  One reason is that
we actually try to not free swap slots unless there is a shortage of
swap space to save future swap out IO (grep for vm_swap_full()).  The
other reason is that if a page shared among multiple threads is
swapped out, it can not be removed from swap until all threads have
faulted the page back in because of page table entries still referring
to the swap slot on disk.  In a multi-threaded application, this is
rather unlikely.

So even though the referencing order of the application might change,
the disk layout won't.  But adjusting the disk layout speculatively
increases disk IO, so it could be hard to prove that you came up with
a net improvement.

--
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:[~2013-03-08  2:35 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-08  2:07 Raymond Jennings
2013-03-08  2:35 ` Johannes Weiner [this message]
2013-03-08  3:01   ` Raymond Jennings
2013-03-09  2:00   ` Will Huck
2013-03-12 16:52     ` Johannes Weiner
2013-03-13  0:46       ` Will Huck
2013-03-13  1:31       ` Will Huck
2013-03-11  2:54   ` Ric Mason
2013-03-12 16:53     ` Johannes Weiner
2013-03-11  3:11   ` Simon Jeons
2013-03-12 17:03     ` Johannes Weiner
2013-03-11  3:16   ` Jaegeuk Hanse
2013-03-12 17:08     ` Johannes Weiner
2013-03-13  3:47       ` Jaegeuk Hanse
2013-03-11  6:24   ` Will Huck

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=20130308023511.GD23767@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=linux-mm@kvack.org \
    --cc=shentino@gmail.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