Why would some process swap in place of reclaiming free(cached) memory
Greg Freemyer
greg.freemyer at gmail.com
Thu Feb 21 23:23:30 EST 2013
On Thu, Feb 21, 2013 at 12:19 AM, Soham Chakraborty
<sohamwonderpiku4u at gmail.com> wrote:
>
>
> On Thu, Feb 21, 2013 at 10:45 AM, Mandeep Sandhu
> <mandeepsandhu.chd at gmail.com> wrote:
>>
>> > 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?
>>
>> Are you saying that pages of code segment (of an executable) which
>> have not been accessed yet, are copied onto the swap space from their
>> location on the disk when the program is exec'ed? Or do they remain on
>> disk (in their original location) and loaded into memory only when
>> accessed (and _then_ possibly swapped out)? If they remain on disk,
>> then that wouldn't show up in swap space, right?
>
>
> If the code segment of an executable which hasn't been accessed, they will
> remain on disk because they have fixed filesystem backing. Only when they
> are referenced, they will go to cache and then when inactive and/or while
> reclaiming, they will end up in disk again. But, afaik, anything which has a
> filesystem backing, a fixed storage backing, doesn't go to swap. This part
> is pretty clear to me. Only anon pages go to swap and something which is on
> disk, is not anon in first place.
Soham,
I agree with the details you describe. My question was if the pages
not in RAM, but available in filesystem backing were being included in
the count of pages swapped out that you were asking about.
Let me rephrase my answer:
Total addressable pages = Allocated RAM pages + filesystem Backing
Storage pages + pages swapped out
I don't see the filesystem backing storage pages typically included in
performance tools like top.
Therefore my question was if those userspace reporting tools use the
term swap to represent both the truely swapped out pages and the
filesystem backing storage pages.
Seems like you know the MM system better than me, so I won't argue for
or against my theory. I'll just leave it as a question.
Greg
More information about the Kernelnewbies
mailing list