1828708 Members
2355 Online
109984 Solutions
New Discussion

Swap Disk Usage

 
Arnaud Veron
Valued Contributor

Swap Disk Usage

Hi,

I'd like to know how my swap disk is used.
I can see the whole processes that are using the swap disk with the "fuser -c /dev/disk/dskXX" command.

But how can i know how much swap is using each process ???

Thanks for your help.

Arnaud.
2 REPLIES 2
Ralf Puchner
Honored Contributor

Re: Swap Disk Usage

ps waux, this question was asked and answered several time. have a look into the "VSZ" row.
Help() { FirstReadManual(urgently); Go_to_it;; }
Arnaud Veron
Valued Contributor

Re: Swap Disk Usage

An example with my comments in brackets :

[[ a little info about my 51B-1 test server ]]
# vmstat -P

Total Physical Memory = 1024.00 M
= 131072 pages

Physical Memory Clusters:

start_pfn end_pfn type size_pages / size_bytes
0 653 pal 653 / 5.10M
653 131063 os 130410 / 1018.83M
131063 131072 pal 9 / 72.00k

Physical Memory Use:

start_pfn end_pfn type size_pages / size_bytes
653 801 scavenge 148 / 1.16M
801 1698 text 897 / 7.01M
1698 1875 data 177 / 1.38M
1875 2104 bss 229 / 1.79M
2104 2321 kdebug 217 / 1.70M
2321 2328 cfgmgmt 7 / 56.00k
2328 2330 locks 2 / 16.00k
2330 2344 pmap 14 / 112.00k
2344 2701 unixtable 357 / 2.79M
2701 2725 logs 24 / 192.00k
2725 5729 vmtables 3004 / 23.47M
5729 131063 managed 125334 / 979.17M
============================
Total Physical Memory Use: 130410 / 1018.83M

Managed Pages Break Down:

free pages = 101380
active pages = 1454
inactive pages = 6842
wired pages = 12717
ubc pages = 3089
==================
Total = 125482

WIRED Pages Break Down:

vm wired pages = 5278
ubc wired pages = 27
meta data pages = 1287
malloc pages = 2613
contig pages = 2638
user ptepages = 759
kernel ptepages = 111
free ptepages = 4
==================
Total = 12717


[[ physical swap is filled in with 1903 pages ]]
# swapon -s
Swap partition /dev/disk/dsk0b:
Allocated space: 324413 pages (2.48GB)
In-use space: 1903 pages ( 0%)
Free space: 322510 pages ( 99%)


Total swap allocation:
Allocated space: 324413 pages (2.48GB)
In-use space: 1903 pages ( 0%)
Available space: 322510 pages ( 99%)


# mkdir /memfilesystem

[[ creating a 5GB memory filesystem ]]
# mfs -s `echo 10*1024*1024|bc` /memfilesystem

# df -k|grep mem
var_domain#tmp 2097152 3327 1416632 1% /cluster/members/member0/tmp
mfs:37139 5068029 1 4561225 0% /memfilesystem

[[ RSS = 29MB and VSZ = 5GB ]]
# ps auxww|grep mem
root 37152 0.0 0.0 2.43M 224K pts/1 S + 16:59:52 0:00.00 grep mem
root 37139 0.0 2.8 5.00G 29M ?? I 16:58:48 0:00.28 mfs -s 10485760 /memfilesystem

[[ physical swap is still 1903 pages so VSZ != swap usage ]]
# swapon -s
Swap partition /dev/disk/dsk0b:
Allocated space: 324413 pages (2.48GB)
In-use space: 1903 pages ( 0%)
Free space: 322510 pages ( 99%)


Total swap allocation:
Allocated space: 324413 pages (2.48GB)
In-use space: 1903 pages ( 0%)
Available space: 322510 pages ( 99%)

[[ filling in the 5GB memory filesystem with 200MB ]]
# dd if=/dev/zero of= /memfilesystem/memfilesystem/file1 bs=1024k count=200
200+0 records in
200+0 records out
# df -k|grep mem
var_domain#tmp 2097152 3327 1416624 1% /cluster/members/member0/tmp
mfs:37139 5068029 204913 4356313 5% /memfilesystem

[[ RSS = 29MB + 200MB and VSZ still 5GB ]]
# ps auxww|grep mem
root 37139 0.9 22.5 5.00G 229M ?? S 16:58:48 0:01.04 mfs -s 10485760 /memfilesystem
root 37260 0.0 0.0 2.43M 224K pts/1 S + 17:00:55 0:00.00 grep mem

