kernel swap accounting...

Mulyadi Santosa mulyadi.santosa at gmail.com
Tue Jan 31 10:02:15 EST 2012


Hi all

Recently I dig out my old script that count the total number of
swapped out pages. Basically, the script looks like this (sorry for
any obvious typo):
for a in /proc/[0-9]*
do strings $a/cmdline;
        echo ;
        grep Swap $a/smaps |  awk '{ SUM += $2 } END { print SUM }';
        echo ----------------;
done

the problem is: the total number of swapped out pages (in kilobytes)
doesn't match the output of "free" (swap used column). The difference
is not really big, it ranges around 1-2 megabytes in my measurements.

Anybody knows why?

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com



More information about the Kernelnewbies mailing list