·         Also it is advised to examine this summary information, it will certainly be helpfull.

Solaris swapfs

Paging is needed when application requests more memory than free available physical memory.
Paging occurs just for Anonymous memory pages. ( Anonymous pages = process heap + stack + COW)
In AIX and Linux, swap is just the disk device admin configured.
In Solaris, there is a file system called SWAPFS managing swap. It has a concept called “Virtual Swap”
Admin configured swap disk device is called Physical Swap, and it is just a part of Virtual Swap.
Virtual Swap = Physical Swap + Possible RAM.  (Possible RAM= availrmem - swapfs_minfree)
Solaris always keeps track of how much physical memory available. It is stored in a variable called availrmem
swapfs_minfree
is a limit that can never be used for virtual swap. Its default value is RAM/8, it can be changed by /etc/system.  Availrmem is a dynamically changing value, so virtual swap is also a dynamically changing term. Virtual swap is monitored by swap –sh, while physical swap is monitored by swap –lh. Physical swap must always be monitored and there must always be enough room at physical swap, because if %100 physical swap used, all virtual swap will be served from RAM and it is not a good practice. Maximum %25 physical swap usage is always accepted with normal paging operations. You can define your monitoring thresholds due to your application and company needs. Solaris installation by default defines ZFS physical swap size as RAM/4 but this value can be changed online. best practice is physical swap= 0,75 * physical_RAM

Solaris keeps track of available physical memory with availrmem because swapfs use reservation method.
For example, When a process asks for memory at its stack creation, solaris swapfs checks if system.can reserve it or not. If system can reserve it, process will be created. If system can’t reserve it, system will refuse process creation and log messages like below. If you dont want to get below messages, best practice is physical swap= 0,75 * physical_RAM

Jun 18 05:19:07 server1 genunix: [ID 470503 kern.warning] WARNING: Sorry, no swap space to grow stack for pid 16768 (oracle)
Jun 18 05:19:07 server1 genunix: [ID 470503 kern.warning] WARNING: Sorry, no swap space to grow stack for pid 16772 (ksh)

Reservation is something different than allocation. Reservation is just decrementing requested amount from available virtual swap. If available virtual swap (look swap -sh) has enough room, reservation is OK. Process reserved its stack memory but nothing allocated yet. Memory allocation will occur when process pushed something into its stack, deallocation will occur when process popped something from its stack. (will allocate only needed size at that time, not all reservation size.) Also allocation will only occur from physical swap device when page-out occurred. At time t, there can be unallocated reserved areas inside virtual swap.

In AIX and Linux, there is no such reservation mechanism. They just allocate necessary amount of memory when needed. It is called LAZY ALLOCATION. This makes faster application startups because of not implementing reservation but processes are running with the risk of OOM-killer method. Because application demands memory and OS tries to allocate that demand at that time but it may be probable system not having that enough memory, then OOM-killer kills random processes due to their OOM-scores. OOM-scores provide a safer way but it is still risky that your long running critical database application can be killed, process can live consistency problems at startup after this kill etc. Solaris does not like OOM-killer method and thinks that it is risky for application health, so it creates process if it can reserve, it does not create process at the very beginning if it can’t reserve memory. If Solaris can’t reserve memory and does not create any new process, systems admins must examine and solve the issue. It is not adviced for a system admin to behave like OOM-killer and reset the server. Better approach would temporarily increase physical ram or physical swap, then analyze the issue. Memory reservation can only be disabled in program code by setting MAP_NORESERVE flag.


Also Solaris does not have swapoff command like Linux. It has swap –d option to delete physical swap but it may be too probable that it will give “device busy” error and wont delete it. If there is swap problem, you must examine and find related processes and take necessary actions or you must increase swap by adding new devices. (Dont forget that swapoff requires sufficient free RAM to put swap contents into memory.)

 

*** Please feel free to communicate by bulent.yucesoy@gmail.com