[[ physical swap is still 1903 pages ]]
# swapon -s
Swap partition /dev/disk/dsk0b:
Allocated space: 324413 pages (2.48GB)
In-use space: 1903 pages ( 0%)
Free space: 322510 pages ( 99%)


Total swap allocation:
Allocated space: 324413 pages (2.48GB)
In-use space: 1903 pages ( 0%)
Available space: 322510 pages ( 99%)

[[ filling in the 5GB memory filesystem with another 200MB file ]]
# cp /memfilesystem/file1 /memfilesystem/file2
# df -k|grep mem
var_domain#tmp 2097152 3327 1416624 1% /cluster/members/member0/tmp
mfs:37139 5068029 409825 4151401 9% /memfilesystem

[[ RSS = 29MB + 2*200MB and VSZ still 5GB ]]
# ps auxww|grep mem
root 37139 0.4 42.1 5.00G 429M ?? S 16:58:48 0:02.07 mfs -s 10485760 /memfilesystem
root 37261 0.0 0.0 2.43M 224K pts/1 S + 17:01:54 0:00.00 grep mem

[[ physical swap is still 1903 pages ]]
# swapon -s
Swap partition /dev/disk/dsk0b:
Allocated space: 324413 pages (2.48GB)
In-use space: 1903 pages ( 0%)
Free space: 322510 pages ( 99%)


Total swap allocation:
Allocated space: 324413 pages (2.48GB)
In-use space: 1903 pages ( 0%)
Available space: 322510 pages ( 99%)

[[ filling in the 5GB memory filesystem with another 200MB file ]]
# cp /memfilesystem/file1 /memfilesystem/file3
# df -k|grep mem
var_domain#tmp 2097152 3327 1416624 1% /cluster/members/member0/tmp
mfs:37139 5068029 614737 3946489 14% /memfilesystem

[[ RSS = 29MB + 3*200MB and VSZ still 5GB ]]
# ps auxww|grep mem
root 37139 2.2 61.8 5.00G 629M ?? S 16:58:48 0:03.12 mfs -s 10485760 /memfilesystem
root 37272 0.0 0.0 2.43M 224K pts/1 S + 17:03:06 0:00.00 grep mem

[[ physical swap is still 1903 pages ]]
# swapon -s
Swap partition /dev/disk/dsk0b:
Allocated space: 324413 pages (2.48GB)
In-use space: 1903 pages ( 0%)
Free space: 322510 pages ( 99%)


Total swap allocation:
Allocated space: 324413 pages (2.48GB)
In-use space: 1903 pages ( 0%)
Available space: 322510 pages ( 99%)

[[ filling in the 5GB memory filesystem with another 200MB file ]]
# cp /memfilesystem/file1 /memfilesystem/file4
# df -k|grep mem
var_domain#tmp 2097152 3327 1416624 1% /cluster/members/member0/tmp
mfs:37139 5068029 819649 3741577 18% /memfilesystem

[[ RSS = 29MB + 3*200MB + last free mem chunk and VSZ still 5GB ]]
[[ if the memory was not full, we at this moment should have RSS = 29MB + 4*200MB ]]
[[ we can see RSS is only 718MB ]]
[[ 29MB + 4*200MB - 718MB = about 111 MB swapped out to disk ]]
# ps auxww|grep mem
root 37276 0.0 0.0 2.43M 224K pts/1 S + 17:03:47 0:00.00 grep mem
root 37139 0.0 70.5 5.00G 718M ?? S 16:58:48 0:04.89 mfs -s 10485760 /memfilesystem

[[ physical swap occupation has grew up by 20400-1903=18497 pages => about 130MB ]]
# swapon -s
Swap partition /dev/disk/dsk0b:
Allocated space: 324413 pages (2.48GB)
In-use space: 20400 pages ( 6%)
Free space: 304013 pages ( 93%)


Total swap allocation:
Allocated space: 324413 pages (2.48GB)
In-use space: 20400 pages ( 6%)
Available space: 304013 pages ( 93%)
#


So my question is : how can i know that PID 37139 ( mfs ) have at least 110 MB swapped out to physical swap ???
In some case, VSZ-RSS=swap disk usage but not always...

Thanks for your help.