Quote:>You can check this with swap -l.
Speaking of checking swap :-) ...
This is going to be long, but it illustrates a real problem (maybe it's
a bug, but I've never seen a patch described for it). I have noticed that
swap -l and swap -s never agree with each other, even after doing various
arithmetic manipulations with free memory, etc.
E.g., on a system with 128MB real memory (vmstat showing 7MB free) and
300MB swap, here's what I get:
-------------
# swap -s
total: 188352k bytes allocated + 36200k reserved = 224552k used, 165368k
available
# swap -l
swapfile dev swaplo blocks free
/dev/dsk/c0t3d0s1 32,25 8 403192 230104
/export/home/swap/swapfile - 8 204792 51328
# vmstat 2
procs memory page disk faults cpu
r b w swap free re mf pi po fr de sr s1 s1 s1 s1 in sy cs us sy id
[...]
0 0 0 165348 7220 0 0 92 0 12 0 9 0 78 0 0 574 431 207 8 10 82
-------------
swap -s has to be including some real memory, otherwise it couldn't get to
225+165=390MB total "swap". And so must vmstat, top, and proctool, which
all agree with the 165MB free swap, and all purport to show 7MB free memory
separately as well. On the other hand, 300+128 > 390, so it can't be
including all memory, either. Why isn't swap -s consistent about counting
real memory in its figures?
By contrast, swap -l thinks there is only 140MB free swap (it consistently
reports lower numbers than swap -s). If I take the amount used that swap -l
suggests (300-140=160MB), and add it to the 165MB "free" from vmstat, I get
325MB, which is more swap than there actually is. Even if I first subtract
the supposed 7MB free memory from the 165 number (in case it means "free
virtual", not "free swap"), it still comes out to 318.
So which, if any, of these numbers are right? Is there another 18MB free
memory that vmstat and friends aren't reporting? Or another 38MB (428-390)?
Or ~64MB total (the 225 used that swap -s reports, minus the 160 used that
swap -l claims, subtracted from 128MB total memory)?
No contortions, logical or otherwise :-), that I can think of make these
numbers add up. It would be annoying enough to go through this if they did,
but they never do. How much of this can be trusted, and is there any way
to get the true story? I'd really appreciate knowing; I have a few users
who would like to see how they're using their system, and telling them
"well this kind of gives you an idea but don't trust it completely" just
doesn't cut it.
Thank you, and apologies for the long article!
--
Ruth Milner NRAO Socorro NM