summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_mmap.c
Commit message (Collapse)AuthorAgeFilesLines
* Add support for 4MB pages. This includes the .text, .data, .data partsdyson1997-07-171-4/+8
| | | | | | | | of the kernel, and also most of the dynamic parts of the kernel. Additionally, 4MB pages will be allocated for display buffers as appropriate (only.) The 4MB support for SMP isn't complete, but doesn't interfere with operation either.
* Correct the return code for the mlock system call. Also add the stubsdyson1997-06-151-2/+32
| | | | for mlockall and munlockall.
* Don't #include <sys/fcntl.h> in <sys/file.h> if KERNEL is defined.bde1997-03-231-1/+2
| | | | | Fixed everything that depended on getting fcntl.h stuff from the wrong place. Most things don't depend on file.h stuff at all.
* Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are notpeter1997-02-221-1/+1
| | | | ready for it yet.
* This is the kernel Lite/2 commit. There are some requisite userlanddyson1997-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>
* Change the map entry flags from bitfields to bitmasks. Allowsdyson1997-01-161-1/+1
| | | | for some code simplification.
* Make the long-awaited change from $Id$ to $FreeBSD$jkh1997-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.
* Prepare better for multi-platform by eliminating another requireddyson1997-01-111-2/+4
| | | | | pmap routine (pmap_is_referenced.) Upper level recoded to use pmap_ts_referenced.
* Let the VM system know that on certain arch's that VM_PROT_READdyson1996-12-301-1/+13
| | | | | | | | | | | | | | also implies VM_PROT_EXEC. We support it that way for now, since the break system call by default gives VM_PROT_ALL. Now we have a better chance of coalesing map entries when mixing mmap/break type operations. This was contributing to excessive numbers of map entries on the modula-3 runtime system. The problem is still not "solved", but the situation makes more sense. Eventually, when we work on architectures where VM_PROT_READ is orthogonal to VM_PROT_EXEC, we will have to visit this issue carefully (esp. regarding security issues.)
* The code unnecessarily created an object with no handle up-front, whichdyson1996-12-281-5/+10
| | | | | | has the negative effect of disabling some map optimizations. This patch defers the creation of the object until it needs to be at fault time. Submitted by: Alan Cox <alc@cs.rice.edu>
* Make DFLDSIZ and MAXDSIZ fully-supported options.joerg1996-12-221-1/+3
| | | | "Don't forget to do a ``make depend''" :-)
* Implement closer-to POSIX mlock semantics. The major difference isdyson1996-12-141-3/+3
| | | | | | | | | | that we do allow mlock to span unallocated regions (of course, not mlocking them.) We also allow mlocking of RO regions (which the old code couldn't.) The restriction there is that once a RO region is wired (mlocked), it cannot be debugged (or EVER written to.) Under normal usage, the new mlock code will be a significant improvement over our old stuff.
* Change mmap to use OBJT_DEFAULT instead of OBJT_SWAP by defaultdyson1996-10-291-2/+2
| | | | | for anonymous objects. The system will automatically change the type to SWAP if needed (for size or pageout reasons.)
* Remove a bogus optimization in the mmap code. It is superfluous,dyson1996-10-241-24/+5
| | | | | and at best is the same speed as the unoptimized code. At worst, it slows down trivial programs.
* Remove a stale comment.phk1996-10-131-2/+1
|
* Fixed bug with reversed trunc/round_page() in madvise...start must bedg1996-09-191-3/+3
| | | | trunced, end must be rounded.
* Backed out the recent changes/enhancements to the VM code. Thedyson1996-07-301-196/+33
| | | | | | | problem with the 'shell scripts' was found, but there was a 'strange' problem found with a 486 laptop that we could not find. This commit backs the code back to 25-jul, and will be re-entered after the snapshot in smaller (more easily tested) chunks.
* Slight performance tweak for previous commit.dg1996-07-281-2/+3
|
* Allow sequentially created mmap'ed anonymous regions to coalesce. Theredyson1996-07-271-23/+33
| | | | | | is little or no reason to create a swap pager for small mmap's. The vm_map_insert code will automatically create a swap pager if the object becomes too large. This fix, per a request from phk.
* Remove experimental header file. My test-build must have picked itdyson1996-07-271-1/+3
| | | | | up in an unexpected place. Submitted by: jkh
* This commit is meant to solve a couple of VM system problems ordyson1996-07-271-27/+177
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | performance issues. 1) The pmap module has had too many inlines, and so the object file is simply bigger than it needs to be. Some common code is also merged into subroutines. 2) Removal of some *evil* PHYS_TO_VM_PAGE macro calls. Unfortunately, a few have needed to be added also. The removal caused the need for more vm_page_lookups. I added lookup hints to minimize the need for the page table lookup operations. 3) Removal of some bogus performance improvements, that mostly made the code more complex (tracking individual page table page updates unnecessarily). Those improvements actually hurt 386 processors perf (not that people who worry about perf use 386 processors anymore :-)). 4) Changed pv queue manipulations/structures to be TAILQ's. 5) The pv queue code has had some performance problems since day one. Some significant scalability issues are resolved by threading the pv entries from the pmap AND the physical address instead of just the physical address. This makes certain pmap operations run much faster. This does not affect most micro-benchmarks, but should help loaded system performance *significantly*. DG helped and came up with most of the solution for this one. 6) Most if not all pmap bit operations follow the pattern: pmap_test_bit(); pmap_clear_bit(); That made for twice the necessary pv list traversal. The pmap interface now supports only pmap_tc_bit type operations: pmap_[test/clear]_modified, pmap_[test/clear]_referenced. Additionally, the modified routine now takes a vm_page_t arg instead of a phys address. This eliminates a PHYS_TO_VM_PAGE operation. 7) Several rewrites of routines that contain redundant code to use common routines, so that there is a greater likelihood of keeping the cache footprint smaller.
* This commit is dual-purpose, to fix more of the pageout daemondyson1996-05-311-2/+2
| | | | | | queue corruption problems, and to apply Gary Palmer's code cleanups. David Greenman helped with these problems also. There is still a hang problem using X in small memory machines.
* Initial support for mincore and madvise. Both are almost fullydyson1996-05-191-16/+171
| | | | | supported, except madvise does not page in with MADV_WILLNEED, and MADV_DONTNEED doesn't force dirty pages out.
* This set of commits to the VM system does the following, and containdyson1996-05-181-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Another sweep over the pmap/vm macros, this time with more focus onphk1996-05-031-2/+2
| | | | | the usage. I'm not satisfied with the naming, but now at least there is less bogus stuff around.
* Force device mappings to always be shared. It doesn't make sense for themdg1996-03-161-4/+5
| | | | | | | to ever be COW and we need the mappings to be shared for backward compatibilty. Reviewed by: dyson
* Allow mmap'ed devices to work correctly across forks. The sanestdyson1996-03-121-3/+11
| | | | | solution appeared to be to allow the child to maintain the same mapping as the parent.
* Oops.. I nearly forgot the actual core of the length/rounding/etc fixespeter1996-03-021-46/+37
| | | | | | | | | | | | that Bruce asked for. These still are not quite perfect, and in particular, it can get upset on extreme boundary cases (addr = 0xfff, len = 0xffffffff, which would end up mapping a single page rather than failing), but this is better code that I committed before. (note, the VM system does not (apparently) support single mmap segment sizes above 0x80000000 anyway)
* 1) Eliminate unnecessary bzero of UPAGES.dyson1996-03-021-1/+2
| | | | | 2) Eliminate unnecessary copying of pages during/after forks. 3) Add user map simplification.
* kern_descrip.c: add fdshare()/fdcopy()peter1996-02-231-17/+110
| | | | | | | | | | | | | | | | | | | | kern_fork.c: add the tiny bit of code for rfork operation. kern/sysv_*: shmfork() takes one less arg, it was never used. sys/shm.h: drop "isvfork" arg from shmfork() prototype sys/param.h: declare rfork args.. (this is where OpenBSD put it..) sys/filedesc.h: protos for fdshare/fdcopy. vm/vm_mmap.c: add minherit code, add rounding to mmap() type args where it makes sense. vm/*: drop unused isvfork arg. Note: this rfork() implementation copies the address space mappings, it does not connect the mappings together. ie: once the two processes have split, the pages may be shared, but the address space is not. If one does a mmap() etc, it does not appear in the other. This makes it not useful for pthreads, but it is useful in it's own right for having light-weight threads in a static shared address space. Obtained from: Original by Ron Minnich, extended by OpenBSD
* Eliminated many redundant vm_map_lookup operations for vm_mmap.dyson1996-01-191-43/+36
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fixed 1TB filesize changes. Some pindexes had bogus names and typesbde1995-12-171-5/+1
| | | | but worked because vm_pindex_t is indistinuishable from vm_offset_t.
* There was a bug that the size for an msync'ed region was not roundeddyson1995-12-131-2/+2
| | | | | | | up. The effect of this was that msync with a size would generally sync 1 page less than it should. This problem was brought to my attention by Darrel Herbst <dherbst@gradin.cis.upenn.edu> and Ron Minnich <rminnich@sarnoff.com>.
* Changes to support 1Tb filesizes. Pages are now named by andyson1995-12-111-4/+5
| | | | (object,index) pair instead of (object,offset) pair.
* Untangled the vm.h include file spaghetti.dg1995-12-071-2/+10
|
* Completed function declarations and/or added prototypes.bde1995-12-031-2/+4
| | | | | | | | | Staticized some functions. __purified some functions. Some functions were bogusly declared as returning `const'. This hasn't done anything since gcc-2.5. For later versions of gcc, the equivalent is __attribute__((const)) at the end of function declarations.
* Included <sys/sysproto.h> to get central declarations for syscall argsbde1995-11-121-1/+26
| | | | | | | | | | structs and prototypes for syscalls. Ifdefed duplicated decentralized declarations of args structs. It's convenient to have this visible but they are hard to maintain. Some are already different from the central declarations. 4.4lite2 puts them in comments in the function headers but I wanted to avoid the large changes for that.
* First phase of removing the PG_COPYONWRITE flag, and an architecturaldyson1995-10-231-36/+17
| | | | cleanup of mapping files.
* Implement mincore system call.dyson1995-10-211-3/+25
|
* NOTE: libkvm, w, ps, 'top', and any other utility which depends on structdg1995-07-131-161/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* Moved call to VOP_GETATTR() out of vnode_pager_alloc() and into the placesdg1995-07-091-14/+24
| | | | | | that call vnode_pager_alloc() so that a failure return can be dealt with. This fixes a panic seen on NFS clients when a file being opened is deleted on the server before the open completes.
* Remove trailing whitespace.rgrimes1995-05-301-3/+3
|
* Accessing pages beyond the end of a mapped file results in internaldg1995-05-181-3/+8
| | | | | | | | | | | | | inconsistencies in the VM system that eventually lead to a panic. These changes fix the behavior to conform to the behavior in SunOS, which is to deny faults to pages beyond the EOF (returning SIGBUS). Internally, this is implemented by requiring faults to be within the object size boundaries. These changes exposed another bug, namely that passing in an offset to mmap when trying to map an unnamed anonymous region also results in internal inconsistencies. In this case, the offset is forced to zero. Reviewed by: John Dyson and others
* Moved some zero-initialized variables into .bss. Made code intended to bedg1995-04-161-2/+2
| | | | called only from DDB #ifdef DDB. Removed some completely unused globals.
* Fix logic bug I just introduced with the flags to msync().dg1995-03-251-2/+2
|
* Disallow both MS_ASYNC and MS_INVALIDATE flags being set at the same timedg1995-03-251-3/+6
| | | | in msync().
* Added "flags" argument to msync, and implemented MS_ASYNC and MS_INVALIDATE.dg1995-03-251-14/+11
| | | | | The MS_ASYNC flag doesn't current work, and MS_INVALIDATE will only toss out the pages in the address space (not all pages in the shadow chain).
* Fixed bug in vm_mmap() where the object that is created in some casesdg1995-03-221-2/+2
| | | | | | | | was the wrong size. This is the likely cause of panics reported by Lars Fredriksen and Paul Richards related to a -1 blkno when paging via the swap_pager. Submitted by: John Dyson
* Disallow non page-aligned file offsets in vm_mmap(). We don't support thisdg1995-03-211-1/+12
| | | | | in either the high or low level parts of the VM system. Just return EINVAL in this case, just like SunOS does.
* Fixed bug in the size == 0 case of msync() caused by a bogus return valuedg1995-03-211-2/+2
| | | | check..
OpenPOWER on IntegriCloud