topics that matter; ideas worth sharing

share a tip, submit a link, add something new

Clearing up swap space confusion

May 7, 2001, 10:40 AM —  Unix Insider — 

Q: The swap space numbers reported by swap -s and swap -l and sar and vmstat don't add up. Why not?


A: When I tried to summarize the way that swap space works for the
second edition of my book, I discovered that I didn't really
understand it myself. After looking back through my April 1996
Performance Q&A column, "How does swap space work?"
and reading Inside Solaris columnist Jim Mauro's two-part look at swap space implementation, I decided that Jim didn't quite have the full picture either. After many hours of deep detective work I figured it all out, and discovered some minor bugs in the tools that had us both confused.


Since then I've seen this question many times. The answer is too
complex to include in an e-mail, so I've decided to base this month's column
on a section of my book. In the future, I'll be able to point readers with
swap-space queries in the direction of this column.


For all practical purposes, the swapping out of entire processes can be
ignored in Solaris 2, which no longer implements the time-based soft
swap-outs that occur in SunOS 4. vmstat -s reports total
numbers of swap-ins and swap-outs, and they're almost always zero.
It is important to note that prolonged memory shortages can trigger
swap-outs of inactive processes. Swapping out idle processes helps the
performance of machines with less than 32 megabytes (MB) of RAM.
The number of idle swapped-out processes is reported as the
swap queue length by vmstat. This measurement is not explained properly
in the manual page, since that measure used to be the number of active
swapped-out processes waiting to be swapped back in. As soon as a
swapped-out process wakes up again, it will swap its basic data
structures back into the kernel, and page in its code and data as
they are accessed. This activity requires so little memory that it
can always happen immediately.


Code Example 1


%vmstat 5
 procs     memory            page            disk          faults      cpu
 r b w   swap  free  re  mf pi po fr de sr f0 s0 s1 s5   in   sy   cs us sy id
...
 0 0 4 314064  5728   0   7  2  1  1  0  0  0 177 91 22 132  514   94  1  0 98


If you come across a system with a non-zero swap queue reported by
vmstat, take it as a sign that at some time in the past, free memory
went low for long enough to trigger the swapping out of idle
processes. This is the only useful conclusion you can draw from such a
measure.


Swap space operations

Swap space is really a misnomer for paging space.
Almost all accesses are page

I like it!
Post a comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
Resources
White Paper

Symantec Backup Exec 12 and Backup Exec System Recovery 8 deliver industry leading Windows data protection and system recovery. Download this whitepaper to find out the top reasons to upgrade and how to get continuous data protection and complete system recovery.

Webcast

Data and system loss — from a hard drive failure, malicious attack, natural disaster, or simple human error — can happen anytime. Don’t leave your business vulnerable. Make sure you have a secure recovery strategy in place. Symantec's latest backup and system recovery technology can efficiently restore critical applications, individual emails and documents and even restore your entire system in minutes in the event of a loss.

White Paper

Businesses face a growing challenge to ensure that the IT environment is properly protected. Backup Exec 12 integrates with other applications in the Symantec family of products, to complement your current data protection strategy, keep your data securely backed up and make it recoverable when you need it most.

Free stuff
Featured Sponsor

Get a broad understanding of important regulations and how you can make sure your site is in adherence.





Learn how VeriSign SGC-enabled SSL Certificates can help improve site security and customer confidence in the free white paper, "How to Offer the Strongest SSL Encryption." In this paper you will learn the differences between weak and strong encryption and what they mean for your site's performance.

Get VeriSign's free white paper: "The Latest Advancements in SSL Technology" and learn about the benefits of strong SSL encryption, Extended Validation (EV) SSL and security trust marks and what these SSL offerings can do for your site.

Now with Extended Validation (EV) SSL available from VeriSign, you can show your customers that they can trust your site. Learn about EV SSL benefits in this free VeriSign white paper.

More Resources