Why would some process swap in place of reclaiming free(cached) memory

Greg Freemyer greg.freemyer at gmail.com
Wed Feb 20 14:43:09 EST 2013



Soham Chakraborty <sohamwonderpiku4u at gmail.com> 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, 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
>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.
>
>Any reference to source where it gives the condition to transfer some
>pages
>to swap, despite of having free memory, would be highly appreciated. I
>tried to find in mm/vmscan.c but didn't get much success.
>
>Soham

I am not a mm expert, but let me pose a question and let someone else answer it.

What happens to the paging counts when a large program is exec'ed.

I know the pages are kept on disk initially and then swapped in as needed/referenced.  Thus if there are code pages where none of the code in the page has been executed since starting the app, then that page will remain on disk until the application logic eventually invokes it.  At that point it will be demand loaded from disk.

During that early stage, do the never used pages show as swapped out?  If so, why would anyone want all those never used pages to be brought into ram just to sit there unused?

The end result is that that swap'ed pages represent pages available to be swapped in, but not the number of pages that were actually swapped out at some point in time.

Greg
-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.



More information about the Kernelnewbies mailing list