summaryrefslogtreecommitdiff
path: root/sys/vm/vm_zone.c
Commit message (Collapse)AuthorAgeFilesLines
* There should be no remaining references to these two files in the tree. IfJeff Roberson2002-04-071-579/+0
| | | | | | | there are, it is an error. vm_zone has been superseded by uma. Notes: svn path=/head/; revision=94156
* Change callers of mtx_init() to pass in an appropriate lock type name. InJohn Baldwin2002-04-041-3/+3
| | | | | | | | | | most cases NULL is passed, but in some cases such as network driver locks (which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used. Tested on: i386, alpha, sparc64 Notes: svn path=/head/; revision=93818
* Back out the modification of vm_map locks from lockmgr to sx locks. TheBrian Feldman2002-03-181-6/+6
| | | | | | | | | | | | | best path forward now is likely to change the lockmgr locks to simple sleep mutexes, then see if any extra contention it generates is greater than removed overhead of managing local locking state information, cost of extra calls into lockmgr, etc. Additionally, making the vm_map lock a mutex and respecting it properly will put us much closer to not needing Giant magic in vm. Notes: svn path=/head/; revision=92588
* Convert all pmap_kenter/pmap_kremove pairs in MI code to use pmap_qenter/Jake Burkholder2002-03-171-1/+1
| | | | | | | | | | | | | | | | | | pmap_qremove. pmap_kenter is not safe to use in MI code because it is not guaranteed to flush the mapping from the tlb on all cpus. If the process in question is preempted and migrates cpus between the call to pmap_kenter and pmap_kremove, the original cpu will be left with stale mappings in its tlb. This is currently not a problem for i386 because we do not use PG_G on SMP, and thus all mappings are flushed from the tlb on context switches, not just user mappings. This is not the case on all architectures, and if PG_G is to be used with SMP on i386 it will be a problem. This was committed by peter earlier as part of his fine grained tlb shootdown work for i386, which was backed out for other reasons. Reviewed by: peter Notes: svn path=/head/; revision=92461
* Rename SI_SUB_MUTEX to SI_SUB_MTX_POOL to make the name at all accurate.Brian Feldman2002-03-131-6/+6
| | | | | | | | | | | | | | | | | | | While doing this, move it earlier in the sysinit boot process so that the VM system can use it. After that, the system is now able to use sx locks instead of lockmgr locks in the VM system. To accomplish this, some of the more questionable uses of the locks (such as testing whether they are owned or not, as well as allowing shared+exclusive recursion) are removed, and simpler logic throughout is used so locks should also be easier to understand. This has been tested on my laptop for months, and has not shown any problems on SMP systems, either, so appears quite safe. One more user of lockmgr down, many more to go :) Notes: svn path=/head/; revision=92246
* Back out all the pmap related stuff I've touched over the last few days.Peter Wemm2002-02-271-1/+1
| | | | | | | | | There is some unresolved badness that has been eluding me, particularly affecting uniprocessor kernels. Turning off PG_G helped (which is a bad sign) but didn't solve it entirely. Userland programs still crashed. Notes: svn path=/head/; revision=91367
* Jake further reduced IPI shootdowns on sparc64 in loops by using rangedPeter Wemm2002-02-271-1/+1
| | | | | | | | | | | shootdowns in a couple of key places. Do the same for i386. This also hides some physical addresses from higher levels and has it use the generic vm_page_t's instead. This will help for PAE down the road. Obtained from: jake (MI code, suggestions for MD part) Notes: svn path=/head/; revision=91344
* When laying out objects in a ZONE_INTERRUPT zone, allow them to crossJonathan Lemon2001-11-171-2/+4
| | | | | | | | | | | a page boundary, since we've already allocated all our contiguous kva space up front. This eliminates some memory wastage, and allows us to actually reach the # of objects were specified in the zinit() call. Reviewed by: peter, dillon Notes: svn path=/head/; revision=86475
* Add a missing semicolon to unbreak the kernel build with INVARIANTSThomas Moestl2001-08-051-1/+1
| | | | | | | | | | | (which was unfortunately turned off in the confguration I used for the last test build). Spotted by: jake Pointy hat to: tmm Notes: svn path=/head/; revision=81148
* Add a zdestroy() function to the zone allocator. This is needed for theThomas Moestl2001-08-041-0/+108
| | | | | | | | unload case of modules that use their own zones. It has been tested with the nfs module. Notes: svn path=/head/; revision=81136
* Fix missing newline and terminator at the end of the vm.zone sysctl.Dag-Erling Smørgrav2001-07-091-2/+1
| | | | Notes: svn path=/head/; revision=79443
* With Alfred's permission, remove vm_mtx in favor of a fine-grained approachMatthew Dillon2001-07-041-20/+3
| | | | | | | | | | | | (this commit is just the first stage). Also add various GIANT_ macros to formalize the removal of Giant, making it easy to test in a more piecemeal fashion. These macros will allow us to test fine-grained locks to a degree before removing Giant, and also after, and to remove Giant in a piecemeal fashion via sysctl's on those subsystems which the authors believe can operate without Giant. Notes: svn path=/head/; revision=79224
* Introduce a global lock for the vm subsystem (vm_mtx).Alfred Perlstein2001-05-191-8/+24
| | | | | | | | | | | | | | | | | | | | | | vm_mtx does not recurse and is required for most low level vm operations. faults can not be taken without holding Giant. Memory subsystems can now call the base page allocators safely. Almost all atomic ops were removed as they are covered under the vm mutex. Alpha and ia64 now need to catch up to i386's trap handlers. FFS and NFS have been tested, other filesystems will need minor changes (grabbing the vm lock when twiddling page properties). Reviewed (partially) by: jake, jhb Notes: svn path=/head/; revision=76827
* Address a number of problems with sysctl_vm_zone().Alfred Perlstein2001-04-271-11/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The zone allocator's locks should be leaflocks, meaning that they should never be held when entering into another subsystem, however the sysctl grabs the zone global mutex and individual zone mutexes while holding the lock it calls SYSCTL_OUT which recurses into the VM subsystem in order to wire user memory to do a safe copy. This can block and cause lock order reversals. To fix this: lock zone global. get a count of the number of zones. unlock global. allocate temporary storage. format and SYSCTL_OUT the banner. lock global. traverse list. make sure we haven't looped more than the initial count taken to avoid overflowing the allocated buffer. lock each nodes. read values and format into buffer. unlock individual node. unlock global. format and SYSCTL_OUT the rest of the data. free storage. return. Other problems included not checking for errors when doing sysctl out of the column header. Fixed. Inconsistant termination of the copied string. Fixed. Objected to by: des (for not using sbuf) Since the output is not variable length and I'm actually over allocating signifigantly and I'd like to get this fixed now, I'll work on the sbuf convertion at a later date. I would not object to someone else taking it upon themselves to convert it to sbuf. I hold no MAINTIANER rights to this code (for now). Notes: svn path=/head/; revision=76084
* 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
* Change and clean the mutex lock interface.Bosko Milekic2001-02-091-17/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* 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
* Give this code a major facelift:Dag-Erling Smørgrav2001-01-221-223/+152
| | | | | | | | | | | | | | | | | | | | | | | | | | - 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-211-40/+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
* Make zalloc and zfree non-inline functions. This avoids having toAssar Westerlund2000-12-271-2/+74
| | | | | | | | | | have the code calling these be compiled with the same setting for INVARIANTS and SMP. Reviewed by: dillon Notes: svn path=/head/; revision=70390
* - If swap metadata does not fit into the KVM, reduce the number ofSeigo Tanimura2000-12-131-4/+10
| | | | | | | | | | | | | | | | | | 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
* Previous commit changing SYSCTL_HANDLER_ARGS violated KNF.Poul-Henning Kamp2000-07-041-2/+2
| | | | | | | Pointed out by: bde Notes: svn path=/head/; revision=62573
* Style police catches up with rev 1.26 of src/sys/sys/sysctl.h:Poul-Henning Kamp2000-07-031-2/+2
| | | | | | | | | | | Sanitize SYSCTL_HANDLER_ARGS so that simplistic tools can grog our sources: -sysctl_vm_zone SYSCTL_HANDLER_ARGS +sysctl_vm_zone (SYSCTL_HANDLER_ARGS) Notes: svn path=/head/; revision=62454
* Add missing increment of allocation counter.Jeffrey Hsu2000-06-051-0/+2
| | | | Notes: svn path=/head/; revision=61272
* Fix _zget() so that it checks the return from kmem_alloc(), to avoidMike Smith2000-04-041-3/+9
| | | | | | | | zttempting to bzero NULL when the kernel map fills up. _zget() will now return NULL as it seems it was originally intended to do. Notes: svn path=/head/; revision=59017
* Lock reporting and assertion changes.Eivind Eklund1999-12-111-1/+1
| | | | | | | | | | | | | | | | | | * lockstatus() and VOP_ISLOCKED() gets a new process argument and a new return value: LK_EXCLOTHER, when the lock is held exclusively by another process. * The ASSERT_VOP_(UN)LOCKED family is extended to use what this gives them * Extend the vnode_if.src format to allow more exact specification than locked/unlocked. This commit should not do any semantic changes unless you are using DEBUG_VFS_LOCKS. Discussed with: grog, mch, peter, phk Reviewed by: peter Notes: svn path=/head/; revision=54444
* useracc() the prequel:Poul-Henning Kamp1999-10-291-1/+0
| | | | | | | | | | | | | | Merge the contents (less some trivial bordering the silly comments) of <vm/vm_prot.h> and <vm/vm_inherit.h> into <vm/vm.h>. This puts the #defines for the vm_inherit_t and vm_prot_t types next to their typedefs. This paves the road for the commit to follow shortly: change useracc() to use VM_PROT_{READ|WRITE} rather than B_{READ|WRITE} as argument. Notes: svn path=/head/; revision=52635
* Plug an accounting leak: count pages in ZONE_INTERRUPT zones as wired.Dmitrij Tejblum1999-09-301-0/+2
| | | | Notes: svn path=/head/; revision=51810
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* KNFize, by bde.Eivind Eklund1999-01-101-5/+5
| | | | Notes: svn path=/head/; revision=42453
* Split DIAGNOSTIC -> DIAGNOSTIC, INVARIANTS, and INVARIANT_SUPPORT asEivind Eklund1999-01-081-5/+5
| | | | | | | | | | | | discussed on -hackers. Introduce 'KASSERT(assertion, ("panic message", args))' for simple check + panic. Reviewed by: msmith Notes: svn path=/head/; revision=42408
* Examine all occurrences of sprintf(), strcat(), and str[n]cpy()Archie Cobbs1998-12-041-3/+4
| | | | | | | | | | | | | | | | | for possible buffer overflow problems. Replaced most sprintf()'s with snprintf(); for others cases, added terminating NUL bytes where appropriate, replaced constants like "16" with sizeof(), etc. These changes include several bug fixes, but most changes are for maintainability's sake. Any instance where it wasn't "immediately obvious" that a buffer overflow could not occur was made safer. Reviewed by: Bruce Evans <bde@zeta.org.au> Reviewed by: Matthew Dillon <dillon@apollo.backplane.com> Reviewed by: Mike Spengler <mks@networkcs.com> Notes: svn path=/head/; revision=41514
* Add John Dyson's SYSCTL descriptions, and an export of more stats toPeter Wemm1998-10-311-4/+4
| | | | | | | | a sysctl hierarchy (vm.stats.*). SYSCTL descriptions are only present in source, they do not get compiled into the binaries taking up memory. Notes: svn path=/head/; revision=40794
* Fix a panic on SMP systems, caused by sleeping while holding aJohn Polstra1998-10-091-1/+13
| | | | | | | | | | | | | | | | | | | | | | simple-lock. The reviewer raises the following caveat: "I believe these changes open a non-critical race condition when adding memory to the pool for the zone. I think what will happen is that you could have two threads that are simultaneously adding additional memory when the pool runs out. This appears to not be a problem, however, since the re-aquisition of the lock will protect the list pointers." The submitter agrees that the race is non-critical, and points out that it already existed for the non-SMP case. He suggests that perhaps a sleep lock (using the lock manager) should be used to close that race. This might be worth revisiting after 3.0 is released. Reviewed by: dg (David Greenman) Submitted by: tegge (Tor Egge) Notes: svn path=/head/; revision=40087
* Correct copyright.John Dyson1998-04-251-2/+2
| | | | Notes: svn path=/head/; revision=35447
* Support compiling with `gcc -ansi'.Bruce Evans1998-04-151-3/+3
| | | | Notes: svn path=/head/; revision=35210
* Try to dynamically size the VM_KMEM_SIZE (but is still able to be overriddenJohn Dyson1998-02-231-2/+14
| | | | | | | | | | | | | | | in a way identically as before.) I had problems with the system properly handling the number of vnodes when there is alot of system memory, and the default VM_KMEM_SIZE. Two new options "VM_KMEM_SIZE_SCALE" and "VM_KMEM_SIZE_MAX" have been added to support better auto-sizing for systems with greater than 128MB. Add some accouting for vm_zone memory allocations, and provide properly for vm_zone allocations out of the kmem_map. Also move the vm_zone allocation stats to the VM OID tree from the KERN OID tree. Notes: svn path=/head/; revision=33757
* Staticize.Eivind Eklund1998-02-091-4/+4
| | | | Notes: svn path=/head/; revision=33181
* Back out DIAGNOSTIC changes.Eivind Eklund1998-02-061-3/+1
| | | | Notes: svn path=/head/; revision=33134
* Turn DIAGNOSTIC into a new-style option.Eivind Eklund1998-02-041-1/+3
| | | | Notes: svn path=/head/; revision=33108
* VM level code cleanups.John Dyson1998-01-221-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Improve my copyright.John Dyson1997-12-221-9/+2
| | | | Notes: svn path=/head/; revision=31935
* Fix a recursive kernel_map lock problem in vm_zone allocator.John Dyson1997-12-151-19/+23
| | | | | | | PR: 5298 Notes: svn path=/head/; revision=31729
* Slight improvement to the vm_zone stats output. Also, some other superficialJohn Dyson1997-12-141-4/+9
| | | | | | | cleanups. Notes: svn path=/head/; revision=31712
* Don't include <sys/lock.h> in headers when only `struct simplelock' isBruce Evans1997-12-051-1/+2
| | | | | | | required. Fixed everything that depended on the pollution. Notes: svn path=/head/; revision=31561
* Last major round (Unless Bruce thinks of somthing :-) of malloc changes.Poul-Henning Kamp1997-10-121-2/+2
| | | | | | | | | | | Distribute all but the most fundamental malloc types. This time I also remembered the trick to making things static: Put "static" in front of them. A couple of finer points by: bde Notes: svn path=/head/; revision=30354
* Distribute and statizice a lot of the malloc M_* types.Poul-Henning Kamp1997-10-111-1/+3
| | | | | | | Substantial input from: bde Notes: svn path=/head/; revision=30309
* Fix some style(9) and formatting problems. tabsize 4 formatting doesn'tPeter Wemm1997-09-211-63/+78
| | | | | | | | | look too great with 'more' etc. Approved by: dyson (with a minor grumble :-) Notes: svn path=/head/; revision=29657
* Change the M_NAMEI allocations to use the zone allocator. This changeJohn Dyson1997-09-211-8/+62
| | | | | | | | | | | plus the previous changes to use the zone allocator decrease the useage of malloc by half. The Zone allocator will be upgradeable to be able to use per CPU-pools, and has more intelligent usage of SPLs. Additionally, it has reasonable stats gathering capabilities, while making most calls inline. Notes: svn path=/head/; revision=29653