summaryrefslogtreecommitdiff
path: root/sys/uvm/uvm_km.c
AgeCommit message (Collapse)Author
2011-05-24Reimplement uvm/uvm_map.Ariane van der Steldt
vmmap is designed to perform address space randomized allocations, without letting fragmentation of the address space go through the roof. Some highlights: - kernel address space randomization - proper implementation of guardpages - roughly 10% system time reduction during kernel build Tested by alot of people on tech@ and developers. Theo's machines are still happy.
2011-05-10Don't leak swapslots when doing a uvm_km_pgremove and a page is in swap only.Owain Ainsworth
Before we were only calling uao_dropswap() if there was a page, maning that if the buffer was swapped out then we would leak the slot. Quite rare because only pipebuffers should swap from the kernel object, but i've seen panics that implied this had happened (alpha.p for example). ok thib@ after a lot of discussion and checking the semantics.
2011-04-23Fix management of the list of free uvm_km_pages. Seems art@ lost a lineMark Kettenis
when he copied this code from uvm_km_putpage() into km_free(). Found independently by ariane@; ok deraadt@
2011-04-19Add missing call to pmap_update() in km_alloc().Matthew Dempsky
ok deraadt@, miod@
2011-04-19Free the correct pages when we failed to allocate va.Artur Grabowski
2011-04-18Put back the change of pool and malloc into the new km_alloc(9) api.Artur Grabowski
The problems during the hackathon were not caused by this (most likely). prodded by deraadt@ and beck@
2011-04-15unused variable on !PMAP_DIRECTTheo de Raadt
2011-04-15move uvm_pageratop from uvm_pager.c local to a general uvm functionOwain Ainsworth
(uvm_atopg) and use it in uvm_km_doputpage to replace some handrolled code. Shrinks the kernel a trivial amount. ok beck@ and miod@ (who suggested i name it uvm_atopg not uvm_atop)
2011-04-07Do not use NULL in integer comparisons. No functional change.Miod Vallat
ok matthew@ tedu@, also eyeballed by at least krw@ oga@ kettenis@ jsg@
2011-04-06Backout the uvm_km_getpage -> km_alloc conversion. Weird things are happeningArtur Grabowski
and we aren't sure what's causing them. shouted oks by many before I even built a kernel with the diff.
2011-04-05 - Change pool constraints to use kmem_pa_mode instead of uvm_constraint_rangeArtur Grabowski
- Use km_alloc for all backend allocations in pools. - Use km_alloc for the emergmency kentry allocations in uvm_mapent_alloc - Garbage collect uvm_km_getpage, uvm_km_getpage_pla and uvm_km_putpage ariane@ ok
2011-04-04Few minor ninja fixes while this isn't being used anywhere in -current.Artur Grabowski
- Change a few KASSERT(0) into proper panics. - Match the new behavior of single page freeing. - kremove pages and then free them, it's safer. thib@ ok
2011-04-04Better.Artur Grabowski
2011-04-04Make gcc stop whining. pointed out by ariane@.Artur Grabowski
2011-04-04Some minor fixes:Artur Grabowski
- Clarify a comment. - Change all the flags to chars from ints to make the structs smaller.
2011-04-04New unified allocator of kernel memory.Artur Grabowski
We've reached the point where we have a dozen allocators that all do more or less the same thing, but slightly different, with slightly different semantics, slightly different default behaviors and default behaviors that most callers don't expect or want. A random sample on the last general hackathon showed that no one could explain what all the different allocators did. And every time someone needed to do something slightly different a new allocator was written. Unify everything. One single function to allocate multiples of PAGE_SIZE kernel memory. Four arguments: size, how va is allocated, how pa is allocated and misc parameters. Same parameters are passed to the free function so that we don't need to guess what's going on. Functions are currently unused, we'll do one thing at a time to avoid a giant commit. looked at by lots of people, deraadt@ and beck@ are yelling at me to commit.
2010-08-26make the comment explaining the kernel submaps a bit better.Thordur I. Bjornsson
ok art@, oga@
2010-07-22Remove the VM_KMPAGESFREE sysctl. After the pmemrangeThordur I. Bjornsson
changes it was returing a constant 0, changing to cope with those changes makes less sense then just removing as it provides the user with no usefull information. sthen@ grepped the port's tree for me and found not hits, thanks! OK deraadt@, matthew@
2010-07-15the uvm_km_putpage is calling into tangly uvm guts again on not pmap direct.Ted Unangst
go back to something more like the previous design, and have the thread do the heavy lifting. solves vmmaplk panics. ok deraadt oga thib [and even simple diffs are hard to get perfect. help from mdempsky and deraadt]
2010-07-02no need to call uvm_km_free_wakup for the kernel map, uvm_km_free isThordur I. Bjornsson
enough. ok tedu@, art@
2010-07-02add an align argument to uvm_km_kmemalloc_pla.Artur Grabowski
Use uvm_km_kmemalloc_pla with the dma constraint to allocate kernel stacks. Yes, that means DMA is possible to kernel stacks, but only until we've fixed all the scary drivers. deraadt@ ok
2010-07-02Drop the uvm_km_pages.mtx mutex in uvm_km_putpage before we free va's,Thordur I. Bjornsson
as calls to uvm_km_free_wakup can end up in uvm_mapent_alloc which tries to grab this mutex. ok tedu@
2010-06-29Add a no_constraint uvm_constraint_range; use it in the pool code.Thordur I. Bjornsson
ok tedu@, beck@, oga@
2010-06-28Move uvm_km_pages struct declaration and watermark bounds to uvm_km.h, soMiod Vallat
that md code can peek at it, and update m68k !__HAVE_PMAP_DIRECT setup code to the recent uvm_km changes. ok thib@
2010-06-27doh! Use pmap_kenter/pmap_kremove in the backend page allocator to preventThordur I. Bjornsson
recursion in pmap_enter as seen on zaurus. ok art@ also, release a the uvm_km_page.mtx before calling uvm_km_kmemalloc as we can sleep there. ok oga@
2010-06-27uvm constraints. Add two mandatory MD symbols, uvm_md_constraintsThordur I. Bjornsson
which contains the constraints for DMA/memory allocation for each architecture, and dma_constraints which contains the range of addresses that are dma accessable by the system. This is based on ariane@'s physcontig diff, with lots of bugfixes and additions the following additions by my self: Introduce a new function pool_set_constraints() which sets the address range for which we allocate pages for the pool from, this is now used for the mbuf/mbuf cluster pools to keep them dma accessible. The !direct archs no longer stuff pages into the kernel object in uvm_km_getpage_pla but rather do a pmap_extract() in uvm_km_putpages. Tested heavily by my self on i386, amd64 and sparc64. Some tests on alpha and SGI. "commit it" beck, art, oga, deraadt "i like the diff" deraadt
2010-02-12introduce a uvm_km_valloc_try function that won't get a lower level lockTed Unangst
for use by the uvm pseg code. this is the path of least resistance until we sort out how many of these functions we really need. problem found by mikeb ok kettenis oga
2009-07-25Add an extra argument to uvm_unmap_remove(), for the caller to tell itMiod Vallat
whether removing holes or parts of them is allowed or not. Only allow hole removal in uvmspace_free(), when tearing the vmspace down. ok art@
2009-07-22Put the PG_RELEASED changes diff back in.Owain Ainsworth
This has has been tested very very thoroughly on all archs we have excepting 88k and 68k. Please see cvs log for the individual commit messages. ok beck@, thib@
2009-06-17date based reversion of uvm to the 4th May.Owain Ainsworth
More backouts in line with previous ones, this appears to bring us back to a stable condition. A machine forced to 64mb of ram cycled 10GB through swap with this diff and is still running as I type this. Other tests by ariane@ and thib@ also seem to show that it's alright. ok deraadt@, thib@, ariane@
2009-06-16Backout all the PG_RELEASED changes.Owain Ainsworth
This is for the same reason as the earlier backouts, to avoid the bug either added or exposed sometime around c2k9. This *should* be the last one. prompted by deraadt@ ok ariane@
2009-05-05Second step of PG_RELEASED cleanup.Owain Ainsworth
uvm_km deals with kernel memory which is either part of one of the kernel maps, or the main kernel object (a uao). If on km_pgremove we hit a busy page, just sleep on it, if so there's some async io (and that is unlikely). we can remove the check for uvm_km_alloc1() for a released page since now we will never end up with a removed but released page in the kernel map (due to the other chunk and the last diff). ok ariane@. Diff survived several make builds, on amd64 and sparc64, also forced paging with ariane's evil program.
2009-02-22On machines with less than 16MB of physical memory, reduce the lower boundMiod Vallat
of uvm_km_pages. ok deraadt@ tedu@
2009-02-11Remove uvm_km_alloc_poolpage1 as it serves no particular purposeMike Belopuhov
now and valid for __HAVE_PMAP_DIRECT archs only, though implements both code paths. Put it's code directly into the uvm_km_getpage for PMAP_DIRECT archs. No functional change. ok tedu, art
2008-10-23a better fix for the "uvm_km thread runs out of memory" problem.Ted Unangst
add a new arg to the backend so it can tell pool to slow down. when we get this flag, yield *after* putting the page in the pool's free list. whatever we do, don't let the thread sleep. this makes things better by still letting the thread run when a huge pf request comes in, but without artificially increasing pressure on the backend by eating pages without feeding them forward. ok deraadt
2008-06-14If we have one syscall that consumes large amounts of memory (like forArtur Grabowski
example an ioctl that loads bazillions of entries into a pf table) it would exhaust the pool of free pages and not let uvm_km_thread catch up until the pool was actually empty. This could be bad for non-sleeping allocators since they can't wait for the memory while the big hog can. Instead of letting the syscall exhaust the pool, detect when we fall below the low watermark, wake the thread, sleep once and let the thread catch up. This paces the huge consumer so that the more critical consumers never find an exhausted pool of pages. "seems reasonable" kettenis@
2007-12-15export kernel uvm_km_pages_free as vm.kmpagesfree; ok tedu, tested jsgTheo de Raadt
2007-12-11use a mutex for protection of the uvm_km list. ok artTed Unangst
2007-08-03Don't let pagedaemon wait for pages here. We could trigger this easilyArtur Grabowski
when we hit swap before actually fully populating the buffer cache which would lead to deadlocks. From pedro, tested by many, deraadt@ ok
2007-04-29Change the loop test in uvm_km_kmemalloc from '<' to '!='. EverythingArtur Grabowski
is aligned just fine and in case we allocate the last piece of the address space we don't want wrap-around to cause us to fail. pointed out by and ok miod@
2007-04-27Use the right size when we're backing out the allocation inArtur Grabowski
uvm_km_kmemalloc. "should probbaly go in" millert@, "I think it should too" deraadt@
2007-04-15One more voff_t in the right place.Artur Grabowski
miod@ ok
2007-04-15Use the right types for calculating the object offset.Artur Grabowski
miod@ ok
2007-04-15Clean up prototypes, change vm_map_t to struct vm_map *.Artur Grabowski
miod@ ok
2007-04-13While splitting flags and pqflags might have been a good idea in theoryArtur Grabowski
to separate locking, on most modern machines this is not enough since operations on short types touch other short types that share the same word in memory. Merge pg_flags and pqflags again and now use atomic operations to change the flags. Also bump wire_count to an int and pg_version might go int as well, just for alignment. tested by many, many. ok miod@
2007-04-11Instead of managing pages for intrsafe maps in special objects (aka.Artur Grabowski
kmem_object) just so that we can remove them, just use pmap_extract to get the pages to free and simplify a lot of code to not deal with the list of intrsafe maps, intrsafe objects, etc. miod@ ok
2007-04-04Mechanically rename the "flags" and "version" fields in struct vm_pageArtur Grabowski
to "pg_flags" and "pg_version", so that they are a bit easier to work with. Whoever uses generic names like this for a popular struct obviously doesn't read much code. Most architectures compile and there are no functionality changes. deraadt@ ok ("if something fails to compile, we fix that by hand")
2007-03-25remove KERN_SUCCESS and use 0 instead.Artur Grabowski
eyeballed by miod@ and pedro@
2006-11-29We don't use mb_map anymore since a long time already. Remove it.Miod Vallat
2006-11-29Add an alignment parameter to uvm_km_alloc1(), and change all callers toMiod Vallat
pass zero; this will be used shortly. From art@