aboutsummaryrefslogtreecommitdiff
path: root/sys/vm/vm_kern.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC: r1.75 - don't deadlock if the system is low on physical memory andTor Egge2002-03-121-0/+12
| | | | | | | malloc is called with both size > PAGE_SIZE and the M_NOWAIT flag set. Notes: svn path=/stable/4/; revision=92159
* MFC: pmap interface optimizations, optionally physically backed SYSVSHM.Peter Wemm2000-08-041-2/+1
| | | | Notes: svn path=/stable/4/; revision=64259
* useracc() the prequel:Poul-Henning Kamp1999-10-291-1/+0
| | | | | | | | | | | | | | Merge the contents (less some trivial bordering the silly comments) of <vm/vm_prot.h> and <vm/vm_inherit.h> into <vm/vm.h>. This puts the #defines for the vm_inherit_t and vm_prot_t types next to their typedefs. This paves the road for the commit to follow shortly: change useracc() to use VM_PROT_{READ|WRITE} rather than B_{READ|WRITE} as argument. Notes: svn path=/head/; revision=52635
* Remove the last vestiges of "vm_map_t phys_map". It's been unusedAlan Cox1999-10-291-1/+0
| | | | | | | since i386/i386/machdep.c rev 1.45 (or 1994 :-) ). Notes: svn path=/head/; revision=52617
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Remove the declarations for "vm_map_t io_map". It's been unusedAlan Cox1999-08-151-2/+1
| | | | | | | since i386/i386/machdep rev 1.310, i.e., the demise of BOUNCE_BUFFERS. Notes: svn path=/head/; revision=49858
* Remove the declarations for "vm_map_t u_map". It's been unusedAlan Cox1999-08-151-2/+1
| | | | | | | since i386/i386/pmap rev 1.190. (The alpha never used it.) Notes: svn path=/head/; revision=49852
* Fix some int/long printf problems for the AlphaPeter Wemm1999-07-011-3/+3
| | | | Notes: svn path=/head/; revision=48409
* Add a function kmem_alloc_nofault() - same as kmem_alloc_pageable(), butDmitrij Tejblum1999-06-081-1/+25
| | | | | | | | | create a nofault entry. It will be used to allocate kmem for upages. (I am not too happy with all this, but it's better than nothing). Notes: svn path=/head/; revision=47841
* Correct a problem in kmem_malloc: A kmem_malloc allowing "wait" mayAlan Cox1999-03-161-3/+5
| | | | | | | | | block (VM_WAIT) holding the map lock. This is bad. For example, a subsequent kmem_malloc by an interrupt handler on the same map may find the lock held and panic in the lockmgr. Notes: svn path=/head/; revision=44793
* Remove vm_page_frees from kmem_malloc that are performedAlan Cox1999-03-121-7/+1
| | | | | | | by vm_map_delete/vm_object_page_remove anyway. Notes: svn path=/head/; revision=44682
* Potential bug fix, do not just clear PG_BUSY... call vm_page_wakeup()Matthew Dillon1999-01-211-1/+1
| | | | | | | | | | instead to properly handle any waiters. Added comments, added support for M_ASLEEP. Generally treat M_ flags as flags instead of constants to compare against. Notes: svn path=/head/; revision=42969
* This is a rather large commit that encompasses the new swapper,Matthew Dillon1999-01-211-24/+54
| | | | | | | | | | | | | changes to the VM system to support the new swapper, VM bug fixes, several VM optimizations, and some additional revamping of the VM code. The specific bug fixes will be documented with additional forced commits. This commit is somewhat rough in regards to code cleanup issues. Reviewed by: "John S. Dyson" <root@dyson.iquest.net>, "David Greenman" <dg@root.com> Notes: svn path=/head/; revision=42957
* Cosmetic changes to the PAGE_XXX macros to make them consistent withDoug Rabson1998-09-041-5/+5
| | | | | | | the other objects in vm. Notes: svn path=/head/; revision=38799
* Change various syscalls to use size_t arguments instead of u_int.Doug Rabson1998-08-241-4/+4
| | | | | | | | | | | | | Add some overflow checks to read/write (from bde). Change all modifications to vm_page::flags, vm_page::busy, vm_object::flags and vm_object::paging_in_progress to use operations which are not interruptable. Reviewed by: Bruce Evans <bde@zeta.org.au> Notes: svn path=/head/; revision=38517
* Removed unused includes.Bruce Evans1998-06-211-2/+1
| | | | Notes: svn path=/head/; revision=37094
* Changed the log() of "Out of mbuf clusters - increase maxusers" to aDavid Greenman1998-06-051-2/+2
| | | | | | | | | printf() of "Out of mbuf clusters - adjust NMBCLUSTERS or increase maxusers" so that the message is more informative and so that it will appear in the kernel message buffer. Notes: svn path=/head/; revision=36677
* 1) Use a more consistent page wait methodology.John Dyson1998-03-011-2/+2
| | | | | | | | | | | | | | | | 2) Do not unnecessarily force page blocking when paging pages out. 3) Further improve swap pager performance and correctness, including fixing the paging in progress deadlock (except in severe I/O error conditions.) 4) Enable vfs_ioopt=1 as a default. 5) Fix and enable the page prezeroing in SMP mode. All in all, SMP systems especially should show a significant improvement in "snappyness." Notes: svn path=/head/; revision=33936
* Significantly improve the efficiency of the swap pager, which appears toJohn Dyson1998-02-231-5/+6
| | | | | | | | | | | have declined due to code-rot over time. The swap pager rundown code has been clean-up, and unneeded wakeups removed. Lots of splbio's are changed to splvm's. Also, set the dynamic tunables for the pageout daemon to be more sane for larger systems (thereby decreasing the daemon overheadla.) Notes: svn path=/head/; revision=33758
* Back out DIAGNOSTIC changes.Eivind Eklund1998-02-061-3/+1
| | | | Notes: svn path=/head/; revision=33134
* 1) Start using a cleaner and more consistant page allocator insteadJohn Dyson1998-02-051-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | of the various ad-hoc schemes. 2) When bringing in UPAGES, the pmap code needs to do another vm_page_lookup. 3) When appropriate, set the PG_A or PG_M bits a-priori to both avoid some processor errata, and to minimize redundant processor updating of page tables. 4) Modify pmap_protect so that it can only remove permissions (as it originally supported.) The additional capability is not needed. 5) Streamline read-only to read-write page mappings. 6) For pmap_copy_page, don't enable write mapping for source page. 7) Correct and clean-up pmap_incore. 8) Cluster initial kern_exec pagin. 9) Removal of some minor lint from kern_malloc. 10) Correct some ioopt code. 11) Remove some dead code from the MI swapout routine. 12) Correct vm_object_deallocate (to remove backing_object ref.) 13) Fix dead object handling, that had problems under heavy memory load. 14) Add minor vm_page_lookup improvements. 15) Some pages are not in objects, and make sure that the vm_page.c can properly support such pages. 16) Add some more page deficit handling. 17) Some minor code readability improvements. Notes: svn path=/head/; revision=33109
* Turn DIAGNOSTIC into a new-style option.Eivind Eklund1998-02-041-1/+3
| | | | Notes: svn path=/head/; revision=33108
* Change the busy page mgmt, so that when pages are freed, theyJohn Dyson1998-01-311-2/+1
| | | | | | | | | | | | | | | | | MUST be PG_BUSY. It is bogus to free a page that isn't busy, because it is in a state of being "unavailable" when being freed. The additional advantage is that the page_remove code has a better cross-check that the page should be busy and unavailable for other use. There were some minor problems with the collapse code, and this plugs those subtile "holes." Also, the vfs_bio code wasn't checking correctly for PG_BUSY pages. I am going to develop a more consistant scheme for grabbing pages, busy or otherwise. For now, we are stuck with the current morass. Notes: svn path=/head/; revision=32937
* VM level code cleanups.John Dyson1998-01-221-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1) Start using TSM. Struct procs continue to point to upages structure, after being freed. Struct vmspace continues to point to pte object and kva space for kstack. u_map is now superfluous. 2) vm_map's don't need to be reference counted. They always exist either in the kernel or in a vmspace. The vmspaces are managed by reference counts. 3) Remove the "wired" vm_map nonsense. 4) No need to keep a cache of kernel stack kva's. 5) Get rid of strange looking ++var, and change to var++. 6) Change more data structures to use our "zone" allocator. Added struct proc, struct vmspace and struct vnode. This saves a significant amount of kva space and physical memory. Additionally, this enables TSM for the zone managed memory. 7) Keep ioopt disabled for now. 8) Remove the now bogus "single use" map concept. 9) Use generation counts or id's for data structures residing in TSM, where it allows us to avoid unneeded restart overhead during traversals, where blocking might occur. 10) Account better for memory deficits, so the pageout daemon will be able to make enough memory available (experimental.) 11) Fix some vnode locking problems. (From Tor, I think.) 12) Add a check in ufs_lookup, to avoid lots of unneeded calls to bcmp. (experimental.) 13) Significantly shrink, cleanup, and make slightly faster the vm_fault.c code. Use generation counts, get rid of unneded collpase operations, and clean up the cluster code. 14) Make vm_zone more suitable for TSM. This commit is partially as a result of discussions and contributions from other people, including DG, Tor Egge, PHK, and probably others that I have forgotten to attribute (so let me know, if I forgot.) This is not the infamous, final cleanup of the vnode stuff, but a necessary step. Vnode mgmt should be correct, but things might still change, and there is still some missing stuff (like ioopt, and physical backing of non-merged cache files, debugging of layering concepts.) Notes: svn path=/head/; revision=32702
* Get rid of the ad-hoc memory allocator for vm_map_entries, in lieu ofJohn Dyson1997-08-051-1/+2
| | | | | | | | a simple, clean zone type allocator. This new allocator will also be used for machine dependent pmap PV entries. Notes: svn path=/head/; revision=27899
* Removed unused #includes.Bruce Evans1997-08-021-5/+1
| | | | Notes: svn path=/head/; revision=27845
* Kill some stale leftovers from the earlier attempts at SMP per-cpu pagesPeter Wemm1997-06-221-6/+1
| | | | Notes: svn path=/head/; revision=26811
* Update the #include "opt_smpxxx.h" includes - opt_smp.h isn't neededPeter Wemm1997-05-291-2/+1
| | | | | | | very much in the generic parts of the kernel now. Notes: svn path=/head/; revision=26258
* Man the liferafts! Here comes the long awaited SMP -> -current merge!Peter Wemm1997-04-261-1/+7
| | | | | | | | | | | | | | | | | | | There are various options documented in i386/conf/LINT, there is more to come over the next few days. The kernel should run pretty much "as before" without the options to activate SMP mode. There are a handful of known "loose ends" that need to be fixed, but have been put off since the SMP kernel is in a moderately good condition at the moment. This commit is the result of the tinkering and testing over the last 14 months by many people. A special thanks to Steve Passe for implementing the APIC code! Notes: svn path=/head/; revision=25164
* Changed the way that the exec image header is read to be filesystem-David Greenman1997-03-311-2/+1
| | | | | | | | | | centric rather than VM-centric to fix a problem with errors not being detectable when the header is read. Killed exech_map as a result of these changes. There appears to be no performance difference with this change. Notes: svn path=/head/; revision=24437
* Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are notPeter Wemm1997-02-221-1/+1
| | | | | | | ready for it yet. Notes: svn path=/head/; revision=22975
* This is the kernel Lite/2 commit. There are some requisite userlandJohn Dyson1997-02-101-1/+1
| | | | | | | | | | | | | | | | | | changes, so don't expect to be able to run the kernel as-is (very well) without the appropriate Lite/2 userland changes. The system boots and can mount UFS filesystems. Untested: ext2fs, msdosfs, NFS Known problems: Incorrect Berkeley ID strings in some files. Mount_std mounts will not work until the getfsent library routine is changed. Reviewed by: various people Submitted by: Jeffery Hsu <hsu@freebsd.org> Notes: svn path=/head/; revision=22521
* Fix bug related to map entry allocations where a sleep might be attemptedDavid Greenman1997-01-151-11/+3
| | | | | | | | | | | when allocating memory for network buffers at interrupt time. This is due to inadequate checking for the new mcl_map. Fixed by merging mb_map and mcl_map into a single mb_map. Reviewed by: wollman Notes: svn path=/head/; revision=21737
* Make the long-awaited change from $Id$ to $FreeBSD$Jordan K. Hubbard1997-01-141-1/+1
| | | | | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise. Notes: svn path=/head/; revision=21673
* Eliminate the redundancy due to the similarity between the routinesJohn Dyson1996-12-281-7/+3
| | | | | | | | | | vm_map_simplify and vm_map_simplify_entry. Make vm_map_simplify_entry handle wired maps so that we can get rid of vm_map_simplify. Modify the callers of vm_map_simplify to properly use vm_map_simplify_entry. Submitted by: Alan Cox <alc@cs.rice.edu> Notes: svn path=/head/; revision=20993
* Improve the locality of reference for variables in vm_page andJohn Dyson1996-11-171-14/+14
| | | | | | | | vm_kern by moving them from .bss to .data. With this change, there is a measurable perf improvement in fork/exec. Notes: svn path=/head/; revision=19830
* Properly set the PG_MAPPED and PG_WRITEABLE flags. This fixes some potentialJohn Dyson1996-07-021-1/+2
| | | | | | | problems with vm_map_remove/vm_map_delete. Notes: svn path=/head/; revision=16892
* Eliminate a vm_page_free, busy panic, in kern_malloc.John Dyson1996-05-231-1/+2
| | | | Notes: svn path=/head/; revision=15876
* This set of commits to the VM system does the following, and containJohn Dyson1996-05-181-18/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | contributions or ideas from Stephen McKay <syssgm@devetir.qld.gov.au>, Alan Cox <alc@cs.rice.edu>, David Greenman <davidg@freebsd.org> and me: More usage of the TAILQ macros. Additional minor fix to queue.h. Performance enhancements to the pageout daemon. Addition of a wait in the case that the pageout daemon has to run immediately. Slightly modify the pageout algorithm. Significant revamp of the pmap/fork code: 1) PTE's and UPAGES's are NO LONGER in the process's map. 2) PTE's and UPAGES's reside in their own objects. 3) TOTAL elimination of recursive page table pagefaults. 4) The page directory now resides in the PTE object. 5) Implemented pmap_copy, thereby speeding up fork time. 6) Changed the pv entries so that the head is a pointer and not an entire entry. 7) Significant cleanup of pmap_protect, and pmap_remove. 8) Removed significant amounts of machine dependent fork code from vm_glue. Pushed much of that code into the machine dependent pmap module. 9) Support more completely the reuse of already zeroed pages (Page table pages and page directories) as being already zeroed. Performance and code cleanups in vm_map: 1) Improved and simplified allocation of map entries. 2) Improved vm_map_copy code. 3) Corrected some minor problems in the simplify code. Implemented splvm (combo of splbio and splimp.) The VM code now seldom uses splhigh. Improved the speed of and simplified kmem_malloc. Minor mod to vm_fault to avoid using pre-zeroed pages in the case of objects with backing objects along with the already existant condition of having a vnode. (If there is a backing object, there will likely be a COW... With a COW, it isn't necessary to start with a pre-zeroed page.) Minor reorg of source to perhaps improve locality of ref. Notes: svn path=/head/; revision=15809
* Allocate mbufs from a separate submap so that NMBCLUSTERS works asGarrett Wollman1996-05-101-4/+12
| | | | | | | expected. Notes: svn path=/head/; revision=15722
* This fixes kmem_malloc/kmem_free (and malloc/free of objects of > 8K).John Dyson1996-04-241-2/+2
| | | | | | | | A page index was calculated incorrectly in vm_kern, and vm_object_page_remove removed pages that should not have been. Notes: svn path=/head/; revision=15367
* Print a more descriptive message when the mb_map is filled (out of mbufDavid Greenman1996-01-311-2/+2
| | | | | | | clusters), and tell the operator what to do about it (increase maxusers). Notes: svn path=/head/; revision=13786
* Eliminated many redundant vm_map_lookup operations for vm_mmap.John Dyson1996-01-191-9/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Speed up for vfs_bio -- addition of a routine bqrelse to greatly diminish overhead for merged cache. Efficiency improvement for vfs_cluster. It used to do alot of redundant calls to cluster_rbuild. Correct the ordering for vrele of .text and release of credentials. Use the selective tlb update for 486/586/P6. Numerous fixes to the size of objects allocated for files. Additionally, fixes in the various pagers. Fixes for proper positioning of vnode_pager_setsize in msdosfs and ext2fs. Fixes in the swap pager for exhausted resources. The pageout code will not as readily thrash. Change the page queue flags (PG_ACTIVE, PG_INACTIVE, PG_FREE, PG_CACHE) into page queue indices (PQ_ACTIVE, PQ_INACTIVE, PQ_FREE, PQ_CACHE), thereby improving efficiency of several routines. Eliminate even more unnecessary vm_page_protect operations. Significantly speed up process forks. Make vm_object_page_clean more efficient, thereby eliminating the pause that happens every 30seconds. Make sequential clustered writes B_ASYNC instead of B_DELWRI even in the case of filesystems mounted async. Fix a panic with busy pages when write clustering is done for non-VMIO buffers. Notes: svn path=/head/; revision=13490
* Changes to support 1Tb filesizes. Pages are now named by anJohn Dyson1995-12-111-5/+8
| | | | | | | (object,index) pair instead of (object,offset) pair. Notes: svn path=/head/; revision=12767
* Restored used includes of <vm/vm_extern.h>.Bruce Evans1995-12-101-1/+2
| | | | Notes: svn path=/head/; revision=12726
* Untangled the vm.h include file spaghetti.David Greenman1995-12-071-1/+9
| | | | Notes: svn path=/head/; revision=12662
* Fixed up a comment and removed some #if 0'd code.David Greenman1995-11-131-8/+2
| | | | Notes: svn path=/head/; revision=12259
* Machine independent changes to support pre-zeroed free pages. ThisJohn Dyson1995-09-031-8/+6
| | | | | | | significantly improves demand-zero performance. Notes: svn path=/head/; revision=10548
* Eliminate sloppy common-style declarations. There should be none left forBruce Evans1995-07-291-3/+2
| | | | | | | the LINT configuation. Notes: svn path=/head/; revision=9759
* NOTE: libkvm, w, ps, 'top', and any other utility which depends on structDavid Greenman1995-07-131-14/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | proc or any VM system structure will have to be rebuilt!!! Much needed overhaul of the VM system. Included in this first round of changes: 1) Improved pager interfaces: init, alloc, dealloc, getpages, putpages, haspage, and sync operations are supported. The haspage interface now provides information about clusterability. All pager routines now take struct vm_object's instead of "pagers". 2) Improved data structures. In the previous paradigm, there is constant confusion caused by pagers being both a data structure ("allocate a pager") and a collection of routines. The idea of a pager structure has escentially been eliminated. Objects now have types, and this type is used to index the appropriate pager. In most cases, items in the pager structure were duplicated in the object data structure and thus were unnecessary. In the few cases that remained, a un_pager structure union was created in the object to contain these items. 3) Because of the cleanup of #1 & #2, a lot of unnecessary layering can now be removed. For instance, vm_object_enter(), vm_object_lookup(), vm_object_remove(), and the associated object hash list were some of the things that were removed. 4) simple_lock's removed. Discussion with several people reveals that the SMP locking primitives used in the VM system aren't likely the mechanism that we'll be adopting. Even if it were, the locking that was in the code was very inadequate and would have to be mostly re-done anyway. The locking in a uni-processor kernel was a no-op but went a long way toward making the code difficult to read and debug. 5) Places that attempted to kludge-up the fact that we don't have kernel thread support have been fixed to reflect the reality that we are really dealing with processes, not threads. The VM system didn't have complete thread support, so the comments and mis-named routines were just wrong. We now use tsleep and wakeup directly in the lock routines, for instance. 6) Where appropriate, the pagers have been improved, especially in the pager_alloc routines. Most of the pager_allocs have been rewritten and are now faster and easier to maintain. 7) The pagedaemon pageout clustering algorithm has been rewritten and now tries harder to output an even number of pages before and after the requested page. This is sort of the reverse of the ideal pagein algorithm and should provide better overall performance. 8) Unnecessary (incorrect) casts to caddr_t in calls to tsleep & wakeup have been removed. Some other unnecessary casts have also been removed. 9) Some almost useless debugging code removed. 10) Terminology of shadow objects vs. backing objects straightened out. The fact that the vm_object data structure escentially had this backwards really confused things. The use of "shadow" and "backing object" throughout the code is now internally consistent and correct in the Mach terminology. 11) Several minor bug fixes, including one in the vm daemon that caused 0 RSS objects to not get purged as intended. 12) A "default pager" has now been created which cleans up the transition of objects to the "swap" type. The previous checks throughout the code for swp->pg_data != NULL were really ugly. This change also provides the rudiments for future backing of "anonymous" memory by something other than the swap pager (via the vnode pager, for example), and it allows the decision about which of these pagers to use to be made dynamically (although will need some additional decision code to do this, of course). 13) (dyson) MAP_COPY has been deprecated and the corresponding "copy object" code has been removed. MAP_COPY was undocumented and non- standard. It was furthermore broken in several ways which caused its behavior to degrade to MAP_PRIVATE. Binaries that use MAP_COPY will continue to work correctly, but via the slightly different semantics of MAP_PRIVATE. 14) (dyson) Sharing maps have been removed. It's marginal usefulness in a threads design can be worked around in other ways. Both #12 and #13 were done to simplify the code and improve readability and maintain- ability. (As were most all of these changes) TODO: 1) Rewrite most of the vnode pager to use VOP_GETPAGES/PUTPAGES. Doing this will reduce the vnode pager to a mere fraction of its current size. 2) Rewrite vm_fault and the swap/vnode pagers to use the clustering information provided by the new haspage pager interface. This will substantially reduce the overhead by eliminating a large number of VOP_BMAP() calls. The VOP_BMAP() filesystem interface should be improved to provide both a "behind" and "ahead" indication of contiguousness. 3) Implement the extended features of pager_haspage in swap_pager_haspage(). It currently just says 0 pages ahead/behind. 4) Re-implement the swap device (swstrategy) in a more elegant way, perhaps via a much more general mechanism that could also be used for disk striping of regular filesystems. 5) Do something to improve the architecture of vm_object_collapse(). The fact that it makes calls into the swap pager and knows too much about how the swap pager operates really bothers me. It also doesn't allow for collapsing of non-swap pager objects ("unnamed" objects backed by other pagers). Notes: svn path=/head/; revision=9507