Download your favorite Linux distribution at LQ ISO.
Go Back > Blogs > Musings on technology, philosophy, and life in the corporate world
User Name


Hi. I'm a Unix Administrator, mathematics enthusiast, and amateur philosopher. This is where I rant about that which upsets me, laugh about that which amuses me, and jabber about that which holds my interest most: Unix.
Rate this Entry

Paging? Swapping? Which is it?

Posted 04-15-2013 at 12:52 PM by rocket357

It's a bit big to be called a "one-liner", but this "script" will give you a short overview of paging levels vs. swapping levels on your machine.

Set T=<seconds> to whatever timeframe you want to test for.

T=5; ( vmstat -s; sleep $T; vmstat -s ) | awk -v T="$T" -F'[(/)]' '/pages paged in/{ pgpio=pgpin; pgpin=$1 } /pages paged out/{ pgpoo=pgpon; pgpon=$1 } /pages swapped in/{ pgsio=pgsin; pgsin=$1 } /pages swapped out/{ pgsoo=pgson; pgson=$1 } END { printf "== Current %i second intervals ==\nPaged in:    %6.0f = %6.3f KB/s\nPaged out:   %6.0f = %6.3f KB/s\nSwapped in:  %6.0f = %6.3f KB/s\nSwapped out: %6.0f = %6.3f KB/s\n", T, pgpin-pgpio, ((pgpin-pgpio)*4)/T, pgpon-pgpoo, ((pgpon-pgpoo)*4)/T, pgsin-pgsio, ((pgsin-pgsio)*4)/T, pgson-pgsoo, ((pgson-pgsoo)*4)/T}';
Demand Paging:

"Shuffling" individual pages around (i.e. reading another block of code in from the executable file stored on disk, or flushing dirty pages back to disk). Could also occur if a page in the filesystem cache is "paged" in to a process's address space.


Moving infrequently used pages out to the swap area or recalling them back in from the swap area when they are needed.
Posted in Uncategorized
Views 912 Comments 2
« Prev     Main     Next »
Total Comments 2


  1. Old Comment
    Very handy. Thanks.
    Posted 04-15-2013 at 01:50 PM by vmccord vmccord is offline
  2. Old Comment
    You're welcome, vmccord.
    Posted 04-15-2013 at 02:10 PM by rocket357 rocket357 is offline


All times are GMT -5. The time now is 10:59 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration