Annotation of 43BSDReno/share/doc/smm/13.kchanges/sys.vm.t, revision 1.1.1.1

1.1       root        1: .\" Copyright (c) 1986 Regents of the University of California.
                      2: .\" All rights reserved.  The Berkeley software License Agreement
                      3: .\" specifies the terms and conditions for redistribution.
                      4: .\"
                      5: .\"    @(#)sys.vm.t    1.8 (Berkeley) 4/11/86
                      6: .\"
                      7: .NH 2
                      8: Changes in the virtual memory system
                      9: .PP
                     10: The virtual memory system in 4.3BSD is largely unchanged from 4.2BSD.
                     11: The changes that have been made were in two areas: adapting the VM
                     12: substem to larger physical memories, and optimization by simplifying
                     13: many of the macros.
                     14: .PP
                     15: Many of the internal limits on the virtual memory system
                     16: were imposed by the \fIcmap\fP structure.
                     17: This structure was enlarged to increase those limits.
                     18: The limit on physical memory has been changed from 8 megabytes to 64 megabytes,
                     19: with expansion space provided for larger limits,
                     20: and the limit of 15 mounted file systems has been changed to 255.
                     21: The maximum file system size has been increased to 8 gigabytes,
                     22: number of processes to 65536,
                     23: and per-process size to 64 megabytes of data and 64 megabytes of stack.
                     24: Configuration parameters and other segment size limits were
                     25: converted from pages to bytes. 
                     26: Note that most of these are upper bounds;
                     27: the default limits for these quantities are tuned for systems
                     28: with 4-8 megabytes of physical memory.
                     29: The process region sizes may be adjusted
                     30: with kernel configuration file options;
                     31: for example,
                     32: .nf
                     33: .RS
                     34: .sp
                     35: options        MAXDSIZ=33554432
                     36: .sp
                     37: .RE
                     38: .fi
                     39: increases the data segment to 32 megabytes.
                     40: With no option, data segments receive a hard limit of roughly 17Mb
                     41: and a soft limit of 6Mb
                     42: (that may be increased with the csh limit command).
                     43: .PP
                     44: The global clock page replacement algorithm used to have a single
                     45: hand that was used both to mark and to reclaim memory.
                     46: The first time that it encountered a page it would clear its reference bit.
                     47: If the reference bit was still clear on its next pass across the page,
                     48: it would reclaim the page.
                     49: (On the VAX, the reference bit was simulated using the valid bit.)
                     50: The use of a single hand does not work well with large physical
                     51: memories as the time to complete a single revolution of the hand
                     52: can take up to a minute or more.
                     53: By the time the hand gets around to the marked pages,
                     54: the information is usually no longer pertinent.
                     55: During periods of sudden shortages,
                     56: the page daemon will not be able to find any reclaimable pages until
                     57: it has completed a full revolution.
                     58: To alleviate this problem,
                     59: the clock hand has been split into two separate hands.
                     60: The front hand clears the reference bits,
                     61: and the back hand follows a constant number of pages behind,
                     62: reclaiming pages that have have not been referenced since the front hand
                     63: passed.
                     64: While the code has been written in such a way as
                     65: to allow the distance between
                     66: the hands to be varied, we have not yet found any algorithms
                     67: suitable for determining how to dynamically adjust this distance.
                     68: The parameters determining the rate of page scan
                     69: have also been updated to reflect larger configurations.
                     70: The free memory threshold at which \fIpageout\fP begins was reduced
                     71: from one-fourth of memory to 512K
                     72: for machines with more than 2 megabytes of user memory.
                     73: The scan rate is now independent of memory size
                     74: instead of proportional to memory size.
                     75: .PP
                     76: The text table is now managed differently.
                     77: Unused entries are treated
                     78: as a cache, similar to the usage of the inode table.
                     79: Entries with reference counts of 0 are placed in an LRU cache
                     80: for potential reuse.
                     81: In effect, all texts are ``sticky,'' except that they are flushed
                     82: after a period of disuse or overflow of the table.
                     83: The sticky bit works
                     84: as before, preventing entries from being freed and locking
                     85: text files into the cache.
                     86: The code to prevent modification of running
                     87: texts was cleaned up by keeping a pointer to the text entry in the
                     88: inode, allowing texts to be freed when unlinking files without linear
                     89: searches.
                     90: .PP
                     91: The swap code was changed
                     92: to handle errors a bit better (\fIswapout\fP doesn't do \fIswkill\fPs, it just
                     93: reflects errors to the caller for action there).
                     94: During swapouts,
                     95: interrupts are now blocked for less time after freeing the pages
                     96: of the user structure and page tables
                     97: (as explained by the old comment from \fIswapout\fP,
                     98: ``XXX hack memory interlock''),
                     99: and this is now done only when swapping out the current process.
                    100: The same situation existed in \fIexit\fP, but had not yet been protected
                    101: by raised priority.
                    102: .PP
                    103: Various routines that took page numbers as arguments
                    104: now take \fIcmap\fP pointers instead to reduce the number of conversions.
                    105: These include \fImlink\fP, \fImunlink\fP, \fImlock\fP, \fImunlock\fP, and
                    106: \fImwait\fP.
                    107: \fIMlock\fP and \fImunlock\fP are generally used in their macro forms.
                    108: .PP
                    109: The remainder of the section details the other changes according to source
                    110: file.
                    111: .XP vm_mem.c
                    112: Low-level support for mapped files was removed,
                    113: as the descriptor field in the page table entry was too small.
                    114: Callers of \fImunhash\fP must block interrupts with \fIsplimp\fP
                    115: between checking for the presence of a block in the hash list
                    116: and removing it with \fImunhash\fP in order to avoid reallocation
                    117: of the page and a subsequent panic.
                    118: .XP vm_page.c
                    119: When filling a page from the text file, \fIpagein\fP uses a new routine,
                    120: \fIfodkluster\fP, to bring in additional pages that are contiguous
                    121: in the filesystem.
                    122: If errors occur while reading in text pages,
                    123: no page-table change is propagated to other users of the shared image,
                    124: allowing them to retry and notice the error
                    125: if they attempt to use the same page.
                    126: Virtual memory initialization code has been collected into \fIvminit\fP,
                    127: which adjusts swap interleaving to allow the configured size limits,
                    128: set up the parameters for the clock algorithm, and set the initial
                    129: virtual memory-related resource limits.
                    130: The limit to resident-set size is set to the size of the available user memory.
                    131: This change causes a single large process occupying most of memory
                    132: to begin random page replacement as memory resources run short.
                    133: Several races in \fIpagein\fP have been detected and fixed.
                    134: Most of the \fIpageout\fP code was moved to \fIcheckpage\fP
                    135: in implementing the two-handed clock algorithm.
                    136: .XP vm_proc.c
                    137: The \fIsetjmp\fP in \fIprocdup\fP was changed to \fIsavectx\fP,
                    138: which saves all registers, not just those needed to locate
                    139: the others on the stack.
                    140: .XP vm_pt.c
                    141: The \fIsetjmp\fP call in \fIptexpand\fP was changed to \fIsavectx\fP
                    142: to save all registers before initiating a swapout.
                    143: \fIVrelu\fP does an \fIsplimp\fP before freeing user-structure pages
                    144: if running on behalf of the current process.
                    145: This had been done by \fIswapout\fP before, but not by \fIexit\fP.
                    146: .XP vm_sched.c
                    147: The swap scheduler looks through the \fIallproc\fP list for processes
                    148: to swap in or out.
                    149: A call to \fIremrq\fP when swapping sleeping processes was unnecessary
                    150: and was removed.
                    151: If swapouts fail upon exhaustion of swap space,
                    152: \fIsched\fP does not continue to attempt swapouts.
                    153: .XP vm_subr.c
                    154: The \fIptetov\fP function and the unused \fIvtopte\fP function
                    155: were recoded without using the usual macros
                    156: in order to fold the similar cases together.
                    157: .XP vm_sw.c
                    158: The error returned by \fIswapon\fP when the device is not one of those
                    159: configured was changed from ENODEV to EINVAL for accuracy.
                    160: The search for the specified device begins with the first entry
                    161: so that the error is correct (EBUSY) when attempting to enable the primary
                    162: swap area.
                    163: .XP vm_swap.c
                    164: The \fIswapout\fP routine now leaves any \fIswkill\fP to its caller.
                    165: This avoids killing processes in a few situations.
                    166: It uses \fIxdetach\fP instead of \fIxccdec\fP.
                    167: Several unneeded \fIspl\fP's were deleted.
                    168: .XP vm_swp.c
                    169: The \fIswap\fP routine now consistently returns error status.
                    170: \fIPhysio\fP was modified to do scatter-gather I/O correctly.
                    171: .XP vm_text.c
                    172: The text routines use a text free list as a cache of text images,
                    173: resulting in numerous changes throughout this file.
                    174: \fIXccdec\fP now works only on locked text entries,
                    175: and is replaced by \fIxdetach\fP for external callers.
                    176: \fIXumount\fP frees unused swap images from all
                    177: devices when called with NODEV as argument.
                    178: It is no longer necessary to search the text table
                    179: to find any text associated with an inode in \fIxrele\fP,
                    180: as the inode stores a pointer to any text entry mapping it.
                    181: Statistics are gathered on the hit rate of the cache and its cost.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.