|
Softpanorama |
May the source be with you, but remember the KISS principle ;-)
|
A system’s virtual memory is a combination of the available random access memory (RAM) and disk space. Portions of the virtual memory are reserved as swap space. Swap space can be defined as a temporary storage location that is used when system’s memory requirements exceed the size of available RAM. The default page size for Solaris is 8K. Usual size of Solaris swap partition is the size of RAM.
swap utility usage (-a add, -s summary, -l list, -d delete):
-d
To delete a swap slice from the current swap configuration.
# swap -d /dev/dsk/c1t0d0s3
Add the following line to create the swap slice.
/dev/dsk/c1t0d0s3 --swap -no -Use the swap -a command to add additional swap area.
# swap -a /dev/dsk/c1t0d0s3Note
– When the system is subsequently rebooted, the new swap slice /dev/dsk/c1t0d0s3 will be automatically included as part of the swap space as a result of adding the entry to the /etc/vfstab file.
/export/data directory.
# mkfile 1000m /export/data/swapfile
# swap -a /export/data/swapfile
# vi /etc/vfstab
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot opt
/export/data/swapfile --swap -no -
Removing Swap Slices
# swap -d /dev/dsk/c1t0d0s3
# swap -d /export/data/swapfile
It is important for administrators to understand the features of the SunOS swap mechanism in determining:
Swap slices are used as virtual memory storage areas when the system does not have enough physical memory to handle current processes.
The virtual memory system maps physical copies of files on disk to virtual addresses in memory. Physical memory pages which contain the data for these mappings can be backed by regular files in the file system, or by swap space. If the memory is backed by swap space it is referred to as anonymous memory because there is no identity assigned to the disk space backing the memory.
Solaris uses the concept of virtual swap space, a layer between anonymous memory pages and the physical storage (or disk-backed swap space) that actually back these pages. A system's virtual swap space is equal to the sum of all its physical (disk-backed) swap space plus a portion of the currently available physical memory.
Virtual swap space has these advantages:
The TMPFS file system is activated automatically in the Solaris environment by an entry in the /etc/vfstab file. The TMPFS file system stores files and their associated information in memory (in the /tmp directory) rather than on disk, which speeds access to those files. This results in a major performance enhancement for applications such as compilers and DBMS products that use /tmp heavily.
The TMPFS file system allocates space in the /tmp directory from the system's swap resources. This means that as you use up space in /tmp, you are also using up swap space. So if your applications use /tmp heavily and you do not monitor swap space usage, your system could run out of swap space.
Use the following if you want to use TMPFS but your swap resources are limited:
TMPDIR environment variable to point to a larger, real directory.
Using your compiler's TMPDIR variable only controls whether the
compiler is using /tmp or not. It has no effect on other programs'
use of /tmp.
This section lists several possible error messages displayed when you run out of swap space.
These messages indicate that an application was trying to get more anonymous memory and there was no swap space left to back it.
application is out of memory malloc error O messages.1:Sep 21 20:52:11 mars genunix: [ID 470503 kern.warning] WARNING: Sorry, no swap space to grow stack for pid 100295 (myprog) |
| directory: File system full, swap space limit exceeded |
This message is displayed if a page could not be allocated when writing a file. This can occur when TMPFS tries to write more than it is allowed or if currently executed programs are using a lot of memory.
| directory: File system full, memory allocation failed |
This message means TMPFS ran out of physical memory while attempting to create a new file or directory.
See TMPFS(7FS) for information on recovering from the TMPFS-related error messages.
Initially, swap space is allocated as part of the Solaris installation process. If you use the installation program's automatic layout of disk slices and do not manually change the size of the swap slice, the Solaris installation program allocates default swap slices as shown in the table below.
| If Your System Has n Mbytes of Physical Memory ... | Then the Default Swap Space Allocated Is ... |
|---|---|
| 16-63 | 32 Mbytes |
| 64-127 | 64 Mbytes |
| 128-511 | 128 Mbytes |
| greater than 512 | 256 Mbytes |
Additional swap space can also be added to the system by creating a swap file. See "Adding More Swap Space" for information about creating a swap file.
After the system is installed, swap slices and files are listed in the /etc/vfstab file and are activated by the /sbin/swapadd script when the system is booted.
An entry for a swap device in the /etc/vfstab file contains:
Because the file system containing a swap file must be mounted before the swap file is activated, make sure that the entry that mounts the file system comes before the entry that activates the swap file in the /etc/vfstab file.
The most important factors in determining swap space size are the requirements of the system's software applications. For example, large applications such as computer-aided-design simulators, database-management products, transaction monitors, and geologic analysis systems can consume as much as 200-1000 Mbytes of swap space.
Consult your application vendor for swap space requirements for any application whose data files typically exceed 10-20 Mbytes in size.
If you are unable to determine swap space requirements from the application vendor, use the following guidelines to allocate swap space:
The /usr/sbin/swap command is used to manage swap areas. Two options, -l and -s, are used to display information about swap resources.
Use the swap -l command to identify a system's swap areas. Activated swap devices or files are listed under the swapfile column.
# swap -l swapfile dev swaplo blocks free /dev/dsk/c0t2d0s1 32,17 8 205624 192704 |
Use the swap -s command to monitor swap resources.
# swap -s total: 10492k bytes allocated + 7840k reserved = 18332k used, 21568k available |
The used plus available figures equals total swap space on the system, which includes a portion of physical memory and swap devices (or files).
You can use the amount of swap space available and used (in the swap -s output) as a way to monitor swap space usage over time. If a system's performance is good, use swap -s to see how much swap space is available. When the performance of a system slows down, check the amount of swap space available to see if it has decreased. Then you can identify what changes to the system might have caused swap space usage to increase.
Keep in mind when using this command that the amount of physical memory available for swap usage changes dynamically as the kernel and user processes lock down and release physical memory.
Note - The swap -l command displays swap space in 512-byte blocks and the swap -s command displays swap space in 1024-byte blocks. If you add up the blocks from swap -l and convert them to Kbytes, it will be less than used + available (in the swap -s output) because swap -l does not include physical memory in its calculation of swap space.
The output from the swap -s command is summarized in the table below.
| Keyword | Description |
|---|---|
| bytes allocated | The total amount of swap space in 1024-byte blocks that is currently allocated as backing store (disk-backed swap space). |
| reserved | The total amount of swap space in 1024-byte blocks not currently allocated, but claimed by memory for possible future use. |
| used | The total amount of swap space in 1024-byte blocks that is either allocated or reserved. |
| available | The total amount of swap space in 1024-byte blocks that is currently available for future reservation and allocation. |
As system configurations change and new software packages are installed, you might need to add more swap space. The easiest way to add more swap space is to use the mkfile and swap commands to designate a part of an existing UFS or NFS file system as a supplementary swap area. These commands, described below, enable you to add more swap space without repartitioning a disk.
Alternative ways to add more swap space are to repartition an existing disk or add another disk. See Chapter 28, Disk Management (Overview) for information on how to repartition a disk.
The following general steps are involved in creating a swap file:
The mkfile command creates a file that is suitable for use either as an NFS-mounted or local swap area. The sticky bit is set, and the file is filled with zeros. You can specify the size of the swap file in bytes (the default) or in kilobytes, blocks, or megabytes using the k, b, or m suffixes, respectively.
The table below shows the options to the mkfile command.
| Option | Description |
|---|---|
| -n | Creates an empty file. The size is noted, but the disk blocks are not allocated until data is written to them. |
| -v | Verbose. Reports the names and sizes of created files. |
Use the -n option only when creating an NFS swap file.
You can create a swap file without root permissions, but it is a good idea for root to be the owner of the swap file to avoid accidental overwriting.
# mkfile nnn[k|b|m] filename |
The swap file of the size nnn (in Kbytes, bytes, or Mbytes) and name you specify is created.
# /usr/sbin/swap -a /path/filename |
You must use the absolute path name to specify the swap file. The swap file is added and available until the file system is unmounted, the system is rebooted, or the swap file is removed. Keep in mind that you can't unmount a file system while some process or program is swapping to the swap file.
| /path/filename - - swap - no - |
$ /usr/sbin/swap -l |
The following examples shows how to create a 24 Mbyte swap file called /files/swapfiles.
# mkdir /files # mkfile 24m /files/swapfile # swap -a /files/swapfile # vi /etc/vfstab (An entry is added for the swap file): /files/swapfile - - swap - no - # swap -l swapfile dev swaplo blocks free /dev/dsk/c0t2d0s1 32,17 8 205624 192704 /files/swapfile - 8 40952 40952 |
If the user no longer needs the extra swap space, you can remove it.
| # /usr/sbin/swap -d /path/filename |
The swap file name is removed from the list so that it is no longer available for swapping. The file itself is not deleted.
# rm swap-filename |
If the swap space is a file, remove it. Or, if the swap space is on a separate slice and you are sure you will not need it again, make a new file system and mount the file system.
See Chapter 36, Mounting and Unmounting File Systems (Tasks) for information on mounting a file system.
The following examples shows how to delete the /files/swapfile swap file.
# swap -d /files/swapfile # (Remove the deleted swap entry from the /etc/vfstab file) # rm /files/swapfile # swap -l swapfile dev swaplo blocks free /dev/dsk/c0t2d0s1 32,17 8 205624 192720 |
Supporting Multiple Page Sizes in the Solaris Operating System
Beginning with the Solaris 9 OS, multiple page sizes can be supported on UltraSPARC processors so administrators can optimize performance by changing the page size on behalf of an application. Typical performance measurement tools do not provide sufficient detail for evaluating the impact of page size and do not provide the needed support to make optimal page size choices.
This article explains how to use new tools to determine the potential performance gain. In addition, it explains how to configure larger page sizes using the multiple page size support (MPSS) feature of the Solaris 9 OS. The article addresses the following topics:
- "Understanding Why Virtual-to-Physical Address Translation Affects Performance"
- "Working With Multiple Page Sizes in the Solaris OS"
- "Configuring for Multiple Page Sizes"
Solaris Tunable Parameters Reference Manual
Getting to know the Solaris filesystem, Part 3 - SunWorld - July 1999
Getting the Best AIPS Performance from Solaris
Copyright © 1996-2008 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.
Standard disclaimer: The statements, views and opinions presented on this web page are those of the author and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.
Last modified: June 05, 2008