Re: Kswapd flaw

From: Nix
Date: Tue Jun 28 2005 - 11:29:00 EST


On Tue, 28 Jun 2005, Al Boldi murmured woefully:
> Nix wrote:{
> I don't think so, except on a process-by-process basis via mlockall().
> (/proc/sys/vm/swappiness lets you say that swapping is more or less
> desirable, but under enough memory pressure paging *will* happen regardless
> of the value of that variable.)
>
> But I'm mystified as to why you might want to suppress paging. The only
> effect of suppressing it is to reduce the amount of memory you can allocate
> before you run completely out and start killing things.
> }
>
> Nix,
> You start killing things because you overcommitted, when you were not
> supposed to fault in the first place because you have no swap.

The only thing that is blocked by having no swap is swapping. The only
things that go to swap are things that can't go anywhere else (because
swap is comparatievly slow). As far as I know, the only things that land
in swap are modified private writable file-backed mappings
(e.g. relocations in text sections of programs), and allocated anonymous
mappings (what most people think of as `data'). (Data allocated via
brk() is of the latter type.)

So if swap is turned off, the kernel can still acquire more memory when
short by discarding file-backed pages from the page cache --- this
includes non-modified text pages of programs and modified non-private
file mappings, as well as data read/written via read() and write().

That is, with no swapfile, the kernel can't swap. It can still *page*,
pushing stuff out to files if modified, throwing them out of memory if
not, and reloading them from their original file when needed.

> ( I couldn't find /proc/sys/vm/swappiness in 2.4, although I heard about it
> in 2.6.)

Yeah, it's a 2.6 thing.

--
`I lost interest in "blade servers" when I found they didn't throw knives
at people who weren't supposed to be in your machine room.'
--- Anthony de Boer
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/