1844919 Members
1566 Online
110233 Solutions
New Discussion

swap reservation

 
Tore_1
Regular Advisor

swap reservation

Hi, does anyone know why hpux requieres every
process to *reserve* swapspace?
11 REPLIES 11
Bill McNAMARA_1
Honored Contributor

Re: swap reservation

It's a virtual memory system.

If an app needs to be paged out to free up real mem, then it must be able to have the swap reserved.


man swapinfo.

You can also set swap mem on to false in the kernel and page in memory (useful if you have 100G of memory!)


Later,
Bill
It works for me (tm)
Tore_1
Regular Advisor

Re: swap reservation

i know, but why doesnt all unixes require swap
reservation?
Peter Kloetgen
Esteemed Contributor

Re: swap reservation

Hi Tore,

swapping is needed if your memory is full with processes and there is no space available for more required processes. Then either whole processes ( swapping ) or pages ( paging ) are outsourced into swapspace. This should appear not very intensively or often, if so, you should add physical RAM to your computer. Swapping and paging is very slow compared with processes which are run directly out of RAM. But swapspace guarantees, that you are still able to act, if your RAM is fully occupied. Computers with up to a GB RAM it is a normal amount of swapspace round about two times total RAM amount.

more information see:

man swapinfo

Allways stay on the bright side of life!

Peter
I'm learning here as well as helping
Bill McNAMARA_1
Honored Contributor

Re: swap reservation

sory got the swap mem on wrong:

kibo:root> kmtune | grep swap
allocate_fs_swapmap 0
maxswapchunks 512
nswapdev 10
nswapfs 10
remote_nfs_swap 0
swapmem_on 1

See this link for more:

http://docs.hp.com//hpux/onlinedocs/os/KCparam.SwapMemOn.html

Later,
Bill
It works for me (tm)
Tore_1
Regular Advisor

Re: swap reservation

say you have 1G ram, and 2G swap. If you put a 1,5 G memory load on the system, would it be usable? If not, why do you need 2G swap?
Patrick Wallek
Honored Contributor

Re: swap reservation

Well, that depends on what your definition of "usable" is. If you have already maxed out your 1GB of RAM and something comes in that needs 500MB, then processes in memory will start getting paged to disk to free up RAM. When it comes back to time for those processes to run, something else will get paged out so the process coming in has memory to work with.

Your system will still run, but things will be VERY VERY SLOW.

Paging really should not be an issue today. If you start using swap significantly, then you buy more RAM. RAM is cheap!!!!

Frank Slootweg
Honored Contributor

Re: swap reservation

If the kernel parameter swapmem_on is set to 1, which is in nearly all cases the most sensible thing to do, then (80% of) memory is included in the swapspace calculations. If swapmem_on is 1, the swapinfo(1M) output will have an extra "memory" line. (Note: Always use "swapinfo -t" and only/mainly look at the "total" line.)

So for example if you have 1GB of RAM and 800MB of processes, the *disk* swap space is not *used* at all, so the "USED" field of the "dev" line(s) would be zero and there would be *no* disk *activity*.

If you have HP-UX 11.X, you may also want to read the section on "Lazy Swap" in the Release Notes (/usr/share/11.00RelNotes). Note however that that is for very specific cases, while swapmem_on addresses the more general cases.
William Lara
New Member

Re: swap reservation

It is the system's way of making sure that it will not start a process that it will not be able to swap out at a later point in time. If there is no memory pressure then yea, set swapmen_on to 1. That will keep you from wasting disk space to reserve swap that is never used. If you programs are reserving a large amount of swapspace compared to how much is actually they actually end up using then I would look into lazy swap (an attribute of the exectuable). I would read up and test before implementing first. See man page for chatr,also see white pages for HP_UX memory management and process management.
Only if you are experiencing memory pressure do you need more ram (it did not sound like you were).
Dave's not here!
Sridhar Bhaskarla
Honored Contributor

Re: swap reservation

Hi Tore,

I understood it in this way. It wants to make sure that there is swap space available in case if it needs to page out. Best way to confirm it is by reserving the swap space.

For ex., if you have 1 GB memory and if you alloted only 100MB of swap, what will happen if the system has to pageout 200MB if it
didn't reserve the swap space?.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Dietmar Konermann
Honored Contributor

Re: swap reservation

Just a small note on "but why doesnt all unixes require swap reservation?".

This is designer's choice. By default HP-UX reserves swap for allocations. Period.

This can be changed using lazy swap allocation (like Frank already stated). Beginning with 11.00 you could flag an executable to use lazy swapping with the chatr(1M) command. Programs can e.g. use mmap(2) with the MAP_NORESERVE option, like the java VM usually does.

Some other vendors use the lazy scheme by default... however, if swap gets full, "lazy processes" need to be killed. That's the disadvantage, so lazy swapping is somewhat "more dangerous" and risky.

Best regards...
Dietmar.
"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)
Frank Slootweg
Honored Contributor

Re: swap reservation

William,

Just wondering: Why did you 'wake' this thread which was nearly a year old?