Swap usage discussion

Alan Dayley plug-devel@lists.PLUG.phoenix.az.us
Thu Jun 17 08:26:02 2004


I have the need to study and understand how the kernel uses the hard disk
swap space.  The kernel in question is based on Red Hat Linux 9 which
would be version 2.4.[twenty something], I think.

I picked up the book "Understanding the Linux Virtual Memory Manager" from
PLUG and have begun to study it.  It is a documentary analysis of the
virtual memory manager in the 2.4 kernel with some discussion of the
2.6-test kernel where it differs.  It discusses at the code level with
annotated code and text describing the goals and operaton of the code.  It
is excellent information.

However, understanding the code is different than knowing how it actually
operates when running in a particular environment.  So much depends on how
much RAM, how many processes are running concurrently besides the actual
kernel, how large the swap space is, etc.

I need to characterize:
- How often data is written to the swap space.
- How large the data written is.
- How the swap space is used, ie. If are the lower LBAs of the swap area
used first.  Or, if each process uses the same block of LBAs.  Etc.

The ultimate reason for this study is to accurately as possible predict
how long a given flash media will last when used as the hard drive
containing the swap area.  I am confident that some flash media will last
an acceptably long time, into decades.  However, I must have an
intelligent argument based on hard numbers to back this up.  I know
wear-out rates for the flash media in question.  I don't know Linux swap
usage rates.

To my questions:
- What experience and "rules of thumb" are there that would answer this
question?
- What tools such as "top" and "free" can be used to analize memory, and
particularly, swap usage?
- Are there any other tips and pointers that can be provided to help my
quest?

Alan