Swap usage discussion
Ed Skinner
plug-devel@lists.PLUG.phoenix.az.us
Fri Jun 18 11:29:02 2004
On Friday 18 June 2004 09:42, Alan Dayley wrote, in part:
> ... The book I am
> using as a code guide, "Understanding the Linux Virtual Memory Manager"
> explains it like this:
>
> "Linux actually implements paging as modern hardware supports it, but
> traditionally has called it swapping in discussions and documentation. To
> be consistent with the Linux usage of the word, we, too, will refer to it
> as swapping." p. 179
>
> In fact, the kernel source code function names mostly have the word "swap"
> in them when they do in fact implement paging operations. Thank you for
> the pointer and definition.
Briefly looking at a 2.6.4 source tree, I don't see the old situation
where Linux would truly "swap" out an entire process. Unless the code has
moved elsewhere (and words such as "entire", "complete" and "whole" aren't
used in the comments), it would appear Linux doesn't do that anymore.
"Paging" appears to be the only thing going on and, as you note, they use the
word "swap" to refer to that. What I said previously needs to be amended in
this regard.
If you're looking at the sources, oom_kill.c and out_of_memory() have
intrigued me for some time. The nitty-gritty details are interesting but they
also demonstrate a very basic assumption that, at least some, developers
should be aware of. And that is that under certain circumstances, Linux
considers itself (the kernel) more important than the application programs
(with some qualifications you can read about in this particular source file).
The sources indirectly show how to avoid having your process killed off, and
the configuration even allows this "feature" to be disabled, but if
developers don't know this feature is present, then ... ... ...
Do you like that O'Reilly book? The VM area in Linux is one of the
kernel's most challenging aspects (IMHO) and I have yet to find one book that
really does a good job of presenting it clearly. I've always suspected that
the other authors I've read either A) don't really understand it, or B) can't
communicate what they "grok". And I'm certainly not claiming to understand
it, either. I just find it a fascinating area and have learned a little here
and there. (And, yes, I certainly *do* illustrate the adage that a little
knowledge can be dangerous.)
Hope you enjoy Linux as much as I do!
--
Ed Skinner, ed@flat5.net, http://www.flat5.net/