AFAIK, the "high water mark" thing in Linux swap is because the dirty pages
in memory still haven't been written or are in use.

When a page of memory is swapped to disk, it's because that memory is in
use, and has changed from the on-disk data (or has been generated, or
whatever), it can't just be dropped when another program calls malloc(), so
it's written to disk so that when it's needed again, it can be pulled back
into physical memory. When it's pulled back into physical memory, it stays
on the disk, because if that memory needs swapped out again, instead of
re-caching it, it'll just drop it. Remember, it was already in the disk
cache.

Is that memory "in use"? Well, sort of. A /copy/ of that memory is probably
in use, but the cache is keeping a copy until the page in physical memory
isn't used or is changed from the on-disk version.

You can clear it once it goes high by doing a swapoff/swapon (when you've
freed up some physical memory, of course), but the "real" answer is that
the memory being "used" by cache isn't doing anything to anyone. If someone
is trying to calculate something important by using the numbers reported by
free, then they probably should find another, more reliable way of doing
it.

--Matt




On Mon, Aug 27, 2012 at 1:28 PM, Andrew Hume <and...@research.att.com>wrote:

> err, that is the whole point.
> SwapTotal - SwapFree reflects the high water mark problem.
> for example, if we are swapping, and process P1 has 20GB of swap,
> then SwapTotal - SwapFree = 20GB. if i start a new process P2 which uses
> 3GB swap, then SwapTotal - SwapFree = 23GB. Great!
> process P1 now exits. so only 3GB of swap are actually being used,
> and yet SwapTotal - SwapFree = 23GB (still!).
>
> if process P2 now exits, then SwapTotal-SwapFree goes back to 0.
>
> what i would call the real problem is that
>
> SwapTotal != SwapFree + (swap actually being used)
>
> andrew
>
> On Aug 27, 2012, at 7:32 AM, Dan Ritter wrote:
>
> On Mon, Aug 27, 2012 at 06:49:28AM -0700, Andrew Hume wrote:
>
> i have some colleagues who are being frustrated by the stupid way
>
> Linux measures swap space consumption (the high water mark
>
> of currently running processes).
>
>
> does anyone know of a way to measure how much swap space is actually being
> used?
>
>
> In /proc/meminfo, SwapTotal - SwapFree isn't appropriate for you?
>
> -dsr-
>
>
>
> ------------------
> Andrew Hume  (best -> Telework) +1 623-551-2845
> and...@research.att.com  (Work) +1 973-236-2014
> AT&T Labs - Research; member of USENIX and LOPSA
>
>
>
>
>
> _______________________________________________
> Tech mailing list
> Tech@lists.lopsa.org
> https://lists.lopsa.org/cgi-bin/mailman/listinfo/tech
> This list provided by the League of Professional System Administrators
>  http://lopsa.org/
>
>


-- 
LITTLE GIRL: But which cookie will you eat FIRST?
COOKIE MONSTER: Me think you have misconception of cookie-eating process.
_______________________________________________
Tech mailing list
Tech@lists.lopsa.org
https://lists.lopsa.org/cgi-bin/mailman/listinfo/tech
This list provided by the League of Professional System Administrators
 http://lopsa.org/

Reply via email to