[TAG] [TIPS] checking the amount of swapped out memory owned by a process

Mulyadi Santosa mulyadi.santosa at gmail.com
Tue Jun 16 12:30:39 MSD 2009


On Mon, Jun 15, 2009 at 11:40 PM, David Richardson<dsrich at ieee.org> wrote:
> ### Loop over the PIDs and sum up the swap lines;
> ### 'awk' invocation modified slightly to show PIDs.
> ben at Jotunheim:~$ for n in `ps hk-size -eo size,pid|sed '11,$d;s/.* //'`
>
>
> do
> awk -v pid=$n '/^Swap/{a+=$1}END{printf "%-5d: %d\n",pid,a}' /proc/$n/smaps
> done
>
>
> 17435: 0
> 2853 : 0
> 3689 : 0
> 18392: 0
> 3687 : 0
> 3669 : 0
> 2486 : 0
> 13411: 0
> 3777 : 0
> 3645 : 0
> '''
>
> In fact, there's not a single process on the system that shows a 'Swap'
> line that's greater than 0:
>
> ```
> ben at Jotunheim:~$ awk -v name="$n" '/^Swap/{if ($2>0)print $2}'
> /proc/[0-9]*/smaps
> ben at Jotunheim:~$
> '''
>
> Sorry, Mulyadi - that one didn't pan out.

Hmmm....I began to think that this swap accounting is only included in
Fedora kernel tree only....

Sadly, I only have Fedora installation here to test. If I have time,
I'll see if this swap accounting patch is already merged in mainline
kernel.

regards,

Mulyadi.




More information about the TAG mailing list