Maintaining an ample supply of free pages for the system is a key duty of the kernel; to this end, the kernel symbol freemem contains the total number of page frames currently on a free list. When memory pressure is high, there are relatively few free pages on the free lists, and the kernel must take corrective action. Figure 7-1 gives us an overall view of the free-page monitoring system. Figure 7-1. Lotsfree The total amount of memory available to the operating system is determined at boot and stored in the kernel parameter phys_mem_pages. Additional setpoints are calculated and continuously monitored by the kernel. lotsfree The tunable parameter lotsfree sets the point at which the paging system is first called into action. If the number of free pages, freemem, is above lotsfree, then the paging system has nothing to do. The default value for lotsfree depends on the amount memory configured for the system. For systems with 32 MB to 2 GB of physical memory, lotsfree will be 1/16 of the non-kernel memory, not to exceed 8192 pages (32 MB). For systems with more than 2 GB, lotsfree is set to 16,384 pages (64 MB). desfree The tunable parameter desfree sets the minimum desired number of free system pages. When the number of free pages drop below this limit, the vhand agents are already working at their maximum rate. The swapper starts evaluating processes for potential deactivation, but no deactivations take place yet. For systems with 32 MB to 2 GB of memory, desfree is set to 1/64 of non-kernel memory, not to exceed 1024 pages (4 MB). For systems with more than 2 GB of memory, desfree is set to 3072 pages (12 MB). minfree When the tunable parameter minfree's limit is hit, things are really tight, supply is not keeping up with demand by any stretch of the imagination. In terms of memory availability, we are in the 11th hour, so the kernel asks the swapper to start process deactivations. Hopefully, this action will get freemem back into an acceptable range. For systems with 32 MB to 2 GB of memory, minfree is set to 1/4 of desfree, not to exceed 256 pages. For systems with more than 2 GB of memory, minfree is set to 1280 pages (5 MB). gpgslim At boot time, this parameter is set to 1/4 of the way between desfree and lotsfree. When freemem drops below lotsfree, the vhand daemon is started, but at this time it only ages pages no stealing is done. If freemem drops below gpgslim, then the other half of vhand is activated, and it steals stale pages. The kernel adjusts gpgslim between lotsfree and desfree in accordance with recent current trends in memory pressure. (In earlier versions of HP-UX this parameter was tunable.) Other Kernel Paging Parameters There are several other kernel parameters we need to mention: freemem (calculated): This is the current free page count for the system, the number of page frames on all the free lists. parolemem (calculated): This is the count of pages pending page-out operations at this time. vhandrunrate (tunable): This is the number of times per second the kernel will kick off the vhand daemon if the free page count (freemem plus parolemem) has dropped below lotsfree. The default is 8. memzeroperiod (tunable): This parameter, in .1 second increments, determines how often gpgslim is adjusted by the kernel. Every 2 * memzeroperiod seconds or if freemem has reached zero more than two times, gpgslim is adjusted. The formula for this adjustment is [3 * gpgslim + (lotsfree)/4] if freemem has reached its target limit within memzeroperiod and [3 * gpgslim + (desfree)/4] if freemem has not reached its target limit within memzeroperiod. The default value is 30, or every 3 seconds. hitzerofreemem (kernel): The number of times freemem has hit zero in the last memzeroperiod. targetcpu (tunable): This represents the maximum number of CPU cycles we are willing to allocate to the vhand daemon. The default is 100 ticks, or 10 percent of the total CPU time. maxqueuetime (tunable): This number controls the pending parolemem queue depth. The value is in .1 seconds and defaults to 10. This means that the system will attempt to keep the page-out queue to no more than the system can handle in 1 second. pageoutcnt (counter): This is a count of recent kernel- and user-requested page-outs. kpageoutcnt (counter): This is the number of recently completed kernel-requested page-outs (vhand). pageoutrate (calculated): This is the current total page-out rate. kpageoutrate (calculated): This is the current vhand page-out rate. maxpendpageouts (calculated): pageoutrate * (maxqueuetime/10). pgrateupdate (tunable): Number of seconds to copy curr_pgrate to max_pgrate; defaults to 60. curr_pgrate (counter): Maximum kpageoutrate seen in the current period. max_pgrate (calculated): Maximum kpageoutrate seen in the last pgrateupdate period. This is an indicator of possible page thrashing if it is high and the CPU utilization rate is low. agehand (kernel): This is a pointer to the next pregion in which vhand may age (scan) pages. stealhand (kernel): This is a pointer to the next pregion in which vhand may steal pages. agerate (kernel): This is the age quota assigned by the swapper to vhand for its next run. stealrate (kernel): This is the steal quota assigned by the swapper to vhand for its next run. handlaps (kernel): This it the desired amount of lag between the scanning operation and the stealing operation in a pregion. targetlaps (kernel): This it the actual amount of lag between the scanning operation and the stealing operation in a pregion. vhandinfoticks (adb tunable): This parameter should only be set using adb (by a very knowledgeable user). If it is a nonzero value, then every vhandinfoticks vhand prints a status report out to the system console, including the current values of handlaps, targetlaps, agerate, gpgslim, parolemem, stealrate, and freemem. The vhandrunrate sets flags in the kernel to call schedpaging() at the appropriate rate. This routines checks the current value of freemem, and if it has fallen below lotsfree (or gpgslim in an extreme case), the vhand daemon is called. Let's examine vhand in detail. |