Table of contentsThe AIX® virtual memory manager (AIX VMM) is a page-based virtual memory manager. A page is a fixed-size block of data. A page might be resident in memory (that is, mapped into a location in physical memory), or a page might be resident on a disk (that is, paged out of physical memory into paging space or a file system). One unique aspect of the AIX VMM is the management of cached file data. The AIX VMM integrates cached file data with the management of other types of virtual memory (for example, process data, process stack, and so forth). It caches the file data as pages, just like virtual memory for processes. AIX maps pages into real memory based on demand. When an application references a page that is not mapped into real memory, the system generates a page fault. To resolve the page fault, the AIX kernel loads the referenced page to a location in real memory. If the referenced page is a new page (that is, a page in a data heap of the process that has never been previously referenced), "loading" the referenced page simply means filling a real memory location with zeros (that is, providing a zero-filled page). If the referenced page is a pre-existing page (that is, a page in a file or a previously paged out page), loading the referenced page involves reading the page from the disk (paging space or disk file system) into a location in real memory. Once a page is loaded into real memory, it is marked as unmodified. If a process or the kernel modifies the page, the state of the page changes to modified. This allows AIX to keep track of whether a page has been modified after it was loaded into memory. As the system adds more pages into real memory, the number of empty locations in real memory that can contain pages decreases. You can also refer to the number of empty locations as the number of free page frames. When the number of free page frames gets to a low value, the AIX kernel must empty out some locations in real memory for reuse of new pages. This process is otherwise known as page replacement. The AIX VMM has background daemons responsible for doing page replacement. A page
replacement daemon is referred to as
The page replacement daemons target different types of pages for eviction based on system memory usage and tunable parameters. The remainder of this article provides details on how the page replacement daemons target pages for eviction. Fundamentally, there are two types of pages on AIX:
Working storage pages are pages that contain volatile data (in other words, data that is not preserved across a reboot). On other platforms, working storage memory is sometimes referred to as anonymous memory. Examples of virtual memory regions that consist of working storage pages are:
When modified working storage pages need to be paged out (moved from memory to the disk), they are written to paging space. Working storage pages are never written to a file system. When a process exits, the system releases all of its private working storage pages. Thus, the system releases the working storage pages for the data of a process and stack when the process exits. The working storage pages for shared memory regions are not released until the shared memory region is deleted. Permanent storage pages are pages that contain permanent data (that is, data that is preserved across a reboot). This permanent data is just file data. So, permanent storage pages are basically just pieces of files cached in memory. When a modified permanent storage page needs to be paged out (moved from memory to disk), it is written to a file system. As mentioned earlier, an unmodified permanent storage page can just be released without being written to the file system, since the file system contains a pristine copy of the data. For example, if an application is reading a file, the file data is cached in memory in permanent storage pages. These permanent storage pages are unmodified, meaning that the pages have not been modified in memory. So, the in-memory permanent storage pages are equivalent to the file data on the disk. When AIX needs to free up memory, it can just "release" these pages without having to write anything to disk. If the application had been doing writes to the file instead of reads, the permanent storage pages would be "modified," and AIX would have to flush the pages to disk before releasing the pages. You can divide permanent storage pages into two sub-types:
Non-client pages are pages containing cached Journaled File System (JFS) file data. Non-client pages are sometimes referred to as persistent pages. Client pages are pages containing cached data for all other file systems (for example, JFS2 and Network File System (NFS)). In order to help optimize which pages are selected for replacement by the page replacement daemons, AIX classifies pages into one of two types:
Computational pages are pages used for the text, data, stack, and shared memory of a process. Non-computational pages are pages containing file data for files that are being read and written. All working storage pages are computational. A working storage page is never marked as non-computational. Depending on how you use the permanent storage pages, the pages can be computational or non-computational. If a file contains executable text for a process, the system treats the file as computational and marks all of the permanent storage pages in the file as computational. If the file does not contain executable text, the system treats the file as non-computational file and marks all of the pages in the file as non-computational. When you first open a file, the AIX kernel creates an internal VMM object to represent the file. It marks it as non-computational, meaning all files start out as non-computational. As a program does reads and writes to the file, the AIX kernel caches the file's data in memory as non-computational permanent storage pages. If the file is closed, the AIX kernel continues to cache the file data in memory (in permanent storage pages). The kernel continues to cache the file for performance; for example, if another process comes along later and uses the same file, the file data is still in memory, and the AIX kernel does not have to read the file data in from disk. When a page fault is taken on a file due to an instruction fetch, only the non-computational file transitions to the computational state. When a process page faults on a file (meaning the process references a part of the file that is not currently cached in memory in a permanent storage page), the process generates a page fault. If the page fault is due to an instruction fetch (meaning the process was trying to load an instruction from the page to execute), the kernel marks the file as computational. This involves marking all pages in the file as computational. A file is either completely computational or non-computational. Once a file has been marked as computational, it remains marked as a computational file until the file is deleted (or the system is rebooted). Thus, a file remains marked as computational even after it is moved or renamed. The AIX page replacement daemons scan memory a page at a time to find pages to evict in order to free up memory. The page replacement daemons must choose pages carefully to minimize the performance impact of paging on the system, and the page replacement daemons target pages of different classes based on tunable parameter settings and system conditions. There are a number of tunable parameters that you can use to control how AIX selects pages to replace. The two most basic page replacement tunable parameters are
By default, The The number of non-computational pages is referred to as
Figure 1 below gives an overview of how these tunable parameters work under different system conditions: Figure 1. minperm and maxperm limitsWhen the number of non-computational pages ( When the number of non-computational pages ( When the number of non-computational pages ( Figure 2. lru_file_repage tunable parameter When The AIX kernel maintains a re-paging table in order to identify pages that are
paged out and then quickly paged back in. When the kernel pages a page out and
then pages it back in, it usually indicates that there is strong demand for the
page and that the page should stay in memory. The kernel maintains an indication
of how many times it re-pages computational pages and how many times it re-pages
non-computational pages. The AIX kernel can then use this information to determine
which class of pages is being re-paged more heavily (thus, indicating which class
of pages is experiencing higher demand). When the
In most customer environments, it is most optimal to just have the kernel always
target non-computational pages, because paging computational pages (for example, a
process’s stack, data, and so forth) usually has a much higher performance cost on
a process than paging non-computational pages (that is, data file cache). Thus,
the In addition to the The number of non-computational client pages is referred to as
By default, the Monitoring a system's memory usage AIX provides several tools for providing information about counts of the different pages on the system. The The Listing 1. vmstat -v
command
So, in the above example, there are 16529 non-computational file pages mapped into memory. These non-computational pages consume 2.2 percent of memory. Of these 16529 non-computational file pages, 16503 of them are client pages. The Another command that can be used to display information about a system’s memory
usage is the The Listing 2. -G option
to svmon command
To understand how a system’s real memory is being used,
For each page type,
So, in the above example, there are 188426 working storage pages mapped into memory. Of those 188426 working storage pages, 133537 of them are pinned (that is, can’t be paged out). There are no persistent storage pages (because there are no JFS filesystems in use on the system). There are 21284 client storage pages, and none of them are pinned. The
The type of information reported by In contrast, To illustrate this difference, consider the above example of
Displaying and setting tunable parameters The To display the current values of all VMM tunable parameters, run the
To display the current values of select VMM tunable parameters, use the
Listing 3. Tunable parameters
Table 1. Tunable parameters: Column descriptions
The Listing 4. -p option
Suggested tunable parameter settings The vast majority of workloads benefit from the VMM page replacement daemons targeting non-computational pages. Thus, the following suggested tunable parameters provide the best performance for the majority of workloads (see Listing 5): Listing 5. Tunable parameters with best performance
These tunable parameters can be set with the Listing 6. Tunable parameters set with the vmo command
The settings can be viewed with the These tunable parameter settings apply to AIX Version 5.2 and AIX Version 5.3. To set these tunable parameters on AIX Version 5.2, AIX Version 5.2 TL6 or later is required. To set the above tunable parameters on AIX Version 5.3, AIX Version 5.3 TL1 or later is required. The above tunable parameters settings are the default settings for AIX Version 6.1. The AIX VMM classifies pages based on use. You can use system tunable parameters to control the behavior of the AIX page replacement daemons and control how AIX treats different classes of pages page replacement. Tuning the AIX VMM can result in significant performance improvements for workloads. Learn
Get products and technologies
Discuss
David is an AIX kernel architect. His responsibilities include designing and developing new technology for the AIX operating system. His background is in kernel development. You can contact him at dhepkin@us.ibm.com. |
|
来自: Stefen > 《Memory Management》