LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-07-2013, 01:26 AM   #1
Rohit_4739
Member
 
Registered: Oct 2010
Distribution: Red Hat
Posts: 224

Rep: Reputation: 7
/proc/<pid>/smaps missing "Swap"


Hi All,

I made a script few days back to find the process using the Swap in RHEL. I used the /proc/<pid>/smaps file and then extracting the Swap from it. Below is the script

Code:
for i in /proc/*/smaps ; do awk '/Swap/ {sum += $2}; END{ print FILENAME " Total: " sum}' $i; done | sort -nr -k 3
ANd it worked fine on most systems, but today i came across a system where the Swap was full so i ran the script but script didn't show my any results, so i digged into it and found that there is no Swap row in Smaps file. PLease see below

Quote:
# cat /proc/10686/smaps
2b6c5cc6b000-2b6c5ccc5000 r-xp 00000000 fd:01 164061 /usr/sbin/sshd
Size: 360 kB
Rss: 300 kB
Shared_Clean: 300 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 0 kB
2b6c5cec5000-2b6c5cec8000 rw-p 0005a000 fd:01 164061 /usr/sbin/sshd
Size: 12 kB
Rss: 12 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 12 kB
2b6c5cec8000-2b6c5cecf000 rw-p 2b6c5cec8000 00:00 0
Size: 28 kB
Rss: 28 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 28 kB
As you see Swap is missing here. So can anyone please explain how and why Swap is missing here, and then from where Top actually picks up the processes's swap usage.

ANd below is a server where i see two additional rows

Quote:
cat /proc/30513/smaps
00400000-0b459000 r-xp 00000000 fd:09 269727 /u01/app/oracle/product/11.2.0.2/db_1/bin/oracle
Size: 180580 kB
Rss: 11972 kB
Shared_Clean: 11868 kB
Shared_Dirty: 0 kB
Private_Clean: 104 kB
Private_Dirty: 0 kB
Swap: 0 kB
Pss: 475 kB
0b658000-0b820000 rwxp 0b058000 fd:09 269727 /u01/app/oracle/product/11.2.0.2/db_1/bin/oracle
Size: 1824 kB
Rss: 272 kB
Shared_Clean: 200 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 72 kB
Swap: 0 kB
Pss: 78 kB
0b820000-0b86b000 rwxp 0b820000 00:00 0
Size: 300 kB
Rss: 204 kB
Shared_Clean: 8 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 196 kB
Swap: 0 kB
Pss: 196 kB
ANy help ideas,explaination would be highly appreciated.
 
Old 03-07-2013, 02:12 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,102

Rep: Reputation: 982Reputation: 982Reputation: 982Reputation: 982Reputation: 982Reputation: 982Reputation: 982Reputation: 982
Looks like an old kernel - very old. What does "uname -a" show ?.
 
Old 03-07-2013, 02:25 AM   #3
Rohit_4739
Member
 
Registered: Oct 2010
Distribution: Red Hat
Posts: 224

Original Poster
Rep: Reputation: 7
Quote:
Originally Posted by syg00 View Post
Looks like an old kernel - very old. What does "uname -a" show ?.
Code:
root@dbsr0003:/root
# uname -r
2.6.18-92.el5
root@dbsr0003:/root
Its a RHEL5 machine so it is old but not very old (just kidding). And secondly then how from where Top is picking up all the infomration. Below infomrmation is from a different machine with kernel having same major relaease that is 2.6,

Quote:
Pss: 40 kB
7fffcf1ab000-7fffcf1ad000 rw-p 7fffffffd000 00:00 0
Size: 8 kB
Rss: 4 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 4 kB
Swap: 0 kB
Pss: 4 kB
7fffcf1fc000-7fffcf200000 r-xp 7fffcf1fc000 00:00 0 [vdso]
Size: 16 kB
Rss: 4 kB
Shared_Clean: 4 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 0 kB
Swap: 0 kB
Pss: 0 kB
ffffffffff600000-ffffffffffe00000 ---p 00000000 00:00 0 [vsyscall]
Size: 8192 kB
Rss: 0 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 0 kB
Swap: 0 kB
Pss: 0 kB

root@xxxxx:/root
# uname -r
2.6.18-238.12.1.el5
So i am having hard time now understanding this why this weird behaviour ?

Last edited by Rohit_4739; 03-07-2013 at 02:34 AM.
 
Old 03-07-2013, 04:42 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,102

Rep: Reputation: 982Reputation: 982Reputation: 982Reputation: 982Reputation: 982Reputation: 982Reputation: 982Reputation: 982
I think that smaps support came in around 2.6.25/26 - quite a while ago.
As for top I think it calculates the swap when the smaps data isn't available - we've had several discussions here on LQ re whether it produced anything worth using.
 
Old 03-07-2013, 04:44 AM   #5
Rohit_4739
Member
 
Registered: Oct 2010
Distribution: Red Hat
Posts: 224

Original Poster
Rep: Reputation: 7
Quote:
Originally Posted by syg00 View Post
- we've had several discussions here on LQ re whether it produced anything worth using.
By the above statements do you mean Top or Smaps ??
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Monitoring memory usage using /proc/<PID>/smaps Ondrej Linux - Server 0 01-18-2013 02:44 PM
[SOLVED] Correlation between "free -m" shared line & "/proc/meminfo" shmem RHEL 6.2 - Anyone? xenner Linux - General 3 11-15-2012 05:36 PM
Read file in folder /proc/"pid"/fd/0 in ubuntu v11.10? newbie_member Linux - Newbie 4 07-19-2012 05:05 AM
"missing btime in /proc/stat" toredo Linux - Software 1 05-09-2012 04:44 PM
after new swap partition, "NTLDR is missing" shankargopal Puppy 4 07-06-2006 11:44 PM


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

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