Re: [CentOS] Swap memory: I can't reconcile this stuff.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Mon, 2006-06-05 at 20:13, William L. Maltby wrote:

> > > Now, if I treat all those numbers ending in "m" as megabytes, it doesn't
> > > take long to see that I've been lied to somewhere along the way. Or
> > > alternatively, I'm dense and "Just Don't Get It" (TM).
> > 
> > Executables aren't copied into swap - virtual memory is allocated but
> > they page in on demand directly from the binary file.
> > So there really
> > are megs that could swap in if other portions of those programs are
> > executed even though it isn't in the swap partition you designated.
> 
> Just to make sure I'm following here. There are still 3 types of program
> segments: text, data and bss. Text (and data) never need to be swapped
> because they are (theoretically) never modified.  Bss may need to be
> swapped. Are you saying that what it is showing is what is potentially
> available if all swappable memory is swapped out and the "binary" is
> also discarded (maintaining only a small stack of program counters and
> other stack data)?

It's paged on demand.  Instead of thinking about memory being
swapped out, think about it never being read from disk into
memory until the memory that is supposed to hold it is accessed.

When you start executing a program you only need to load the
first block - the rest is loaded on the memory faults from
accessing uninitialized virtual memory.  Now, just to make
things more fun, remember that every shared library as well
as the main executable gets it's own text, data, and bss
segments, but every instance loaded from the same inode (so
hardlinks count) share the same real memory copy of text and
data, and fork()'d processes also start out sharing .bss in
copy-on-write mode.

> If so, it sounds in agreement with what Kai has suggested?
> 
> If that is the case, maybe there is nothing to track down? Everything is
> operating as intended and it is only that no one has bothered to make it
> perfectly clear to the user(s), like me?

It's sort of like trying to compute disk usage when you have
a lot of sparse and hard-linked files.  If you add up the
individual items it won't match the total space on the disk.
It's all done with smoke and mirrors.
-- 
  Les Mikesell
   lesmikesell@xxxxxxxxx


_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux