General
cancel
Showing results for 
Search instead for 
Did you mean: 

Question about Swap in HP-UX 11.23

 
SOLVED
Go to solution
Highlighted
Advisor

Question about Swap in HP-UX 11.23

Could someone please elaborate on the purpose of "reserved" memory?

If there is a process that tries to reserve more swap/virtual/reserve? memory than is available what happens to that process?

/var/adm/syslog $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 20971520 0 20971520 0% 0 - 1 /dev/vg00/lvol9
reserve - 25114192 -25114192
memory 67078728 14496012 52582716 22%
total 92244552 39610204 52634348 43% - 0 -
5 REPLIES 5
Highlighted
Honored Contributor
Solution

Re: Question about Swap in HP-UX 11.23

It isn't memory that's reserved (note that the memory [aka pseudo-swap] has only AVAIL USED and FREE lines), it is swap.

HP-UX (like most other Enterprise Unix OS's) requires all virtual objects by default to be backed by swap space. However, it doesn't need to direct a particular swap block (i.e. a disk sector or file system block) at the time of allocation -- so the swap is "reserved" [no longer considered free]. If the swap is ever actually needed, the system can allocate/use the swap by looking for a free range of the size in question (which has to exist since it was reserved).

Or in short -- if you malloc() X Gb, that requires X Gb of swap reservation to go with it. If it isn't available, the malloc() gets ENOMEM. [Similar results for similar failing allocation system calls]. The odd state is when you leave the defaults and specifically request (via flags or chatr) lazy swap where the reservation isn't done until fault time (when actual RAM pages are consumed). There, a failing reservation will kill the process [and that's why this isn't the default].
Highlighted
Advisor

Re: Question about Swap in HP-UX 11.23

Assuming my process was attempting to allocated more swap than available, would the OS log the failed attempt?
Highlighted
Honored Contributor

Re: Question about Swap in HP-UX 11.23

As mentioned by Don, If a process does a malloc() and the kernel figures out there is not enough swap to support the request, then the malloc() call would fail with errno set to ENOMEM. It is up to the calling process to handle such a case. Mostly, the process would just exit() after receiving such an error.
Highlighted
Acclaimed Contributor

Re: Question about Swap in HP-UX 11.23

>Venkatesh: It is up to the calling process to handle such a case. Mostly, the process would just exit() after receiving such an error.

Exactly.
But I would hope the process would print out an nice informative message and then abort, or at least exit with a bad status. And possibly trying to cleanup.
Highlighted
Honored Contributor

Re: Question about Swap in HP-UX 11.23

To fully utilize all of the RAM on a system there must be a sufficient amount
of virtual memory to accomodate all processes . The virtual memory be at least eaqual to physical memory plus application
size.
For a process
to spawn it needs a sufficient amount of virtual memory to be placed in
reserve. There should be a sufficient amount of free device swap to open any
processes that may be spawned during the course of operations. By subtracting
thereserve from the device total you can determine this value.
If there is an insufficient amount available ( typically from device swap)
you will receive an error : cannot fork : not enough virtual memory. If
this error is received , you will need to allocate more device swap. This
should be configured on a disk with no other swap partitions, and ideally of
the same size and priority of existing swap logical volumes to enable
interleaving.