linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* cache/swap issues under 2.4.1, 2.4.2
@ 2001-02-26  8:37 Mordechai T. Abzug
  2001-02-26 16:42 ` Marcelo Tosatti
  0 siblings, 1 reply; 2+ messages in thread
From: Mordechai T. Abzug @ 2001-02-26  8:37 UTC (permalink / raw)
  To: linux-kernel


I've been noticing some weird cache/swap behavior under 2.4.1 and
2.4.2.  If there is a large amount of allocated cache space, a program
requests a lot of RAM, and then the program exits, then one can end up
using lots of swap while having a hefty cache, which doesn't make much
sense.  Here is a sample run: ("allocram N" is a trivial program to
allocate and dirty N MB of RAM.)

# free
             total       used       free     shared    buffers     cached
Mem:        255564      49344     206220          0        420       5496
-/+ buffers/cache:      43428     212136
Swap:       163832          0     163832

# find / -type f|xargs cat > /dev/null

# free
             total       used       free     shared    buffers     cached
Mem:        255564     253248       2316          0       7764     189300
-/+ buffers/cache:      56184     199380
Swap:       163832          0     163832

# allocram 300 &

# free
             total       used       free     shared    buffers     cached
Mem:        255564     254004       1560          0        316      32764
-/+ buffers/cache:     220924      34640
Swap:       163832     130172      33660

# [1]+  Done                    allocram 300

# free
             total       used       free     shared    buffers     cached
Mem:        255564      65508     190056          0        400      39852
-/+ buffers/cache:      25256     230308
Swap:       163832      48444     115388


Why do I have 47MB of swap in use?  I thought at first that it might
be due to the minimum allowable cache size, but considering that there
was only 48MB of RAM in use to begin with, that still seems
suspicious.  Even weirder, if I then turn off swap, the usage looks
more reasonable:

# swapoff -a

# free
             total       used       free     shared    buffers     cached
Mem:        255564      53900     201664          0        840       9356
-/+ buffers/cache:      43704     211860
Swap:            0          0          0

This system is an Athlon T-bird 900 on a Asus A7V (KTX-133-based)
motherboard, if that matters.  I don't have any other 2.4.x systems to
try it on.  NB: X 4.0.1 with tdfx freezes for a few seconds during the
swapoff -a process, but it does recover.

- Morty

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: cache/swap issues under 2.4.1, 2.4.2
  2001-02-26  8:37 cache/swap issues under 2.4.1, 2.4.2 Mordechai T. Abzug
@ 2001-02-26 16:42 ` Marcelo Tosatti
  0 siblings, 0 replies; 2+ messages in thread
From: Marcelo Tosatti @ 2001-02-26 16:42 UTC (permalink / raw)
  To: Mordechai T. Abzug; +Cc: lkml


On Mon, 26 Feb 2001, Mordechai T. Abzug wrote:

> Why do I have 47MB of swap in use?  I thought at first that it might
> be due to the minimum allowable cache size, but considering that there
> was only 48MB of RAM in use to begin with, that still seems
> suspicious.  Even weirder, if I then turn off swap, the usage looks
> more reasonable:
> 
> # swapoff -a
> 
> # free
>              total       used       free     shared    buffers     cached
> Mem:        255564      53900     201664          0        840       9356
> -/+ buffers/cache:      43704     211860
> Swap:            0          0          0

The "used" swap space here means _allocated_ swap space, not necessarily
used swap space. 

Linux 2.4 allocate's swap space for an anonymous page when it unmaps a
page table entry mapping the page. When it allocates the swap space, it
also adds the page to the swapcache to be written later. 

The swapcache is part of the pagecache. The swapoff rips all the
swapcached pages on the device, thats why you see a lot less memory
"cached" after the swapoff. 






^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-02-26 18:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-26  8:37 cache/swap issues under 2.4.1, 2.4.2 Mordechai T. Abzug
2001-02-26 16:42 ` Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).