aboutsummaryrefslogtreecommitdiff
path: root/sys/vm/vm_extern.h
Commit message (Collapse)AuthorAgeFilesLines
...
* Eliminate dead code.Alan Cox2009-04-011-13/+0
| | | | | | | Reviewed by: jhb Notes: svn path=/head/; revision=190604
* Introduce a new parameter "superpage_align" to kmem_suballoc() that isAlan Cox2008-05-101-1/+2
| | | | | | | | | | | | | | used to request superpage alignment for the submap. Request superpage alignment for the kmem_map. Pass VMFS_ANY_SPACE instead of TRUE to vm_map_find(). (They are currently equivalent but VMFS_ANY_SPACE is the new preferred spelling.) Remove a stale comment from kmem_malloc(). Notes: svn path=/head/; revision=178933
* Fix for the panic("vm_thread_new: kstack allocation failed") andKonstantin Belousov2007-11-051-5/+5
| | | | | | | | | | | | | | | | | | | | | | | silent NULL pointer dereference in the i386 and sparc64 pmap_pinit() when the kmem_alloc_nofault() failed to allocate address space. Both functions now return error instead of panicing or dereferencing NULL. As consequence, vmspace_exec() and vmspace_unshare() returns the errno int. struct vmspace arg was added to vm_forkproc() to avoid dealing with failed allocation when most of the fork1() job is already done. The kernel stack for the thread is now set up in the thread_alloc(), that itself may return NULL. Also, allocation of the first process thread is performed in the fork1() to properly deal with stack allocation failure. proc_linkup() is separated into proc_linkup() called from fork1(), and proc_linkup0(), that is used to set up the kernel process (was known as swapper). In collaboration with: Peter Holm Reviewed by: jhb Notes: svn path=/head/; revision=173361
* Close race between vmspace_exitfree() and exit1() and races betweenTor Egge2006-05-291-0/+2
| | | | | | | | | | | | | | | | | | | | vmspace_exitfree() and vmspace_free() which could result in the same vmspace being freed twice. Factor out part of exit1() into new function vmspace_exit(). Attach to vmspace0 to allow old vmspace to be freed earlier. Add new function, vmspace_acquire_ref(), for obtaining a vmspace reference for a vmspace belonging to another process. Avoid changing vmspace refcount from 0 to 1 since that could also lead to the same vmspace being freed twice. Change vmtotal() and swapout_procs() to use vmspace_acquire_ref(). Reviewed by: alc Notes: svn path=/head/; revision=159054
* Use sf_buf_alloc() instead of vm_map_find() on exec_map to create theAlan Cox2005-12-161-0/+2
| | | | | | | | | | | | | | | | | | | | ephemeral mappings that are used as the source for three copy operations from kernel space to user space. There are two reasons for making this change: (1) Under heavy load exec_map can fill up causing vm_map_find() to fail. When it fails, the nascent process is aborted (SIGABRT). Whereas, this reimplementation using sf_buf_alloc() sleeps. (2) Although it is possible to sleep on vm_map_find()'s failure until address space becomes available (see kmem_alloc_wait()), using sf_buf_alloc() is faster. Furthermore, the reimplementation uses a CPU private mapping, avoiding a TLB shootdown on multiprocessors. Problem uncovered by: kris@ Reviewed by: tegge@ MFC after: 3 weeks Notes: svn path=/head/; revision=153485
* - Change the vm_mmap() function to accept an objtype_t parameter specifyingJohn Baldwin2005-04-011-1/+1
| | | | | | | | | | | | | | | the type of object represented by the handle argument. - Allow vm_mmap() to map device memory via cdev objects in addition to vnodes and anonymous memory. Note that mmaping a cdev directly does not currently perform any MAC checks like mapping a vnode does. - Unbreak the DRM getbufs ioctl by having it call vm_mmap() directly on the cdev the ioctl is acting on rather than trying to find a suitable vnode to map from. Reviewed by: alc, arch@ Notes: svn path=/head/; revision=144501
* Disable U area swapping and remove the routines that create, destroy,David Schultz2004-11-201-2/+0
| | | | | | | | | copy, and swap U areas. Reviewed by: arch@ Notes: svn path=/head/; revision=137910
* For years, kmem_alloc_pageable() has been misused. Now that the last ofAlan Cox2004-07-251-1/+0
| | | | | | | | these misuses has been corrected, remove it before new ones appear, such as arm/arm/pmap.c revision 1.8. Notes: svn path=/head/; revision=132638
* To date, unwiring a fictitious page has produced a panic. The reasonAlan Cox2004-05-221-2/+2
| | | | | | | | | | | | | | | | | | being that PHYS_TO_VM_PAGE() returns the wrong vm_page for fictitious pages but unwiring uses PHYS_TO_VM_PAGE(). The resulting panic reported an unexpected wired count. Rather than attempting to fix PHYS_TO_VM_PAGE(), this fix takes advantage of the properties of fictitious pages. Specifically, fictitious pages will never be completely unwired. Therefore, we can keep a fictitious page's wired count forever set to one and thereby avoid the use of PHYS_TO_VM_PAGE() when we know that we're working with a fictitious page, just not which one. In collaboration with: green@, tegge@ PR: kern/29915 Notes: svn path=/head/; revision=129571
* Remove advertising clause from University of California Regent's license,Warner Losh2004-04-061-4/+0
| | | | | | | | | per letter dated July 22, 1999. Approved by: core Notes: svn path=/head/; revision=127961
* Revert to the original vslock() and vsunlock() API with the followingDon Lewis2004-03-151-2/+2
| | | | | | | | | | | | exceptions: Retain the recently added vslock() error return. The type of the len argument should be size_t, not u_int. Suggested by: bde Notes: svn path=/head/; revision=127007
* Undo the merger of mlock()/vslock and munlock()/vsunlock() and theDon Lewis2004-03-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | introduction of kern_mlock() and kern_munlock() in src/sys/kern/kern_sysctl.c 1.150 src/sys/vm/vm_extern.h 1.69 src/sys/vm/vm_glue.c 1.190 src/sys/vm/vm_mmap.c 1.179 because different resource limits are appropriate for transient and "permanent" page wiring requests. Retain the kern_mlock() and kern_munlock() API in the revived vslock() and vsunlock() functions. Combine the best parts of each of the original sets of implementations with further code cleanup. Make the mclock() and vslock() implementations as similar as possible. Retain the RLIMIT_MEMLOCK check in mlock(). Move the most strigent test, which can return EAGAIN, last so that requests that have no hope of ever being satisfied will not be retried unnecessarily. Disable the test that can return EAGAIN in the vslock() implementation because it will cause the sysctl code to wedge. Tested by: Cy Schubert <Cy.Schubert AT komquats.com> Notes: svn path=/head/; revision=126668
* Split the mlock() kernel code into two parts, mlock(), which unpacksDon Lewis2004-02-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the syscall arguments and does the suser() permission check, and kern_mlock(), which does the resource limit checking and calls vm_map_wire(). Split munlock() in a similar way. Enable the RLIMIT_MEMLOCK checking code in kern_mlock(). Replace calls to vslock() and vsunlock() in the sysctl code with calls to kern_mlock() and kern_munlock() so that the sysctl code will obey the wired memory limits. Nuke the vslock() and vsunlock() implementations, which are no longer used. Add a member to struct sysctl_req to track the amount of memory that is wired to handle the request. Modify sysctl_wire_old_buffer() to return an error if its call to kern_mlock() fails. Only wire the minimum of the length specified in the sysctl request and the length specified in its argument list. It is recommended that sysctl handlers that use sysctl_wire_old_buffer() should specify reasonable estimates for the amount of data they want to return so that only the minimum amount of memory is wired no matter what length has been specified by the request. Modify the callers of sysctl_wire_old_buffer() to look for the error return. Modify sysctl_old_user to obey the wired buffer length and clean up its implementation. Reviewed by: bms Notes: svn path=/head/; revision=126253
* Remove vm_page_alloc_contig(). It's now unused.Alan Cox2004-01-141-1/+0
| | | | Notes: svn path=/head/; revision=124513
* Remove long dead code, specifically, code related to munmapfd().Alan Cox2004-01-111-1/+0
| | | | | | | (See also vm/vm_mmap.c revision 1.173.) Notes: svn path=/head/; revision=124366
* Revert previous commit. Come back vslock(), all is forgiven.Bruce M Simpson2003-10-051-0/+2
| | | | | | | Pointy hat to: bms Notes: svn path=/head/; revision=120811
* Retire vslock() and vsunlock() with extreme prejudice.Bruce M Simpson2003-10-051-2/+0
| | | | | | | Discussed with: pete Notes: svn path=/head/; revision=120806
* Make swaponvp() static to the swap_pager.Poul-Henning Kamp2003-08-151-1/+0
| | | | Notes: svn path=/head/; revision=118945
* Migrate the thread stack management functions from the machine-dependentAlan Cox2003-06-141-1/+5
| | | | | | | | | | | | | | | | | | | to the machine-independent parts of the VM. At the same time, this introduces vm object locking for the non-i386 platforms. Two details: 1. KSTACK_GUARD has been removed in favor of KSTACK_GUARD_PAGES. The different machine-dependent implementations used various combinations of KSTACK_GUARD and KSTACK_GUARD_PAGES. To disable guard page, set KSTACK_GUARD_PAGES to 0. 2. Remove the (unnecessary) clearing of PG_ZERO in vm_thread_new. In 5.x, (but not 4.x,) PG_ZERO can only be set if VM_ALLOC_ZERO is passed to vm_page_alloc() or vm_page_grab(). Notes: svn path=/head/; revision=116355
* Move the *_new_altkstack() and *_dispose_altkstack() functions out of theAlan Cox2003-06-141-0/+2
| | | | | | | | various pmap implementations into the machine-independent vm. They were all identical. Notes: svn path=/head/; revision=116328
* - Add vm_paddr_t, a physical address type. This is required for systemsJake Burkholder2003-03-251-1/+1
| | | | | | | | | | | | | | | | | | where physical addresses larger than virtual addresses, such as i386s with PAE. - Use this to represent physical addresses in the MI vm system and in the i386 pmap code. This also changes the paddr parameter to d_mmap_t. - Fix printf formats to handle physical addresses >4G in the i386 memory detection code, and due to kvtop returning vm_paddr_t instead of u_long. Note that this is a name change only; vm_paddr_t is still the same as vm_offset_t on all currently supported platforms. Sponsored by: DARPA, Network Associates Laboratories Discussed with: re, phk (cdevsw change) Notes: svn path=/head/; revision=112569
* use 'void *' instead of 'caddr_t' for useracc, kernacc, vslock and vsunlock.Alfred Perlstein2003-01-211-4/+4
| | | | Notes: svn path=/head/; revision=109630
* o Merge vm_fault_wire() and vm_fault_user_wire() by adding a new parameter,Alan Cox2002-07-241-2/+1
| | | | | | | user_wire. Notes: svn path=/head/; revision=100630
* Infrastructure tweaks to allow having both an Elf32 and an Elf64 executablePeter Wemm2002-07-201-1/+1
| | | | | | | | | | | | | | | | | | handler in the kernel at the same time. Also, allow for the exec_new_vmspace() code to build a different sized vmspace depending on the executable environment. This is a big help for execing i386 binaries on ia64. The ELF exec code grows the ability to map partial pages when there is a page size difference, eg: emulating 4K pages on 8K or 16K hardware pages. Flesh out the i386 emulation support for ia64. At this point, the only binary that I know of that fails is cvsup, because the cvsup runtime tries to execute code in pages not marked executable. Obtained from: dfr (mostly, many tweaks from me). Notes: svn path=/head/; revision=100384
* Collect all the (now equivalent) pmap_new_proc/pmap_dispose_proc/Peter Wemm2002-07-071-0/+2
| | | | | | | | | | | | | | | | pmap_swapin_proc/pmap_swapout_proc functions from the MD pmap code and use a single equivalent MI version. There are other cleanups needed still. While here, use the UMA zone hooks to keep a cache of preinitialized proc structures handy, just like the thread system does. This eliminates one dependency on 'struct proc' being persistent even after being freed. There are some comments about things that can be factored out into ctor/dtor functions if it is worth it. For now they are mostly just doing statistics to get a feel of how it is working. Notes: svn path=/head/; revision=99559
* o Eliminate the use of grow_stack() and useracc() from sendsig(), osendsig(),Alan Cox2002-04-051-1/+0
| | | | | | | | | and osf1_sendsig(). o Eliminate the prototype for the MD grow_stack() now that it has been removed from all platforms. Notes: svn path=/head/; revision=93847
* Remove an unused prototype.Alan Cox2002-03-261-1/+0
| | | | Notes: svn path=/head/; revision=93194
* Remove __P.Alfred Perlstein2002-03-191-48/+48
| | | | Notes: svn path=/head/; revision=92727
* - Remove a number of extra newlines that do not belong here according toEivind Eklund2002-03-101-3/+1
| | | | | | | | | | | | style(9) - Minor space adjustment in cases where we have "( ", " )", if(), return(), while(), for(), etc. - Add /* SYMBOL */ after a few #endifs. Reviewed by: alc Notes: svn path=/head/; revision=92029
* Pre-KSE/M3 commit.Julian Elischer2002-02-071-1/+1
| | | | | | | | | | | | | this is a low-functionality change that changes the kernel to access the main thread of a process via the linked list of threads rather than assuming that it is embedded in the process. It IS still embeded there but remove all teh code that assumes that in preparation for the next commit which will actually move it out. Reviewed by: peter@freebsd.org, gallatin@cs.duke.edu, benno rice, Notes: svn path=/head/; revision=90361
* Fix a race with free'ing vmspaces at process exit when vmspaces areAlfred Perlstein2002-02-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | shared. Also introduce vm_endcopy instead of using pointer tricks when initializing new vmspaces. The race occured because of how the reference was utilized: test vmspace reference, possibly block, decrement reference When sharing a vmspace between multiple processes it was possible for two processes exiting at the same time to test the reference count, possibly block and neither one free because they wouldn't see the other's update. Submitted by: green Notes: svn path=/head/; revision=90263
* Move the code that computes the system load average from vm_meter.cIan Dowse2001-10-201-1/+0
| | | | | | | | | | | | | | | to kern_synch.c in preparation for adding some jitter to the inter-sample time. Note that the "vm.loadavg" sysctl still lives in vm_meter.c which isn't the right place, but it is appropriate for the current (bad) name of that sysctl. Suggested by: jhb (some time ago) Reviewed by: bde Notes: svn path=/head/; revision=85227
* KSE Milestone 2Julian Elischer2001-09-121-13/+13
| | | | | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha Notes: svn path=/head/; revision=83366
* Rip some well duplicated code out of cpu_wait() and cpu_exit() and movePeter Wemm2001-09-101-1/+2
| | | | | | | | | | | | | | | it to the MI area. KSE touched cpu_wait() which had the same change replicated five ways for each platform. Now it can just do it once. The only MD parts seemed to be dealing with fpu state cleanup and things like vm86 cleanup on x86. The rest was identical. XXX: ia64 and powerpc did not have cpu_throw(), so I've put a functional stub in place. Reviewed by: jake, tmm, dillon Notes: svn path=/head/; revision=83276
* Remove unused 3rd argument from vsunlock() which abused B_WRITE.Poul-Henning Kamp2000-03-131-1/+1
| | | | Notes: svn path=/head/; revision=57975
* Change #ifdef KERNEL to #ifdef _KERNEL in the public headers. "KERNEL"Peter Wemm1999-12-291-2/+2
| | | | | | | | | is an application space macro and the applications are supposed to be free to use it as they please (but cannot). This is consistant with the other BSD's who made this change quite some time ago. More commits to come. Notes: svn path=/head/; revision=55206
* Remove unused declarations.Alan Cox1999-11-081-4/+0
| | | | Notes: svn path=/head/; revision=52974
* Fix bug in pipe code relating to writes of mmap'd but illegal addressMatthew Dillon1999-09-201-1/+1
| | | | | | | | | | | | spaces which cross a segment boundry in the page table. pmap_kextract() is not designed for access to the user space portion of the page table and cannot handle the null-page-directory-entry case. The fix is to have vm_fault_quick() return a success or failure which is then used to avoid calling pmap_kextract(). Notes: svn path=/head/; revision=51474
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Add a function kmem_alloc_nofault() - same as kmem_alloc_pageable(), butDmitrij Tejblum1999-06-081-1/+2
| | | | | | | | | 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
* Move the declaration of faultin() from the vm headers to proc.h, sincePeter Wemm1999-04-131-2/+1
| | | | | | | it is now referenced from a macro there (PHOLD()). Notes: svn path=/head/; revision=45665
* Mostly remove the VM_STACK OPTION.Julian Elischer1999-01-261-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes the definitions of a few items so that structures are the same whether or not the option itself is enabled. This allows people to enable and disable the option without recompilng the world. As the author says: |I ran into a problem pulling out the VM_STACK option. I was aware of this |when I first did the work, but then forgot about it. The VM_STACK stuff |has some code changes in the i386 branch. There need to be corresponding |changes in the alpha branch before it can come out completely. what is done: | |1) Pull the VM_STACK option out of the header files it appears in. This |really shouldn't affect anything that executes with or without the rest |of the VM_STACK patches. The vm_map_entry will then always have one |extra element (avail_ssize). It just won't be used if the VM_STACK |option is not turned on. | |I've also pulled the option out of vm_map.c. This shouldn't harm anything, |since the routines that are enabled as a result are not called unless |the VM_STACK option is enabled elsewhere. | |2) Add what appears to be appropriate code the the alpha branch, still |protected behind the VM_STACK switch. I don't have an alpha machine, |so we would need to get some testers with alpha machines to try it out. | |Once there is some testing, we can consider making the change permanent |for both i386 and alpha. | [..] | |Once the alpha code is adequately tested, we can pull VM_STACK out |everywhere. | Submitted by: "Richard Seaman, Jr." <dick@tar.com> Notes: svn path=/head/; revision=43209
* Add (but don't activate) code for a special VM option to makeJulian Elischer1999-01-061-1/+5
| | | | | | | | | | | | | | | | downward growing stacks more general. Add (but don't activate) code to use the new stack facility when running threads, (specifically the linux threads support). This allows people to use both linux compiled linuxthreads, and also the native FreeBSD linux-threads port. The code is conditional on VM_STACK. Not using this will produce the old heavily tested system. Submitted by: Richard Seaman <dick@tar.com> Notes: svn path=/head/; revision=42360
* This commit fixes various 64bit portability problems required forDoug Rabson1998-06-071-3/+3
| | | | | | | | | | | | | FreeBSD/alpha. The most significant item is to change the command argument to ioctl functions from int to u_long. This change brings us inline with various other BSD versions. Driver writers may like to use (__FreeBSD_version == 300003) to detect this change. The prototype FreeBSD/alpha machdep will follow in a couple of days time. Notes: svn path=/head/; revision=36735
* VM level code cleanups.John Dyson1998-01-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* caddr_t --> void *Alexander Langer1997-12-311-2/+2
| | | | Notes: svn path=/head/; revision=32132
* Support an optional, sysctl enabled feature of idle process swapout. ThisJohn Dyson1997-12-061-2/+2
| | | | | | | | | | | | | | is apparently useful for large shell systems, or systems with long running idle processes. To enable the feature: sysctl -w vm.swap_idle_enabled=1 Please note that some of the other vm sysctl variables have been renamed to be more accurate. Submitted by: Much of it from Matt Dillon <dillon@best.net> Notes: svn path=/head/; revision=31563
* Fully implement vfork. Vfork is now much much faster than even ourJohn Dyson1997-04-131-1/+3
| | | | | | | | | | | | | | | | | | | | fork. (On my machine, fork is about 240usecs, vfork is 78usecs.) Implement rfork(!RFPROC !RFMEM), which allows a thread to divorce its memory from the other threads of a group. Implement rfork(!RFPROC RFCFDG), which closes all file descriptors, eliminating possible existing shares with other threads/processes. Implement rfork(!RFPROC RFFDG), which divorces the file descriptors for a thread from the rest of the group. Fix the case where a thread does an exec. It is almost nonsense for a thread to modify the other threads address space by an exec, so we now automatically divorce the address space before modifying it. Notes: svn path=/head/; revision=24848
* The biggie: Get rid of the UPAGES from the top of the per-process addressPeter Wemm1997-04-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | space. (!) Have each process use the kernel stack and pcb in the kvm space. Since the stacks are at a different address, we cannot copy the stack at fork() and allow the child to return up through the function call tree to return to user mode - create a new execution context and have the new process begin executing from cpu_switch() and go to user mode directly. In theory this should speed up fork a bit. Context switch the tss_esp0 pointer in the common tss. This is a lot simpler since than swithching the gdt[GPROC0_SEL].sd.sd_base pointer to each process's tss since the esp0 pointer is a 32 bit pointer, and the sd_base setting is split into three different bit sections at non-aligned boundaries and requires a lot of twiddling to reset. The 8K of memory at the top of the process space is now empty, and unmapped (and unmappable, it's higher than VM_MAXUSER_ADDRESS). Simplity the pmap code to manage process contexts, we no longer have to double map the UPAGES, this simplifies and should measuably speed up fork(). The following parts came from John Dyson: Set PG_G on the UPAGES that are now in kernel context, and invalidate them when swapping them out. Move the upages object (upobj) from the vmspace to the proc structure. Now that the UPAGES (pcb and kernel stack) are out of user space, make rfork(..RFMEM..) do what was intended by sharing the vmspace entirely via reference counting rather than simply inheriting the mappings. Notes: svn path=/head/; revision=24691
* Correction to the prototype for vm_fault.John Dyson1997-04-061-2/+2
| | | | Notes: svn path=/head/; revision=24667