summaryrefslogtreecommitdiffstats
path: root/sys/vm/swap_pager.c
Commit message (Collapse)AuthorAgeFilesLines
* Add sysctl documentation strings. The descriptions are derivedivoras2009-11-021-3/+7
| | | | | | | | | from tuning(7). One of the descriptions references tuning(7) because it is too complex to adequatly describe here (it is not a simple boolean sysctl) and users should be warned to that. Reviewed by: alc, kib Approved by: gnn (mentor)
* Remove spurious call to priv_check(PRIV_VM_SWAP_NOQUOTA).kib2009-10-181-6/+4
| | | | | | | | | | | | Call priv_check(PRIV_VM_SWAP_NORLIMIT) only when per-uid limit is actually exceed. Both changes aim at calling priv_check(9) only for the cases when privilege is actually exercised by the process. Reported and tested by: rwatson Reviewed by: alc MFC after: 3 days
* Initialize the uip to silence gcc warning that seems to sneak in in somekib2009-06-241-0/+1
| | | | | | build environments. Reported by: alc, bf1783 at googlemail com
* Implement global and per-uid accounting of the anonymous memory. Addkib2009-06-231-7/+152
| | | | | | | | | | | | | | | | | | | | | | | | | | | rlimit RLIMIT_SWAP that limits the amount of swap that may be reserved for the uid. The accounting information (charge) is associated with either map entry, or vm object backing the entry, assuming the object is the first one in the shadow chain and entry does not require COW. Charge is moved from entry to object on allocation of the object, e.g. during the mmap, assuming the object is allocated, or on the first page fault on the entry. It moves back to the entry on forks due to COW setup. The per-entry granularity of accounting makes the charge process fair for processes that change uid during lifetime, and decrements charge for proper uid when region is unmapped. The interface of vm_pager_allocate(9) is extended by adding struct ucred *, that is used to charge appropriate uid when allocation if performed by kernel, e.g. md(4). Several syscalls, among them is fork(2), may now return ENOMEM when global or per-uid limits are enforced. In collaboration with: pho Reviewed by: alc Approved by: re (kensmith)
* Move "options MAC" from opt_mac.h to opt_global.h, as it's now in GENERICrwatson2009-06-051-1/+0
| | | | | | | | and used in a large number of files, but also because an increasing number of incorrect uses of MAC calls were sneaking in due to copy-and-paste of MAC-aware code without the associated opt_mac.h include. Discussed with: pjd
* Fix typo.kib2009-04-281-2/+2
|
* Eliminate an errant comment.alc2009-04-261-2/+1
| | | | Discussed with: tegge
* Eliminate unnecessary calls to pmap_clear_modify(). Specifically, callingalc2009-04-251-8/+8
| | | | | | | | | pmap_clear_modify() on a page is pointless if that page is not mapped or it is only mapped for read access. Instead, assert that the page is not mapped or not mapped for write access as appropriate. Eliminate unnecessary clearing of a page's dirty mask. Instead, assert that the page's dirty mask is clear.
* Eliminate stale comments.alc2009-02-201-4/+0
|
* Move the code for doing out-of-memory grass from vm_pageout_scan()kib2008-09-291-3/+6
| | | | | | | | | | | | into the separate function vm_pageout_oom(). Supply a parameter for vm_pageout_oom() describing a reason for the call. Call vm_pageout_oom() from the swp_pager_meta_build() when swap zone is exhausted. Reviewed by: alc Tested by: pho, jhb MFC after: 2 weeks
* Decontextualize the couplet VOP_GETATTR / VOP_SETATTR as the passed threadattilio2008-08-281-1/+1
| | | | | | was always curthread and totally unuseful. Tested by: Giovanni Trematerra <giovanni dot trematerra at gmail dot com>
* If the kernel has run out of metadata for swap, then explicitly panic()jhb2008-07-301-1/+1
| | | | | | instead of emitting a warning before deadlocking. MFC after: 1 month
* Use the VM_ALLOC_INTERRUPT for the page requests when allocating memorykib2008-07-111-7/+5
| | | | | | | | | | | | | | | for the bio for swapout write. It allows the page allocator to drain free page list deeper. As result, a deadlock where pageout deamon sleeps waiting for bio to be allocated for swapout is no more reproducable in practice. Alan said that M_USE_RESERVE shall be ressurrected and used there, but until this is implemented, M_NOWAIT does exactly what is needed. Tested by: pho, kris Reviewed by: alc No objections from: phk MFC after: 2 weeks (RELENG_7 only)
* add malloc flag to blist so that it can be used in ithread contextkmacy2008-05-051-1/+1
| | | | Reviewed by: alc, bsdimp
* VOP_LOCK1() (and so VOP_LOCK()) and VOP_UNLOCK() are only used inattilio2008-01-131-3/+3
| | | | | | | | | | | conjuction with 'thread' argument passing which is always curthread. Remove the unuseful extra-argument and pass explicitly curthread to lower layer functions, when necessary. KPI results broken by this change, which should affect several ports, so version bumping and manpage update will be further committed. Tested by: kris, pho, Diego Sardina <siarodx at gmail dot com>
* vn_lock() is currently only used with the 'curthread' passed as argument.attilio2008-01-101-3/+3
| | | | | | | | | | | | | | | | Remove this argument and pass curthread directly to underlying VOP_LOCK1() VFS method. This modify makes the code cleaner and in particular remove an annoying dependence helping next lockmgr() cleanup. KPI results, obviously, changed. Manpage and FreeBSD_version will be updated through further commits. As a side note, would be valuable to say that next commits will address a similar cleanup about VFS methods, in particular vop_lock1 and vop_unlock. Tested by: Diego Sardina <siarodx at gmail dot com>, Andrea Di Pasquale <whyx dot it at gmail dot com>
* When MAC is enabled in the kernel, fix a panic triggered by a lockingcsjp2008-01-081-8/+8
| | | | | | | | | | | | | | assertion hit in swapoff_one() when we un-mount a swap partition. We should be using curthread where we used thread0 before. This change also replaces the thread argument with a credential argument, as the MAC framework only requires the cred. It should be noted that this allows the machine to be rebooted without panicing with "cannot differ from curthread or NULL" when MAC is enabled. Submitted by: rwatson Reviewed by: attilio MFC after: 2 weeks
* o Fix panic message: it's swap_pager_putpages() not swap_pager_getpages().maxim2007-11-021-1/+1
| | | | Submitted by: Mark Tinguely
* Merge first in a series of TrustedBSD MAC Framework KPI changesrwatson2007-10-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | from Mac OS X Leopard--rationalize naming for entry points to the following general forms: mac_<object>_<method/action> mac_<object>_check_<method/action> The previous naming scheme was inconsistent and mostly reversed from the new scheme. Also, make object types more consistent and remove spaces from object types that contain multiple parts ("posix_sem" -> "posixsem") to make mechanical parsing easier. Introduce a new "netinet" object type for certain IPv4/IPv6-related methods. Also simplify, slightly, some entry point names. All MAC policy modules will need to be recompiled, and modules not updates as part of this commit will need to be modified to conform to the new KPI. Sponsored by: SPARTA (original patches against Mac OS X) Obtained from: TrustedBSD Project, Apple Computer
* Consider a scenario in which one processor, call it Pt, is performingalc2007-08-051-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | vm_object_terminate() on a device-backed object at the same time that another processor, call it Pa, is performing dev_pager_alloc() on the same device. The problem is that vm_pager_object_lookup() should not be allowed to return a doomed object, i.e., an object with OBJ_DEAD set, but it does. In detail, the unfortunate sequence of events is: Pt in vm_object_terminate() holds the doomed object's lock and sets OBJ_DEAD on the object. Pa in dev_pager_alloc() holds dev_pager_sx and calls vm_pager_object_lookup(), which returns the doomed object. Next, Pa calls vm_object_reference(), which requires the doomed object's lock, so Pa waits for Pt to release the doomed object's lock. Pt proceeds to the point in vm_object_terminate() where it releases the doomed object's lock. Pa is now able to complete vm_object_reference() because it can now complete the acquisition of the doomed object's lock. So, now the doomed object has a reference count of one! Pa releases dev_pager_sx and returns the doomed object from dev_pager_alloc(). Pt now acquires dev_pager_mtx, removes the doomed object from dev_pager_object_list, releases dev_pager_mtx, and finally calls uma_zfree with the doomed object. However, the doomed object is still in use by Pa. Repeating my key point, vm_pager_object_lookup() must not return a doomed object. Moreover, the test for the object's state, i.e., doomed or not, and the increment of the object's reference count should be carried out atomically. Reviewed by: kib Approved by: re (kensmith) MFC after: 3 weeks
* Eliminate GIANT_REQUIRED from swap_pager_putpages().alc2007-06-241-1/+0
| | | | | Approved by: re (mux) MFC after: 1 week
* Do proper "locking" for missing vmmeters part.attilio2007-06-041-5/+5
| | | | | | | | Now, we assume no more sched_lock protection for some of them and use the distribuited loads method for vmmeter (distribuited through CPUs). Reviewed by: alc, bde Approved by: jeff (mentor)
* Revert VMCNT_* operations introduction.attilio2007-05-311-8/+8
| | | | | | | | Probabilly, a general approach is not the better solution here, so we should solve the sched_lock protection problems separately. Requested by: alc Approved by: jeff (mentor)
* Revert UF_OPENING workaround for CURRENT.kib2007-05-311-1/+1
| | | | | | | | | Change the VOP_OPEN(), vn_open() vnode operation and d_fdopen() cdev operation argument from being file descriptor index into the pointer to struct file. Proposed and reviewed by: jhb Reviewed by: daichi (unionfs) Approved by: re (kensmith)
* - define and use VMCNT_{GET,SET,ADD,SUB,PTR} macros for manipulatingjeff2007-05-181-8/+8
| | | | | | | | vmcnts. This can be used to abstract away pcpu details but also changes to use atomics for all counters now. This means sched lock is no longer responsible for protecting counts in the switch routines. Contributed by: Attilio Rao <attilio@FreeBSD.org>
* Audit pathnames looked up in swapon(2) and swapoff(2).rwatson2007-04-231-2/+4
| | | | | MFC after: 2 weeks Obtained from: TrustedBSD Project
* Use pause() rather than tsleep() on stack variables and function pointers.jhb2007-02-271-2/+1
|
* - Move 'struct swdevt' back into swap_pager.h and expose it to userland.jhb2007-02-071-31/+0
| | | | | | | | - Restore support for fetching swap information from crash dumps via kvm_get_swapinfo(3) to fix pstat -T/-s on crash dumps. Reviewed by: arch@, phk MFC after: 1 week
* - Add a new function uma_zone_exhausted() to see if a zone is full.jhb2007-01-051-0/+2
| | | | | | | | | - Add a printf in swp_pager_meta_build() to warn if the swapzone becomes exhausted so that there's at least a warning before a box that runs out of swapzone space before running out of swap space deadlocks. MFC after: 1 week Reviwed by: alc
* Sweep kernel replacing suser(9) calls with priv(9) calls, assigningrwatson2006-11-061-5/+5
| | | | | | | | | | | | | specific privilege names to a broad range of privileges. These may require some future tweaking. Sponsored by: nCircle Network Security, Inc. Obtained from: TrustedBSD Project Discussed on: arch@ Reviewed (at least in part) by: mlaier, jmg, pjd, bde, ceri, Alex Lyashkov <umka at sevcity dot net>, Skip Ford <skip dot ford at verizon dot net>, Antoine Brodin <antoine dot brodin at laposte dot net>
* The page queues lock is no longer required by vm_page_wakeup().alc2006-10-231-2/+2
|
* Complete break-out of sys/sys/mac.h into sys/security/mac/mac_framework.hrwatson2006-10-221-1/+2
| | | | | | | | | | | | | begun with a repo-copy of mac.h to mac_framework.h. sys/mac.h now contains the userspace and user<->kernel API and definitions, with all in-kernel interfaces moved to mac_framework.h, which is now included across most of the kernel instead. This change is the first step in a larger cleanup and sweep of MAC Framework interfaces in the kernel, and will not be MFC'd. Obtained from: TrustedBSD Project Sponsored by: SPARTA
* Introduce a field to struct vm_page for storing flags that arealc2006-08-091-12/+9
| | | | | | | | | | | | | | | | synchronized by the lock on the object containing the page. Transition PG_WANTED and PG_SWAPINPROG to use the new field, eliminating the need for holding the page queues lock when setting or clearing these flags. Rename PG_WANTED and PG_SWAPINPROG to VPO_WANTED and VPO_SWAPINPROG, respectively. Eliminate the assertion that the page queues lock is held in vm_page_io_finish(). Eliminate the acquisition and release of the page queues lock around calls to vm_page_io_finish() in kern_sendfile() and vfs_unbusy_pages().
* Remove a stale comment.alc2006-08-051-5/+0
|
* When sleeping on a busy page, use the lock from the containing objectalc2006-08-031-4/+4
| | | | rather than the global page queues lock.
* Use better order here.pjd2006-05-101-1/+1
|
* On shutdown try to turn off all swap devices. This way GEOM providers arepjd2006-04-101-19/+62
| | | | | | | | properly closed on shutdown. Requested by: ru Reviewed by: alc MFC after: 2 weeks
* Remove leading __ from __(inline|const|signed|volatile). They areimp2006-03-081-1/+1
| | | | obsolete. This should reduce diffs to NetBSD as well.
* Make sure b_vp and b_bufobj are NULL before calling relpbuf(), as it assertscognet2006-01-271-0/+9
| | | | | | | they are. They should be NULL at this point, except if we're coming from swapdev_strategy(). It should only affect the case where we're swapping directly on a file over NFS.
* Make sure we have a bufobj before calling bstrategy().cognet2005-09-211-1/+3
| | | | | | | I'm not sure this is the right thing to do, but at least I don't panic anymore when swapping on a NFS file without using md(4). X-MFC after: proper review
* Eliminate inconsistency in the setting of the B_DONE flag. Specifically,alc2005-07-201-2/+0
| | | | | | | | | | | | | | | | make the b_iodone callback responsible for setting it if it is needed. Previously, it was set unconditionally by bufdone() without holding whichever lock is shared by the b_iodone callback and the corresponding top-half function. Consequently, in a race, the top-half function could conclude that operation was done before the b_iodone callback finished. See, for example, aio_physwakeup() and aio_fphysio(). Note: I don't believe that the other, more widely-used b_iodone callbacks are affected. Discussed with: jeff Reviewed by: phk MFC after: 2 weeks
* Reduce the number of times that we acquire and release locks inalc2005-05-201-8/+6
| | | | | | swap_pager_getpages(). MFC after: 1 week
* Remove calls to spl*().alc2005-05-191-43/+0
|
* Revert revision 1.270: swp_pager_async_iodone() need not performalc2005-05-181-2/+0
| | | | | | VM_LOCK_GIANT(). Discussed with: jeff
* - VM_LOCK_GIANT in the swap pager's iodone routine as VFS will soon call itjeff2005-04-301-0/+2
| | | | | | without Giant. Sponsored by: Isilon Systems, Inc.
* - Pass the ISOPEN flag to namei so filesystems will know we're about tojeff2005-04-271-1/+1
| | | | open them or otherwise access the data.
* Move the swap_zone == NULL check earlier (i.e. before we dereferencedas2005-03-181-2/+2
| | | | | | the pointer.) Found by: Coverity Prevent analysis tool
* /* -> /*- for license, minor formatting changesimp2005-01-071-1/+1
|
* When allocating bio's in the swap_pager use M_WAITOK since thephk2005-01-031-6/+7
| | | | alternative is much worse.
* Disable U area swapping and remove the routines that create, destroy,das2004-11-201-3/+0
| | | | | | copy, and swap U areas. Reviewed by: arch@
OpenPOWER on IntegriCloud