Skip to main content

IBM Systems  >   System z  >   z/VM  >  

Should Linux Swap to a Virtual Disk In Storage (VDISK)?

To explore swapping to VDISK, first we need to look at what happens when your Linux guest swaps. Next we examine administrative characteristics of VDISK. Finally, we look at considerations for storage-rich and storage-constrained systems.

Note that while the phrases "swap disk" and "swapping" are often used in describing Linux, we should remember that Linux does not swap process spaces in the traditional sense, but instead does paging based on least recently used algorithms. For historical reasons, the term swap is still shown and used, but it refers to paging in Linux. The term swap is also used to help delineate paging at the Linux level (swap disk), in contrast to paging at the z/VM level.

What Happens When Your Linux Guest Swaps

When a Linux guest swaps (pages), it is doing I/O to its swap DASD in support of the virtualization of its memory. This means:

  • The Linux guest is incurring guest path length and I/O latency because it is doing swap I/O.
  • z/VM is incurring Control Program path length and I/O latency on behalf of the guest when it does the I/O to the swap DASD on behalf of the guest.
These factors combine to produce protracted response time and decreased transaction rates for Linux. Further, they have an effect no matter what the target device is.

Administrative Aspects of VDISK

A VDISK makes a very attractive swap device from an administration point of view. It is easy to set up a VDISK, in fact, usually your z/VM system administrator does not need to be involved. The CP DEFINE command or a user directory statement can be employed to set up a VDISK.

Performance Effects of Swapping to VDISK

Swapping to VDISK has potential for improving system performance. It can also be detrimental to performance. Following are the considerations one must keep in mind.

Because pages that back the virtual disk blocks of a VDISK are only created if the virtual disk block is created. It can be advantageous to define multiple VDISKs as swap space instead of a single large VDISK. You would also configure Linux to use the first VDISK higher in its hierarchy. This will allow Linux to reuse freed disk blocks on the first VDISK before moving onto the next one. This may lower the total number of pages representing the VDISKs to be backed by z/VM.

Storage-Rich Systems

If your system has plenty of real storage, you can reduce latency in Linux swap I/O by putting the Linux swap volume on a VDISK. The VDISK is a very fast I/O device when its disk blocks, implemented as pages in an address space, can remain memory-resident.

Note that using a VDISK does not change the other I/O behaviors of Linux or z/VM. Linux must still form and emit I/Os to read and write the swap extent, and z/VM must still perform these I/Os for the guest.

Storage-Constrained Systems

Though the pages backing the VDISK blocks themselves are not created until referenced, the architected control blocks for dynamic address translation (page tables and segment tables, mainly) are created at the time the VDISK is created. Further, these control blocks are not pageable.

The VM storage management steal processing has a hierarchy of pages that it uses in trying to select the most appropriate pages. In that hierarchy, normal idle guest pages are chosen for steal more readily than VDISK pages (a virtual disk in storage page is implemented as a system utility space and therefore is given preferential treatment). As Linux guests go idle, this hierarchy might have an undesireable effect. Linux will determine an unused page and move it out to its swap disk (a VDISK). If the Linux guest goes idle, VM storage management will steal more aggressively from the guest pages (pages Linux decided it needed) and less aggressively from the VDISK (pages Linux decided it was safe to page out). This is counter to what good performance would dictate.

You can tell whether you are storage-constrained by using Performance Toolkit, as illustrated in the table below.

Assessment Performance Toolkit
Paging, generally Option 3A, PAG selection
DASD activity Option 13, DEV selection
Channel activity Option 11, CHAN selection


Back to the Performance Tips Page