All of lore.kernel.org
 help / color / mirror / Atom feed
From: michi1@michaelblizek.twilightparadox.com (michi1 at michaelblizek.twilightparadox.com)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Why would some process swap in place of reclaiming free(cached) memory
Date: Wed, 20 Feb 2013 17:31:33 +0100	[thread overview]
Message-ID: <20130220163132.GA2220@grml> (raw)
In-Reply-To: <CAHbM+PP_fomB2KKhmdU0Bp5=CdPP307pNYMLhpkDN7oMkhSzHg@mail.gmail.com>

Hi!

On 20:31 Wed 20 Feb     , Soham Chakraborty wrote:
> Hi all,
> 
> I posted this question in linux-mm list as well but it didn't spawn much
> interest. So, I am putting the same question here also. Would love if
> someone can put some traction.
> 
> The question is salivating and simple. When we have free and lotsa cached
> memory in a system (irrespective of distro and kernel), why would some
> process end up in swap space,

Freeing cache memory does not need to be faster than swapping. The cached
files might be accessed more often than memory of some process. It is a
hard balancing act.

> I understand the overcommit mode of vm, the
> default value of 0 and what it does. I also know that the cache might be
> dirty and we don't might not want to allocate free pages thinking that we
> might go under the watermark of low. But, I mainly end up getting this
> question from end users - why would things swap if I have free memory.

I think this might indeed make sense in some cases. If there is lots of
memory used which is never accessed, it could be swapped out early. This
would prevent write activity if memory gets tight later. Also note that there
is a entry "SwapCached" in /proc/meminfo. It might be possible that the pages
swapped out pages are present in both swap *and* memory. Just a possibility...

> I
> guess, technically we can't stop swapping even if we set vm.swappiness to 0
> but well, I think I have said what I need to said. If you need data, I can
> provide those.

Swapping can be prevented.
1) You can disable all swap space in the system
2) Alternatively, you can call mlock() if you only care about few processes.

> ...

	-Michi
-- 
programing a layer 3+4 network protocol for mesh networks
see http://michaelblizek.twilightparadox.com

  reply	other threads:[~2013-02-20 16:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-20 15:01 Why would some process swap in place of reclaiming free(cached) memory Soham Chakraborty
2013-02-20 16:31 ` michi1 at michaelblizek.twilightparadox.com [this message]
2013-02-20 19:43 ` Greg Freemyer
2013-02-21  5:15   ` Mandeep Sandhu
2013-02-21  5:19     ` Soham Chakraborty
2013-02-22  4:23       ` Greg Freemyer
2013-02-22  3:36 ` Mulyadi Santosa

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=20130220163132.GA2220@grml \
    --to=michi1@michaelblizek.twilightparadox.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /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.