aboutsummaryrefslogtreecommitdiff
path: root/sys/vm
Commit message (Collapse)AuthorAgeFilesLines
* Convert the allproc and proctree locks from lockmgr locks to sx locks.John Baldwin2001-03-284-15/+20
| | | | Notes: svn path=/head/; revision=74927
* Catch up to header include changes:John Baldwin2001-03-281-0/+1
| | | | | | | | - <sys/mutex.h> now requires <sys/systm.h> - <sys/mutex.h> and <sys/sx.h> now require <sys/lock.h> Notes: svn path=/head/; revision=74914
* Export intrnames and intrcnt as sysctls (hw.nintr, hw.intrnames andThomas Moestl2001-03-231-0/+30
| | | | | | | | | hw.intrcnt). Approved by: rwatson Notes: svn path=/head/; revision=74670
* Fix a lock reversal problem in the VM subsystem related to threadedMatthew Dillon2001-03-143-0/+10
| | | | | | | | | | | | | | | | programs. There is a case during a fork() which can cause a deadlock. From Tor - The workaround that consists of setting a flag in the vm map that indicates that a fork is in progress and using that mark in the page fault handling to force a revalidation failure. That change will only affect (pessimize) page fault handling during fork for threaded (linuxthreads style) applications and applications using aio_*(). Submited by: tegge Notes: svn path=/head/; revision=74237
* Temporarily remove the vm_map_simplify() call from vm_map_insert(). TheMatthew Dillon2001-03-141-0/+7
| | | | | | | | | | | call is correct, but it interferes with the massive hack called vm_map_growstack(). The call will be returned after our stack handling code is fixed. Reported by: tegge Notes: svn path=/head/; revision=74235
* When creating a shadow vm_object in vmspace_fork(), only oneIan Dowse2001-03-091-0/+4
| | | | | | | | | | | | | | | reference count was transferred to the new object, but both the new and the old map entries had pointers to the new object. Correct this by transferring the second reference. This fixes a panic that can occur when mmap(2) is used with the MAP_INHERIT flag. PR: i386/25603 Reviewed by: dillon, alc Notes: svn path=/head/; revision=74042
* Unrevert the pmap_map() changes. They weren't broken on x86.John Baldwin2001-03-072-17/+10
| | | | | | | Sense beaten into me by: peter Notes: svn path=/head/; revision=73936
* Back out the pmap_map() change for now, it isn't completely stable on theJohn Baldwin2001-03-072-10/+17
| | | | | | | i386. Notes: svn path=/head/; revision=73903
* - Rework pmap_map() to take advantage of direct-mapped segments onJohn Baldwin2001-03-062-17/+10
| | | | | | | | | | | | | | | | | | | | | | supported architectures such as the alpha. This allows us to save on kernel virtual address space, TLB entries, and (on the ia64) VHPT entries. pmap_map() now modifies the passed in virtual address on architectures that do not support direct-mapped segments to point to the next available virtual address. It also returns the actual address that the request was mapped to. - On the IA64 don't use a special zone of PV entries needed for early calls to pmap_kenter() during pmap_init(). This gets us in trouble because we end up trying to use the zone allocator before it is initialized. Instead, with the pmap_map() change, the number of needed PV entries is small enough that we can get by with a static pool that is used until pmap_init() is complete. Submitted by: dfr Debugging help: peter Tested by: me Notes: svn path=/head/; revision=73862
* Simplify vm_object_deallocate(), by decrementing the refcount first.Alfred Perlstein2001-03-041-18/+13
| | | | | | | This allows some of the conditionals to be combined. Notes: svn path=/head/; revision=73534
* Allocate vm_page_array and vm_page_buckets from the end of the biggest chunkAndrew Gallatin2001-03-011-18/+16
| | | | | | | | | | | | | | | | of memory, rather than from the start. This fixes problems allocating bouncebuffers on alphas where there is only 1 chunk of memory (unlike PCs where there is generally at least one small chunk and a large chunk). Having 1 chunk had been fatal, because these structures take over 13MB on a machine with 1GB of ram. This doesn't leave much room for other structures and bounce buffers if they're at the front. Reviewed by: dfr, anderson@cs.duke.edu, silence on -arch Tested by: Yoriaki FUJIMORI <fujimori@grafin.fujimori.cache.waseda.ac.jp> Notes: svn path=/head/; revision=73282
* If we intend to make the page writable without requiring another fault,Matthew Dillon2001-02-281-6/+6
| | | | | | | | | make sure that PG_NOSYNC is properly set. Previously we only set it for a write-fault, but this can occur on a read-fault too. (will be MFCd prior to 4.3 freeze) Notes: svn path=/head/; revision=73212
* Introduce per-swap area accounting in the VM system, and exportRobert Watson2001-02-232-3/+42
| | | | | | | | | | | | | | this information via the vm.nswapdev sysctl (number of swap areas) and vm.swapdevX nodes (where X is the device), which contain the MIBs dev, blocks, used, and flags. These changes are required to allow top and other userland swap-monitoring utilities to run without setgid kmem. Submitted by: Thomas Moestl <tmoestl@gmx.net> Reviewed by: freebsd-audit Notes: svn path=/head/; revision=72949
* Fix formatting bugs introduced in sysctl_vm_zone() by the previous commit.Dag-Erling Smørgrav2001-02-221-2/+7
| | | | | | | Also, if SYSCTL_OUT() returns a non-zero value, stop at once. Notes: svn path=/head/; revision=72888
* Implement a unified run queue and adjust priority levels accordingly.Jake Burkholder2001-02-122-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - All processes go into the same array of queues, with different scheduling classes using different portions of the array. This allows user processes to have their priorities propogated up into interrupt thread range if need be. - I chose 64 run queues as an arbitrary number that is greater than 32. We used to have 4 separate arrays of 32 queues each, so this may not be optimal. The new run queue code was written with this in mind; changing the number of run queues only requires changing constants in runq.h and adjusting the priority levels. - The new run queue code takes the run queue as a parameter. This is intended to be used to create per-cpu run queues. Implement wrappers for compatibility with the old interface which pass in the global run queue structure. - Group the priority level, user priority, native priority (before propogation) and the scheduling class into a struct priority. - Change any hard coded priority levels that I found to use symbolic constants (TTIPRI and TTOPRI). - Remove the curpriority global variable and use that of curproc. This was used to detect when a process' priority had lowered and it should yield. We now effectively yield on every interrupt. - Activate propogate_priority(). It should now have the desired effect without needing to also propogate the scheduling class. - Temporarily comment out the call to vm_page_zero_idle() in the idle loop. It interfered with propogate_priority() because the idle process needed to do a non-blocking acquire of Giant and then other processes would try to propogate their priority onto it. The idle process should not do anything except idle. vm_page_zero_idle() will return in the form of an idle priority kernel thread which is woken up at apprioriate times by the vm system. - Update struct kinfo_proc to the new priority interface. Deliberately change its size by adjusting the spare fields. It remained the same size, but the layout has changed, so userland processes that use it would parse the data incorrectly. The size constraint should really be changed to an arbitrary version number. Also add a debug.sizeof sysctl node for struct kinfo_proc. Notes: svn path=/head/; revision=72376
* Change and clean the mutex lock interface.Bosko Milekic2001-02-097-64/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mtx_enter(lock, type) becomes: mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks) mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized) similarily, for releasing a lock, we now have: mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN. We change the caller interface for the two different types of locks because the semantics are entirely different for each case, and this makes it explicitly clear and, at the same time, it rids us of the extra `type' argument. The enter->lock and exit->unlock change has been made with the idea that we're "locking data" and not "entering locked code" in mind. Further, remove all additional "flags" previously passed to the lock acquire/release routines with the exception of two: MTX_QUIET and MTX_NOSWITCH The functionality of these flags is preserved and they can be passed to the lock/unlock routines by calling the corresponding wrappers: mtx_{lock, unlock}_flags(lock, flag(s)) and mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN locks, respectively. Re-inline some lock acq/rel code; in the sleep lock case, we only inline the _obtain_lock()s in order to ensure that the inlined code fits into a cache line. In the spin lock case, we inline recursion and actually only perform a function call if we need to spin. This change has been made with the idea that we generally tend to avoid spin locks and that also the spin locks that we do have and are heavily used (i.e. sched_lock) do recurse, and therefore in an effort to reduce function call overhead for some architectures (such as alpha), we inline recursion for this case. Create a new malloc type for the witness code and retire from using the M_DEV type. The new type is called M_WITNESS and is only declared if WITNESS is enabled. Begin cleaning up some machdep/mutex.h code - specifically updated the "optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently need those. Finally, caught up to the interface changes in all sys code. Contributors: jake, jhb, jasone (in no particular order) Notes: svn path=/head/; revision=72200
* Mechanical change to use <sys/queue.h> macro API instead ofPoul-Henning Kamp2001-02-044-6/+6
| | | | | | | | | | fondling implementation details. Created with: sed(1) Reviewed by: md5(1) Notes: svn path=/head/; revision=71999
* This commit represents work mainly submitted by Tor and slightly modifiedMatthew Dillon2001-02-041-7/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | by myself. It solves a serious vm_map corruption problem that can occur with the buffer cache when block sizes > 64K are used. This code has been heavily tested in -stable but only tested somewhat on -current. An MFC will occur in a few days. My additions include the vm_map_simplify_entry() and minor buffer cache boundry case fix. Make the buffer cache use a system map for buffer cache KVM rather then a normal map. Ensure that VM objects are not allocated for system maps. There were cases where a buffer map could wind up with a backing VM object -- normally harmless, but this could also result in the buffer cache blocking in places where it assumes no blocking will occur, possibly resulting in corrupted maps. Fix a minor boundry case in the buffer cache size limit is reached that could result in non-optimal code. Add vm_map_simplify_entry() calls to prevent 'creeping proliferation' of vm_map_entry's in the buffer cache's vm_map. Previously only a simple linear optimization was made. (The buffer vm_map typically has only a handful of vm_map_entry's. This stabilizes it at that level permanently). PR: 20609 Submitted by: (Tor Egge) tegge Notes: svn path=/head/; revision=71983
* - Doh, lock faultin() with proc lock in scheduler().John Baldwin2001-01-251-0/+6
| | | | | | | - Lock p_swtime with sched_lock in scheduler() as well. Notes: svn path=/head/; revision=71610
* Convert all simplelocks to mutexes and remove the simplelock implementations.Jason Evans2001-01-241-6/+5
| | | | Notes: svn path=/head/; revision=71576
* Argh, I didn't get this test right when I converted it. Break this upJohn Baldwin2001-01-241-10/+9
| | | | | | | | into two separate if's instead of nested if's. Also, reorder things slightly to avoid unnecessary mutex operations. Notes: svn path=/head/; revision=71574
* - Catch up to proc flag changes.John Baldwin2001-01-242-11/+21
| | | | | | | | - Minimal proc locking. - Use queue macros. Notes: svn path=/head/; revision=71572
* Add mtx_assert()'s to verify that kmem_alloc() and kmem_free() are calledJohn Baldwin2001-01-241-0/+3
| | | | | | | with Giant held. Notes: svn path=/head/; revision=71571
* - Catch up to proc flag changes.John Baldwin2001-01-241-27/+43
| | | | | | | | | | | - Proc locking in a few places. - faultin() now must be called with the proc lock held. - Split up swappable() into a couple of tests so that it can be locke in swapout_procs(). - Use queue macros. Notes: svn path=/head/; revision=71570
* - Catch up to proc flag changes.John Baldwin2001-01-241-1/+3
| | | | Notes: svn path=/head/; revision=71569
* Add missing include.John Baldwin2001-01-241-0/+1
| | | | Notes: svn path=/head/; revision=71512
* Add mibs to hold the number of forks since boot. New mibs are:Hajimu UMEMOTO2001-01-231-0/+16
| | | | | | | | | | | | | | | | | vm.stats.vm.v_forks vm.stats.vm.v_vforks vm.stats.vm.v_rforks vm.stats.vm.v_kthreads vm.stats.vm.v_forkpages vm.stats.vm.v_vforkpages vm.stats.vm.v_rforkpages vm.stats.vm.v_kthreadpages Submitted by: Paul Herman <pherman@frenchfries.net> Reviewed by: alfred Notes: svn path=/head/; revision=71429
* Sigh. atomic_add_int takes a pointer, not an integer.Jake Burkholder2001-01-231-4/+4
| | | | | | | Pointy-hat-to: des Notes: svn path=/head/; revision=71408
* Use atomic operations to update the stat counters.Dag-Erling Smørgrav2001-01-231-4/+4
| | | | Notes: svn path=/head/; revision=71406
* Call vm_zone_init() at the appropriate time.Dag-Erling Smørgrav2001-01-221-0/+2
| | | | | | | Reviewed by: jasone, jhb Notes: svn path=/head/; revision=71362
* Give this code a major facelift:Dag-Erling Smørgrav2001-01-222-235/+167
| | | | | | | | | | | | | | | | | | | | | | | | | | - replace the simplelock in struct vm_zone with a mutex. - use a proper SLIST rather than a hand-rolled job for the zone list. - add a subsystem lock that protects the zone list and the statistics counters. - merge _zalloc() into zalloc() and _zfree() into zfree(), and move them below _zget() so there's no need for a prototype. - add two initialization functions: one which initializes the subsystem mutex and the zone list, and one that currently doesn't do anything. - zap zerror(); use KASSERTs instead. - dike out half of sysctl_vm_zone(), which was mostly trying to do manually what the snprintf() call could do better. Reviewed by: jhb, jasone Notes: svn path=/head/; revision=71361
* First step towards an MP-safe zone allocator:Dag-Erling Smørgrav2001-01-212-43/+5
| | | | | | | | | | - have zalloc() and zfree() always lock the vm_zone. - remove zalloci() and zfreei(), which are now redundant. Reviewed by: bmilekic, jasone Notes: svn path=/head/; revision=71350
* fix comment which was outdated 3 years agoAlfred Perlstein2000-12-291-14/+13
| | | | | | | | remove useless assignment purge entire file of 'register' keyword Notes: svn path=/head/; revision=70480
* clean up kmem_suballoc():Alfred Perlstein2000-12-291-4/+4
| | | | | | | | remove useless assignment remove 'register' variables Notes: svn path=/head/; revision=70478
* Make zalloc and zfree non-inline functions. This avoids having toAssar Westerlund2000-12-272-78/+77
| | | | | | | | | | have the code calling these be compiled with the same setting for INVARIANTS and SMP. Reviewed by: dillon Notes: svn path=/head/; revision=70390
* This implements a better launder limiting solution. There was a solutionMatthew Dillon2000-12-264-114/+156
| | | | | | | | | | | | | | | | | | | | | | in 4.2-REL which I ripped out in -stable and -current when implementing the low-memory handling solution. However, maxlaunder turns out to be the saving grace in certain very heavily loaded systems (e.g. newsreader box). The new algorithm limits the number of pages laundered in the first pageout daemon pass. If that is not sufficient then suceessive will be run without any limit. Write I/O is now pipelined using two sysctls, vfs.lorunningspace and vfs.hirunningspace. This prevents excessive buffered writes in the disk queues which cause long (multi-second) delays for reads. It leads to more stable (less jerky) and generally faster I/O streaming to disk by allowing required read ops (e.g. for indirect blocks and such) to occur without interrupting the write stream, amoung other things. NOTE: eventually, filesystem write I/O pipelining needs to be done on a per-device basis. At the moment it is globalized. Notes: svn path=/head/; revision=70374
* Fix floppy drives on machines with lots of RAM.Poul-Henning Kamp2000-12-181-1/+1
| | | | | | | | | | | The fix works by reverting the ordering of free memory so that the chances of contig_malloc() succeeding increases. PR: 23291 Submitted by: Andrew Atrens <atrens@nortel.ca> Notes: svn path=/head/; revision=70160
* - If swap metadata does not fit into the KVM, reduce the number ofSeigo Tanimura2000-12-139-19/+46
| | | | | | | | | | | | | | | | | | struct swblock entries by dividing the number of the entries by 2 until the swap metadata fits. - Reject swapon(2) upon failure of swap_zone allocation. This is just a temporary fix. Better solutions include: (suggested by: dillon) o reserving swap in SWAP_META_PAGES chunks, and o swapping the swblock structures themselves. Reviewed by: alfred, dillon Notes: svn path=/head/; revision=69972
* - Change the allproc_lock to use a macro, ALLPROC_LOCK(how), insteadJake Burkholder2000-12-134-15/+15
| | | | | | | | | | | of explicit calls to lockmgr. Also provides macros for the flags pased to specify shared, exclusive or release which map to the lockmgr flags. This is so that the use of lockmgr can be easily replaced with optimized reader-writer locks. - Add some locking that I missed the first time. Notes: svn path=/head/; revision=69947
* Be less conservative with a recently added KASSERT. Certain edgeMatthew Dillon2000-12-111-1/+4
| | | | | | | | | | | | | cases with file fragments and read-write mmap's can lead to a situation where a VM page has odd dirty bits, e.g. 0xFC - due to being dirtied by an mmap and only the fragment (representing a non-page-aligned end of file) synced via a filesystem buffer. A correct solution that guarentees consistent m->dirty for the file EOF case is being worked on. In the mean time we can't be so conservative in the KASSERT. Notes: svn path=/head/; revision=69847
* Convert more malloc+bzero to malloc+M_ZERO.David Malone2000-12-081-2/+1
| | | | | | | | Submitted by: josh@zipperup.org Submitted by: Robert Drehmel <robd@gmx.net> Notes: svn path=/head/; revision=69781
* Really fix phys_pager:Alfred Perlstein2000-12-061-31/+36
| | | | | | | | | | | | | | | | | | | | | Backout the previous delta (rev 1.4), it didn't make any difference. If the requested handle is NULL then don't add it to the list of objects, to be found by handle. The problem is that when asking for a NULL handle you are implying you want a new object. Because objects with NULL handles were being added to the list, any further requests for phys backed objects with NULL handles would return a reference to the initial NULL handle object after finding it on the list. Basically one couldn't have more than one phys backed object without a handle in the entire system without this fix. If you did more than one shared memory allocation using the phys pager it would give you your initial allocation again. Notes: svn path=/head/; revision=69687
* need to adjust allocation size to properly deal with non PAGE_SIZEAlfred Perlstein2000-12-051-1/+1
| | | | | | | | allocations, specifically with allocations < PAGE_SIZE when the code doesn't work properly Notes: svn path=/head/; revision=69641
* Backed out previous commit. Don't depend on namespace pollution inBruce Evans2000-12-021-0/+1
| | | | | | | <sys/buf.h>. Notes: svn path=/head/; revision=69517
* Protect p_stat with sched_lock.John Baldwin2000-12-021-0/+6
| | | | Notes: svn path=/head/; revision=69516
* Protect p_stat with sched_lock.John Baldwin2000-12-021-2/+13
| | | | Notes: svn path=/head/; revision=69509
* remove unneded sys/ucred.h includesAlfred Perlstein2000-11-301-1/+0
| | | | Notes: svn path=/head/; revision=69399
* Protect the following with a lockmgr lock:Jake Burkholder2000-11-224-1/+17
| | | | | | | | | | | | | | | allproc zombproc pidhashtbl proc.p_list proc.p_hash nextpid Reviewed by: jhb Obtained from: BSD/OS and netbsd Notes: svn path=/head/; revision=69022
* o Export dmmax ("Maximum size of a swap block") using SYSCTL_INT.Robert Watson2000-11-201-0/+3
| | | | | | | | This removes a reason that systat requires setgid kmem. More to come. Notes: svn path=/head/; revision=68921
* Implement a low-memory deadlock solution.Matthew Dillon2000-11-184-79/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Removed most of the hacks that were trying to deal with low-memory situations prior to now. The new code is based on the concept that I/O must be able to function in a low memory situation. All major modules related to I/O (except networking) have been adjusted to allow allocation out of the system reserve memory pool. These modules now detect a low memory situation but rather then block they instead continue to operate, then return resources to the memory pool instead of cache them or leave them wired. Code has been added to stall in a low-memory situation prior to a vnode being locked. Thus situations where a process blocks in a low-memory condition while holding a locked vnode have been reduced to near nothing. Not only will I/O continue to operate, but many prior deadlock conditions simply no longer exist. Implement a number of VFS/BIO fixes (found by Ian): in biodone(), bogus-page replacement code, the loop was not properly incrementing loop variables prior to a continue statement. We do not believe this code can be hit anyway but we aren't taking any chances. We'll turn the whole section into a panic (as it already is in brelse()) after the release is rolled. In biodone(), the foff calculation was incorrectly clamped to the iosize, causing the wrong foff to be calculated for pages in the case of an I/O error or biodone() called without initiating I/O. The problem always caused a panic before. Now it doesn't. The problem is mainly an issue with NFS. Fixed casts for ~PAGE_MASK. This code worked properly before only because the calculations use signed arithmatic. Better to properly extend PAGE_MASK first before inverting it for the 64 bit masking op. In brelse(), the bogus_page fixup code was improperly throwing away the original contents of 'm' when it did the j-loop to fix the bogus pages. The result was that it would potentially invalidate parts of the *WRONG* page(!), leading to corruption. There may still be cases where a background bitmap write is being duplicated, causing potential corruption. We have identified a potentially serious bug related to this but the fix is still TBD. So instead this patch contains a KASSERT to detect the problem and panic the machine rather then continue to corrupt the filesystem. The problem does not occur very often.. it is very hard to reproduce, and it may or may not be the cause of the corruption people have reported. Review by: (VFS/BIO: mckusick, Ian Dowse <iedowse@maths.tcd.ie>) Testing by: (VM/Deadlock) Paul Saab <ps@yahoo-inc.com> Notes: svn path=/head/; revision=68885