Unix Technical Forum

swapinfo explains

This is a discussion on swapinfo explains within the HP-UX Operating System forums, part of the Unix Operating Systems category; --> Hi, I trying to understand the below information: # swapinfo -t Kb Kb Kb PCT START/ Kb TYPE AVAIL ...


Go Back   Unix Technical Forum > Unix Operating Systems > HP-UX Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-16-2008, 07:21 PM
Smith
 
Posts: n/a
Default swapinfo explains

Hi,
I trying to understand the below information:


# swapinfo -t
Kb Kb Kb PCT START/ Kb
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 4194304 0 4194304 0% 0 - 1 /dev/vg00/lvol2
dev 4096000 2902180 1193820 71% 0 - 0 /dev/test_dg2/swap1
reserve - 4699536 -4699536
memory 4183232 3544588 638644 85%
total 12473536 11146304 1327232 89% - 0 -


From the above,
The first swap of 4Gb is not in use.
The second swap of 4Gb is 71%

question 1) How total of 89% is deduce?
question 2) the reserve is used for?? And why is the reserve needs 4Gb?

Thanks and regards



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-16-2008, 07:21 PM
Don Morris
 
Posts: n/a
Default Re: swapinfo explains

Smith wrote:
> Hi,
> I trying to understand the below information:
>
>
> # swapinfo -t
> Kb Kb Kb PCT START/ Kb
> TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
> dev 4194304 0 4194304 0% 0 - 1 /dev/vg00/lvol2
> dev 4096000 2902180 1193820 71% 0 - 0 /dev/test_dg2/swap1
> reserve - 4699536 -4699536
> memory 4183232 3544588 638644 85%
> total 12473536 11146304 1327232 89% - 0 -
>
>
> From the above,
> The first swap of 4Gb is not in use.
> The second swap of 4Gb is 71%
>

As it should be -- the priority of the second device is 0,
the priority of the first is 1 -- lowest priority devices
are used first.

> question 1) How total of 89% is deduce?
> question 2) the reserve is used for?? And why is the reserve needs 4Gb?


Have to answer these together.

First, you have to understand how swap is used on HP-UX (which differs
in the default from Linux, for example). On HP-UX, whenever a process
uses virtual address space (by doing malloc/sbrk, etc.) it must reserve
the corresponding amount of swap to back it. That means that the amount
of free swap is reduced -- not that a particular disk block on a swap
device is allocated. This is done so that when the time comes (if ever)
to actually swap out that part of the process, HP-UX will always be able
to find space for it on some swap device. When no swap is left for
reservation, HP-UX will simply fail new allocation requests (which also
means that new processes won't start, etc.) So the system limits the
amount of virtual addresses consumed such that if the worst case happens
and all of swap is consumed, it will be able to do so without killing
processes. [On Linux, since they use "lazy" swap where swap is only
consumed when it is actually used, overreservation of swap means that
processes can't always find swap when they need it... and that gets
handled by killing processes arbitrarily to free up space or other
methods... HP-UX made the design choice to make checks up front in
most cases... there is a LAZY_SWAP option on mmap, etc. for applications
which want to take the risk]. [1]

That's the reservation field -- you should always see something
reserved. Then when swap is actually *used* a disk block is chosen,
and device/FS swap is consumed... so swapinfo will show that swap
usage moving from "reserved" to "used". In your case, your applications
are consuming 7.25Gb of virtual address space backed by disk. 4.48Gb
doesn't need to actually be swapped out yet (which is good), and the
rest has been swapped out (which is likely making the box run pretty
slow... your working set is really larger than your memory, you should
look into tuning your applications to use less memory if possible --
or just buy more RAM).

That's the Disk/FS side of things.. then there's memory or "pseudo"
swap. That's the memory line on swapinfo. This was implemented so that
customers with lots of RAM who knew their working set fit in memory
and almost *never* actually swapped wouldn't have to buy a bunch of
disks that would sit there unused. Simply put, this is an accounting
trick on HP-UX where the physical memory being used for a virtual object
is counted as the "swap" for that object. In other words -- the physical
page swaps to itself. Memory swap is automatically used (if the
swapmem_on parameter is set to the default of "enabled") for any Kernel
memory [since the kernel is never swapped out] and for any memory pinned
via the mlock/mlockall interfaces [similar reasoning.. if the memory
can't be swapped out, why consume disk reservation for it?]

So the total swap consumed on the machine is:

Swap Blocks actually being used (2902180 bytes)
+
Swap reserved (not used yet, but may be needed) (4699536 bytes)
+
Memory Swap (3544588)

And the total swap available correspondingly is:

Total Swap Blocks configured on the box
+
Total Memory Swap available on the box [usually 75% or so
of RAM, the kernel uses a heuristic to pick the value at boot]

Add your Avail lines above and that gives you the total configured swap.
Add your used lines and that gives you your total consumed.
Consumed / Configured * 100 = 89%.

Don

[1] As an aside, this is the reason for the max{t,s,d}siz{_64bit}
tunables in HP-UX.. they're there to fence in the virtual sizes of
user processes. Otherwise, you could have a denial of service attack
by a malicious user aware of the reservation policy by simply doing
a malloc() in chunks of more memory than the system can reserve in
swap... existing processes would continue to run (until they needed
memory), but nothing new could start.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:57 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com