X

Alan Hargreaves's Weblog

How much disk based swap am I using?

Alan Hargreaves
Senior Principal Technical Support Engineer

I got passed a call today where the customer was concerned that they were using 65% of their available swap. Given that the machine had 128gb of memory and about 16gb free they were concerned at what may be using swap.

The output that lead to the concern was:

$ swap -s
total: 6515808k bytes allocated + 3248840k reserved = 9764648k used, 102445552k available

From this output it would be easy to assume that we are using 6.2 gb of swap and the customer knew that they only had an 8gb swap volume.

The part that is often overlooked is the available amount. If we add available and used we end up with 107gb. That's substantially larger than the swap volume size.

What is going on here?

First some definitions from "Solaris Internals"



Reserved

Virtual swap space is reserved for an entire segment. Reservation
occurs when a segment is created with private/read/write access. The
reservation represents the virtual size of the area being created.

Allocated

Virtual swap space is allocated when the first physical page is
assigned to it. At that point, a swapfs vnode and offset are assigned
against the anon slot.

Swapped out (used swap)

When a memory shortage occurs, a page may be swapped out by the page
scanner. Swap-out happens when the page scanner calls swapfs_putpage
for the page in question. The page is migrated to physical (disk or
file) swap.

and a few from swap(1M)



Allocated

The total amount of swap space in bytes currently allocated for use
as backing store.

Reserved

The total amount of swap space in bytes not currently allocated, but
claimed by memory mappings for possible future use.

Used(Often referred as “reserved”)

The total amount of swap space in bytes that is either allocated or
reserved.

Available

The total swap space in bytes that is currently available for future
reservation and allocation.

Solaris uses all available pageable memory as virtual swap space in
addition to the disk-based swap space.

The amount of virtual swap space available is the amount of available
pageable physical memory plus the amount of disk-based swap space
available.

Solaris reserves the virtual swap space from the disk- based swap
first. Only if disk-based swap is exhausted or unconfigured, the
reservation is done from physical memory.

"swap -s" reports on "virtual swap". To look at the actual amount of disk
based swap in use we need to look at "swap -l".

In this case we see

$ swap -l
swapfile dev swaplo blocks free
/dev/zvol/dsk/rpool/swap 256,1 16 16777200 16777200

The crucial take away in this output is that blocks == free. This means that we are not using any disk based swap.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.