pcp
[Top] [All Lists]

Re: [pcp] proc.runq.swapped

To: Nathan Scott <nathans@xxxxxxxxxx>
Subject: Re: [pcp] proc.runq.swapped
From: Marko Myllynen <myllynen@xxxxxxxxxx>
Date: Fri, 21 Aug 2015 10:28:54 +0300
Cc: pcp developers <pcp@xxxxxxxxxxx>
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <1030698109.15876249.1440139882307.JavaMail.zimbra@xxxxxxxxxx>
Organization: Red Hat
References: <55D57D3D.5050900@xxxxxxxxxx> <1030698109.15876249.1440139882307.JavaMail.zimbra@xxxxxxxxxx>
Reply-to: myllynen@xxxxxxxxxx
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0
Hi,

On 2015-08-21 09:51, Nathan Scott wrote:
>>
>> I'm using this script to see which processes have (parts of) their memory
>> swapped:
>>
>> #!/bin/sh
>> #
>> # Total swap usage as shown by free(1) and /proc/swaps does not exactly match
>> # with the swap usage summed up for individual processes as done below due to
>> # pages in swap cache being included in free(1) and /proc/swaps usage amount.
>>
>> for p in /proc/[1-9]* ; do
>>   awk '/^[0-9]+ \(/ {printf "%-8s%-18s", $1, $2; nextfile} \
>>     /Swap:/ {swap+=$2} END {printf "%8.4f MB\n", swap/1024}' $p/stat $p/smaps
>>     \
>>       2>/dev/null ;
>> done|sort -gk3|awk '{s=s+$3;print $0}END{printf "Total:%28.4f %s\n", s,
>> "MB"}'
> 
> It looks like this script has a different definition of swapped to the value
> that proc.runq.swapped presents.  The script is looking at smaps, and looking
> for any mappings within a process listed as swapped out.  Reading through the
> pmdaproc code, proc.runq.swapped counts processes where the address space is
> entirely swapped out (not just parts thereof), and this is infered using only
> values from /proc/pid/stat.

thanks, code had a comment about that but I couldn't find any of such
processes during later testing so it wasn't clear.

>> So looks like proc.runq.swapped is currently meaningless?
> 
> Just a different meaning to the value being presented by the script, I
> think, not meaningless.

Yup, the above is certainly useful metric to have.

> We have no code looking inside the smaps files at all currently in PCP -
> new metrics could certainly be added to export values from there though,
> its a SMOP.
> 
> I did notice going through the atop code recently that it also looks at
> smaps, but only if a special option is used (-R) and it's using smaps to
> extract this (and nothing else - no swap metrics from there FWLIW) ...
> 
> (we don't support this in pcp-atop yet, but we could if a PMDA was made
> to export this metric - it would need similar code to that which you're
> after to mimic your script above, looking at Pss: instead of Swap: tho).

Thanks,

-- 
Marko Myllynen

<Prev in Thread] Current Thread [Next in Thread>