Bug 709684

Summary: procps/top SWAP statistics makes no sense
Product: Red Hat Enterprise Linux 6 Reporter: Jan Görig <jgorig>
Component: procpsAssignee: Jaromír Cápík <jcapik>
Status: CLOSED ERRATA QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: medium Docs Contact:
Priority: low    
Version: 6.2CC: albert, aros, jgorig, masanari_iida, ovasik, rvokal, wmealing
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: procps-3.2.8-18.el6 Doc Type: Bug Fix
Doc Text:
Cause - per-process swap values was computed in procps incorrectly Consequence - per-process swap values in top make no sense Fix - swap values are now taken from /proc provided by kernel Result - per-process swap values in top are correct
Story Points: ---
Clone Of: 532668 Environment:
Last Closed: 2011-12-06 09:57:33 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 532668    
Bug Blocks:    
Attachments:
Description Flags
proposed patch none

Description Jan Görig 2011-06-01 11:44:50 UTC
+++ This bug was initially created as a clone of Bug #532668 +++

Description of problem: top shows wrong values for the SWAP field of runnings processes.

Version-Release number of selected component (if applicable): procps-3.2.7-27

How reproducible: always.

Steps to Reproduce: run top, press 'f', press 'p' (show SWAP column).
  
Actual results: senseless SWAP values for running processes.

Expected results: real SWAP values or disable SWAP column altogether as it makes no sense.

Additional info: consult with http://bugzilla.kernel.org/show_bug.cgi?id=14532 for more details.

--- Additional comment from triage.org on 2009-11-16 15:58:54 CET ---


This bug appears to have been reported against 'rawhide' during the Fedora 12 development cycle.
Changing version to '12'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

--- Additional comment from t.artem on 2009-11-16 16:24:44 CET ---

This is definitely `top` bug: http://bugzilla.kernel.org/show_bug.cgi?id=14532#c5

I have notified procps maintainer however I'm not sure if he fixes this bug in the nearest future, as procps development has stalled ostensibly.

--- Additional comment from fedora-admin-xmlrpc on 2010-05-20 14:30:19 CEST ---

This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

--- Additional comment from triage.org on 2010-11-04 07:50:52 CET ---


This message is a reminder that Fedora 12 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 12.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '12'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 12's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 12 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

--- Additional comment from t.artem on 2010-11-26 13:57:52 CET ---

Bump!

--- Additional comment from fedora-admin-xmlrpc on 2011-05-12 10:56:28 CEST ---

This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

--- Additional comment from t.artem on 2011-05-12 11:47:42 CEST ---

Created attachment 498494 [details]
top swap values with no swap

With SWAP disabled, it looks even funnier.

--- Additional comment from masanari_iida on 2011-05-25 11:47:51 CEST ---

Hello
There is one test patch for procps support swap field, created by Mr. Kosaki.
Can you test following patch and evaluate with kernel 2.6.34 or better?
https://github.com/kosaki/procps/commit/8a3d0d4e117efeec869d3d450f749a61cb8b0237

--- Additional comment from jgorig on 2011-05-26 14:43:32 CEST ---

Similar patch for readproc was added by upstream a year ago [1].
Fedora 15 has already this version of readproc but the top interface wasn't updated. I have done some little tests and output seems to be ok, so I am going to release update for F15 next week.

[1] https://gitorious.org/procps/procps/commit/5f570a84f186ca5924be0722ba0956d5fef0b04a

--- Additional comment from masanari_iida on 2011-05-26 17:08:39 CEST ---

Thanks for the investigation.
I will check the procps update on F15.
In the mean time, I would expect to see this modification on RHEL6.2,
because this feature is very useful for enterprise users.
if you ask me to open another BZ for RHEL6, let me know.

Comment 1 Jan Görig 2011-06-01 11:46:42 UTC
Created attachment 502228 [details]
proposed patch

Comment 3 masanari iida 2011-06-02 09:39:13 UTC
Patch on comment #1 works for me.

top - 00:26:06 up 1 day, 10:30,  7 users,  load average: 0.06, 0.01, 0.00
Tasks: 158 total,   1 running, 157 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.3%us,  0.7%sy,  0.0%ni, 99.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:    758620k total,   653400k used,   105220k free,    48356k buffers
Swap:  2064376k total,     2620k used,  2061756k free,   236620k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  SWAP COMMAND
  490 root      16  -4 11384  856  392 S  0.0  0.1   0:00.19  580 udevd
 9694 root      18  -2 11380  716  240 S  0.0  0.1   0:00.01  564 udevd
 9693 root      18  -2 11380  724  240 S  0.0  0.1   0:00.00  556 udevd


[root@rhel6 ~]# cat /proc/490/status |grep VmSwap
VmSwap:      580 kB
[root@rhel6 ~]# cat /proc/9694/status |grep VmSwap
VmSwap:      564 kB
[root@rhel6 ~]# cat /proc/9693/status |grep VmSwap
VmSwap:      556 kB

Thank you!

Comment 5 Jan Görig 2011-06-02 12:35:33 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause
- per-process swap values was computed in procps incorrectly
Consequence
- per-process swap values in top make no sense
Fix
- swap values are now taken from /proc provided by kernel
Result
- per-process swap values in top are correct

Comment 6 masanari iida 2011-06-03 05:38:42 UTC
One minor request about man page.
Current man page of top(1),

> p: SWAP  -- Swapped size (kb)
-   The swapped out portion of a task's total virtual memory image.

+ Per-process swap values are now taken from /proc/#/status VmSwap field.

Comment 10 Wade Mealing 2011-07-08 05:55:10 UTC
Dumb post mistake, i just realised that other kernel structures may be swapped out.

Comment 12 errata-xmlrpc 2011-12-06 09:57:33 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2011-1554.html