summaryrefslogtreecommitdiff
path: root/sys/vm/vm_object.c
Commit message (Collapse)AuthorAgeFilesLines
* Consider three objects, O, BO, and BBO, where BO is O's backing objectAlan Cox2005-01-151-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and BBO is BO's backing object. Now, suppose that O and BO are being collapsed. Furthermore, suppose that BO has been marked dead (OBJ_DEAD) by vm_object_backing_scan() and that either vm_object_backing_scan() has been forced to sleep due to encountering a busy page or vm_object_collapse() has been forced to sleep due to memory allocation in the swap pager. If vm_object_deallocate() is then called on BBO and BO is BBO's only shadow object, vm_object_deallocate() will collapse BO and BBO. In doing so, it adds a necessary temporary reference to BO. If this collapse also sleeps and the prior collapse resumes first, the temporary reference will cause vm_object_collapse to panic with the message "backing_object %p was somehow re-referenced during collapse!" Resolve this race by changing vm_object_deallocate() such that it doesn't collapse BO and BBO if BO is marked dead. Once O and BO are collapsed, vm_object_collapse() will attempt to collapse O and BBO. So, vm_object_deallocate() on BBO need do nothing. Reported by: Peter Holm on 20050107 URL: http://www.holm.cc/stress/log/cons102.html In collaboration with: tegge@ Candidate for RELENG_4 and RELENG_5 MFC after: 2 weeks Notes: svn path=/head/; revision=140319
* Eliminate unused and unnecessary "cred" argument from vinvalbuf()Poul-Henning Kamp2005-01-141-1/+1
| | | | Notes: svn path=/head/; revision=140220
* Remove the unused credential argument from VOP_FSYNC() and VFS_SYNC().Poul-Henning Kamp2005-01-111-1/+1
| | | | | | | | | | | | | | | | | | | | | I'm not sure why a credential was added to these in the first place, it is not used anywhere and it doesn't make much sense: The credentials for syncing a file (ability to write to the file) should be checked at the system call level. Credentials for syncing one or more filesystems ("none") should be checked at the system call level as well. If the filesystem implementation needs a particular credential to carry out the syncing it would logically have to the cached mount credential, or a credential cached along with any delayed write data. Discussed with: rwatson Notes: svn path=/head/; revision=140048
* Move the acquisition and release of the page queues lock outside of a loopAlan Cox2005-01-081-2/+3
| | | | | | | in vm_object_split() to avoid repeated acquisition and release. Notes: svn path=/head/; revision=139921
* /* -> /*- for license, minor formatting changesWarner Losh2005-01-071-1/+1
| | | | Notes: svn path=/head/; revision=139825
* Eliminate another unnecessary call to vm_page_busy(). (See revision 1.333Alan Cox2004-12-171-5/+0
| | | | | | | for a detailed explanation.) Notes: svn path=/head/; revision=138986
* With the removal of kern/uipc_jumbo.c and sys/jumbo.h,Alan Cox2004-12-081-21/+5
| | | | | | | vm_object_allocate_wait() is not used. Remove it. Notes: svn path=/head/; revision=138538
* Eliminate an unnecessary atomic operation. Articulate the rationale inAlan Cox2004-11-061-4/+11
| | | | | | | a comment. Notes: svn path=/head/; revision=137324
* Move a call to wakeup() from vm_object_terminate() to vnode_pager_dealloc()Alan Cox2004-11-061-2/+0
| | | | | | | | | | | | because this call is only needed to wake threads that slept when they discovered a dead object connected to a vnode. To eliminate unnecessary calls to wakeup() by vnode_pager_dealloc(), introduce a new flag, OBJ_DISCONNECTWNT. Reviewed by: tegge@ Notes: svn path=/head/; revision=137297
* Eliminate another unnecessary call to vm_page_busy() that immediatelyAlan Cox2004-11-051-1/+0
| | | | | | | | precedes a call to vm_page_rename(). (See the previous revision for a detailed explanation.) Notes: svn path=/head/; revision=137242
* The synchronization provided by vm object locking has eliminated theAlan Cox2004-11-031-3/+0
| | | | | | | | | | | | | | | | | | | | need for most calls to vm_page_busy(). Specifically, most calls to vm_page_busy() occur immediately prior to a call to vm_page_remove(). In such cases, the containing vm object is locked across both calls. Consequently, the setting of the vm page's PG_BUSY flag is not even visible to other threads that are following the synchronization protocol. This change (1) eliminates the calls to vm_page_busy() that immediately precede a call to vm_page_remove() or functions, such as vm_page_free() and vm_page_rename(), that call it and (2) relaxes the requirement in vm_page_remove() that the vm page's PG_BUSY flag is set. Now, the vm page's PG_BUSY flag is set only when the vm object lock is released while the vm page is still in transition. Typically, this is when it is undergoing I/O. Notes: svn path=/head/; revision=137168
* Move the acquisition and release of the lock on the object at the head ofAlan Cox2004-08-291-4/+12
| | | | | | | | the shadow chain outside of the loop in vm_object_madvise(), reducing the number of times that this lock is acquired and released. Notes: svn path=/head/; revision=134496
* * Add a "how" argument to uma_zone constructors and initialization functionsBrian Feldman2004-08-021-3/+4
| | | | | | | | | | | | | | | | | | | | so that they know whether the allocation is supposed to be able to sleep or not. * Allow uma_zone constructors and initialation functions to return either success or error. Almost all of the ones in the tree currently return success unconditionally, but mbuf is a notable exception: the packet zone constructor wants to be able to fail if it cannot suballocate an mbuf cluster, and the mbuf allocators want to be able to fail in general in a MAC kernel if the MAC mbuf initializer fails. This fixes the panics people are seeing when they run out of memory for mbuf clusters. * Allow debug.nosleepwithlocks on WITNESS to be disabled, without changing the default. Both bmilekic and jeff have reviewed the changes made to make failable zone allocations work. Notes: svn path=/head/; revision=132987
* Fix handling of msync(2) for character special files.Doug Rabson2004-07-301-1/+3
| | | | | | | Submitted by: nvidia Notes: svn path=/head/; revision=132883
* Correct a very old error in both vm_object_madvise() (originating inAlan Cox2004-07-281-2/+2
| | | | | | | | | | | | | | | vm/vm_object.c revision 1.88) and vm_object_sync() (originating in vm/vm_map.c revision 1.36): When descending a chain of backing objects, both use the wrong object's backing offset. Consequently, both may operate on the wrong pages. Quoting Matt, "This could be responsible for all of the sporatic madvise oddness that has been reported over the years." Reviewed by: Matt Dillon Notes: svn path=/head/; revision=132804
* Remove spl calls.Alan Cox2004-07-251-11/+0
| | | | Notes: svn path=/head/; revision=132636
* Make the code and comments for vm_object_coalesce() consistent.Alan Cox2004-07-251-6/+3
| | | | Notes: svn path=/head/; revision=132627
* - Change uma_zone_set_obj() to call kmem_alloc_nofault() instead ofAlan Cox2004-07-221-8/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | kmem_alloc_pageable(). The difference between these is that an errant memory access to the zone will be detected sooner with kmem_alloc_nofault(). The following changes serve to eliminate the following lock-order reversal reported by witness: 1st 0xc1a3c084 vm object (vm object) @ vm/swap_pager.c:1311 2nd 0xc07acb00 swap_pager swhash (swap_pager swhash) @ vm/swap_pager.c:1797 3rd 0xc1804bdc vm object (vm object) @ vm/uma_core.c:931 There is no potential deadlock in this case. However, witness is unable to recognize this because vm objects used by UMA have the same type as ordinary vm objects. To remedy this, we make the following changes: - Add a mutex type argument to VM_OBJECT_LOCK_INIT(). - Use the mutex type argument to assign distinct types to special vm objects such as the kernel object, kmem object, and UMA objects. - Define a static swap zone object for use by UMA. (Only static objects are assigned a special mutex type.) Notes: svn path=/head/; revision=132550
* Initialize result->backing_object_offset before linking result onto the list ofTor Egge2004-06-281-5/+5
| | | | | | | | | | vm objects shadowing source in vm_object_shadow(). This closes a race where vm_object_collapse() could be called with a partially uninitialized object argument causing symptoms that looked like hardware problems, e.g. signal 6, 10, 11 or a /bin/sh busy-waiting for a nonexistant child process. Notes: svn path=/head/; revision=131256
* MFS: vm_map.c rev 1.187.2.27 through 1.187.2.29, fix MS_INVALIDATEDag-Erling Smørgrav2004-05-251-1/+5
| | | | | | | semantics but provide a sysctl knob for reverting to old ones. Notes: svn path=/head/; revision=129729
* 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
* Implement a work around for the deadlock avoidance case inAlan Cox2004-03-081-0/+7
| | | | | | | | | vm_object_deallocate() so that it doesn't spin forever either. Submitted by: bde Notes: svn path=/head/; revision=126739
* Correct a long-standing race condition in vm_object_page_remove() thatAlan Cox2004-02-221-1/+1
| | | | | | | | | | could result in a dirty page being unintentionally freed. Reviewed by: tegge MFC after: 7 days Notes: svn path=/head/; revision=126108
* Don't acquire Giant in vm_object_deallocate() unless the object is vnode-Alan Cox2004-01-181-8/+12
| | | | | | | backed. Notes: svn path=/head/; revision=124646
* Revision 1.74 of vm_meter.c ("Avoid lock-order reversal") makes the releaseAlan Cox2004-01-021-2/+0
| | | | | | | | and subsequent reacquisition of the same vm object lock in vm_object_collapse() unnecessary. Notes: svn path=/head/; revision=124084
* - Modify vm_object_split() to expect a locked vm object on entry andAlan Cox2003-12-301-15/+10
| | | | | | | | return on a locked vm object on exit. Remove GIANT_REQUIRED. - Eliminate some unnecessary local variables from vm_object_split(). Notes: svn path=/head/; revision=124008
* - Rename vm_map_clean() to vm_map_sync(). This better reflects the factAlan Cox2003-11-091-0/+69
| | | | | | | | | | | | | that msync(2) is its only caller. - Migrate the parts of the old vm_map_clean() that examined the internals of a vm object to a new function vm_object_sync() that is implemented in vm_object.c. At the same, introduce the necessary vm object locking so that vm_map_sync() and vm_object_sync() can be called without Giant. Reviewed by: tegge Notes: svn path=/head/; revision=122349
* - Increase the scope of two vm object locks in vm_object_split().Alan Cox2003-11-021-2/+2
| | | | Notes: svn path=/head/; revision=121913
* - Introduce and use vm_object_reference_locked(). UnlikeAlan Cox2003-11-021-2/+24
| | | | | | | | | | vm_object_reference(), this function must not be used to reanimate dead vm objects. This restriction simplifies locking. Reviewed by: tegge Notes: svn path=/head/; revision=121907
* - Increase the scope of two vm object locks in vm_object_collapse().Alan Cox2003-11-011-12/+4
| | | | | | | - Remove the acquisition and release of Giant from vm_object_coalesce(). Notes: svn path=/head/; revision=121866
* - Modify swap_pager_copy() and its callers such that the source andAlan Cox2003-11-011-23/+6
| | | | | | | | | destination objects are locked on entry and exit. Add comments to the callers noting that the locks can be released by swap_pager_copy(). - Remove several instances of GIANT_REQUIRED. Notes: svn path=/head/; revision=121854
* - Additional vm object locking in vm_object_split()Alan Cox2003-11-011-2/+11
| | | | | | | | - New vm object locking assertions in vm_page_insert() and vm_object_set_writeable_dirty() Notes: svn path=/head/; revision=121844
* - Revert a part of revision 1.73: Make vm_object_set_flag() an inlineAlan Cox2003-10-311-6/+0
| | | | | | | | function. This function is so trivial that inlining reduces the size of the kernel. Notes: svn path=/head/; revision=121821
* - Take advantage of the swap pager locking: Eliminate the use of GiantAlan Cox2003-10-311-9/+0
| | | | | | | | from vm_object_madvise(). - Remove excessive blank lines from vm_object_madvise(). Notes: svn path=/head/; revision=121815
* - Simplify vm_object_collapse()'s collapse case, reducing the numberAlan Cox2003-10-261-14/+9
| | | | | | | | | of lock acquires and releases performed. - Move an assertion from vm_object_collapse() to vm_object_zdtor() because it applies to all cases of object destruction. Notes: svn path=/head/; revision=121562
* - Increase the object lock's scope in vm_contig_launder() so that accessAlan Cox2003-10-181-1/+1
| | | | | | | | | | | | to the object's type field and the call to vm_pageout_flush() are synchronized. - The above change allows for the eliminaton of the last parameter to vm_pageout_flush(). - Synchronize access to the page's valid field in vm_pageout_flush() using the containing object's lock. Notes: svn path=/head/; revision=121226
* - Use the UMA_ZONE_VM flag on the fakepg and object zones to preventJeff Roberson2003-10-041-1/+1
| | | | | | | | vm recursion and LORs. This may be necessary for other zones created in the vm but this needs to be verified. Notes: svn path=/head/; revision=120739
* Remove GIANT_REQUIRED from vm_object_shadow().Alan Cox2003-09-171-2/+0
| | | | Notes: svn path=/head/; revision=120152
* Eliminate the use of Giant from vm_object_reference().Alan Cox2003-09-151-11/+11
| | | | Notes: svn path=/head/; revision=120086
* There is no need for an atomic increment on the vm object's generationAlan Cox2003-09-131-2/+1
| | | | | | | | | | | count in _vm_object_allocate(). (Access to the generation count is governed by the vm object's lock.) Note: the introduction of the atomic increment in revision 1.238 appears to be an accident. The purpose of that commit was to fix an Alpha-specific bug in UMA's debugging code. Notes: svn path=/head/; revision=120035
* Remove an unused variable.Poul-Henning Kamp2003-08-061-3/+0
| | | | Notes: svn path=/head/; revision=118537
* Allow vm_object_reference() on kernel_object without Giant.Alan Cox2003-07-271-2/+4
| | | | Notes: svn path=/head/; revision=118074
* Don't inline very large functions.Poul-Henning Kamp2003-07-221-1/+1
| | | | | | | Gcc has silently not been doing this for a long time. Notes: svn path=/head/; revision=117876
* Complete the vm object locking in vm_object_backing_scan(); specifically,Alan Cox2003-06-221-5/+12
| | | | | | | | deal with the case where we need to sleep on a busy page with two vm object locks held. Notes: svn path=/head/; revision=116662
* - Increase the scope of the vm object lock in vm_object_collapse().Alan Cox2003-06-211-3/+4
| | | | | | | | - Assert that the vm object and its backing vm object are both locked in vm_object_qcollapse(). Notes: svn path=/head/; revision=116645
* Use __FBSDID().David E. O'Brien2003-06-111-2/+3
| | | | Notes: svn path=/head/; revision=116226
* Don't use vm_object_set_flag() to initialize the vm object's flags.Alan Cox2003-06-091-1/+1
| | | | Notes: svn path=/head/; revision=116079
* - Properly handle the paging_in_progress case on two vm objects inAlan Cox2003-06-081-26/+16
| | | | | | | | vm_object_deallocate(). - Remove vm_object_pip_sleep(). Notes: svn path=/head/; revision=116067
* Pass the vm object to vm_object_collapse() with its lock held.Alan Cox2003-06-071-8/+5
| | | | Notes: svn path=/head/; revision=115931
* - Extend the scope of the backing object's lock in vm_object_collapse().Alan Cox2003-06-051-2/+4
| | | | Notes: svn path=/head/; revision=115879