Commit Graph

1086 Commits

Author SHA1 Message Date
yamt b63b4e8324 - make uvm_swap_stats acquire swap_syscall_lock by itsself
so that callers don't need to acquire it beforehand.
- make swap_syscall_lock static.
2005-09-17 14:51:50 +00:00
yamt d597202302 make VMSWAP optional again. 2005-09-17 14:38:38 +00:00
yamt 1f6a8b12c5 uao_put: don't skip loaned or wired pages. 2005-09-14 20:25:21 +00:00
yamt 6fbf5bf6f1 wrap swap related code by #ifdef VMSWAP. always #define VMSWAP for now. 2005-09-13 22:00:05 +00:00
yamt 873763ea0f uao_put: recognize endoff == 0 as "to the end of the object",
as VOP_PUTPAGES (thus vnode pager) does.  for tmpfs.
2005-09-13 19:54:09 +00:00
yamt 74be61b2e6 remove one of duplicated forward decl. of vmspace. pointed by Dheeraj S. 2005-09-01 02:21:12 +00:00
yamt b34f62d5e9 put back uvm_fault.h for now as it's needed for some ports. 2005-09-01 02:16:46 +00:00
yamt be5d1db4a4 don't include uvm_fault.h unnecessarily. 2005-08-27 16:11:32 +00:00
yamt 38ca5312d2 revert "defflag VMSWAP" changes for now.
there seems to be far more people who don't want to edit
their kernel config files than i thought.
2005-07-31 04:04:30 +00:00
yamt 1d0891101c defflag VMSWAP. 2005-07-30 06:33:33 +00:00
yamt b7bfe82866 update file timestamps for nfsd loaned-read and mmap.
PR/25279.  discussed on tech-kern@.
2005-07-23 12:18:41 +00:00
yamt 62cab9eab7 uvm_fault: check a correct object in the case of layered filesystems.
fix PR/30811 from Jukka Salmi.
2005-07-22 14:57:39 +00:00
yamt 8af42d8d3c ensure that vnodes with dirty pages are always on syncer's queue.
- genfs_putpages: wait for i/o completion of PG_RELEASED/PG_PAGEOUT pages by
  setting "wasclean" false when encountering them.
  suggested by Stephan Uphoff in PR/24596 (1).

- genfs_putpages: write protect pages when cleaning out, if
  we're going to take the vnode off the syncer's queue.
  uvm_fault: don't write-map pages unless its vnode is already on
  the syncer's queue.

  fix PR/24596 (3) but in the different way from the suggested fix.
  (to keep our current behaviour, ie. not to require explicit msync.
  discussed on tech-kern@.)

- genfs_putpages: don't mistakenly take a vnode off the queue
  by introducing a generation number in genfs_node.
  genfs_getpages: increment the generation number.
  suggested by Stephan Uphoff in PR/24596 (2).

- add some assertions.
2005-07-17 12:27:47 +00:00
yamt 2a6dc9d02d - introduce PGO_NOBLOCKALLOC and use it for ubc mapping
to prevent unnecessary block allocations in the case that
  page size > block size.

- ufs_balloc_range: use VM_PROT_WRITE+PGO_NOBLOCKALLOC rather than
  VM_PROT_READ.
2005-07-17 09:13:35 +00:00
thorpej 5303f3b378 Clean up the cpp macro used to say "we're compiling this specific C file". 2005-06-28 05:25:42 +00:00
thorpej 9057ed7600 Make a note about why a large function like uvm_loanentry() can be
an inline in this case.
2005-06-28 04:06:52 +00:00
thorpej 8d3ff810fa Add missing PAGE_INLINE to uvm_pagelookup() 2005-06-28 04:00:07 +00:00
thorpej fcd6584a58 Clean up the use of __inline in this file. In particular, don't inline
really big chunks of code.  This saves almost 2.5K on a GENERIC i386
kernel, and has the added benefit of not polluting the I$ so much.
2005-06-28 01:07:56 +00:00
thorpej b651fb886d Sprinkle some static. 2005-06-27 02:29:32 +00:00
thorpej 154a970ff4 Small whitespace tweak. 2005-06-27 02:23:26 +00:00
thorpej e569facced Use ANSI function decls. 2005-06-27 02:19:48 +00:00
jmc 1786cf4f46 Change signature of uvm_kmapent_map defintiion to __INLINE to match prototype 2005-06-13 20:39:14 +00:00
dsl d68ddde829 If we are builging a small kernel [1], don't inline all these functions.
Saves over 2k and lets i386 rescue_tiny build again.
[1] if MALLOC_NOINLINE is defined - not ideal but...
2005-06-10 22:00:52 +00:00
matt e1245a3c46 Rework the coredump code to have no explicit knownledge of how coredump
i/o is done.  Instead, pass an opaque cookie which is then passed to a
new routine, coredump_write, which does the actual i/o.  This allows the
method of doing i/o to change without affecting any future MD code.
Also, make netbsd32_core.c [re]use core_netbsd.c (in a similar manner that
core_elf64.c uses core_elf32.c) and eliminate that code duplication.
cpu_coredump{,32} is now called twice, first with a NULL iocookie to fill
the core structure and a second to actually write md parts of the coredump.
All i/o is nolonger random access and is suitable for shipping over a stream.
2005-06-10 05:10:12 +00:00
matt bb583a82ce Make sure state.end has a valid initial value. 2005-06-07 22:02:48 +00:00
yamt 11bfc2d8e1 introduce a macro to initialize uvm_object and use it. 2005-06-06 12:09:19 +00:00
chs 48e4eb59a3 adapt to const changes. 2005-06-04 13:48:35 +00:00
matt 25a0e29a75 When writing coredumps, don't write zero uninstantiated demand-zero pages.
Also, with ELF core dumps, trim trailing zeroes from sections.  These two
changes can shrink coredumps by over 50% in size.
2005-06-02 17:01:43 +00:00
drochner d481be4d04 prepend an underscore to local variables in macros, to avoid shadowing
user defined ones
2005-06-01 18:03:50 +00:00
christos e715d2ee98 avoid shadow variables.
remove unneeded casts.
2005-05-29 21:06:33 +00:00
yamt faf63ba09b uvm_kmapent_free: add missing vm_map_lock/unlock. 2005-05-22 21:37:56 +00:00
yamt ea66ccc0a5 uvm_mapent_trymerge: adjust object offset when necessary. 2005-05-18 01:36:16 +00:00
yamt 9dcbe8b85f redo the previous (uvm_map.c rev.1.195) correctly. 2005-05-18 01:34:53 +00:00
yamt 1d028221a3 uvm_mapent_trymerge: add missing checks. 2005-05-17 21:45:24 +00:00
yamt 50a25acc50 (try to) merge map entries in fault handler. 2005-05-17 13:55:33 +00:00
yamt 1e5d4510fa revert uvm_map.c rev.1.190 in favor of merging in fault handler. 2005-05-17 13:54:19 +00:00
yamt 627b0d5099 remove anon related statistics which are no longer used. 2005-05-15 08:01:06 +00:00
yamt 662ada8f7a allocate anons on-demand, rather than reserving static amount of
them on boot/swapon.
2005-05-11 13:02:25 +00:00
nathanw 92279c692f uvm_coredump_walkmap(): Set UVM_COREDUMP_NODUMP on regions whose
protection does not include VM_PROT_READ, so that the core dumping
doesn't error out with EFAULT when trying to write that region.

Addresses PR kern/30143; approach suggested by chs@.
2005-05-06 19:34:47 +00:00
yamt ae24d5d705 - amap_extend: don't extend amap beyond UVM_AMAP_LARGE.
- uvm_map_enter: if we fail to extend amap, just give up merging instead of
  bailing out immediately.
2005-05-05 01:58:51 +00:00
yamt 192e24a575 uvm_reclaimable: add an XXX comment. 2005-05-04 23:23:28 +00:00
yamt 9aacd16106 uvm_map_enter: don't bother to defer amap allocation if there's a mergable
existing entry.  although there're merits and demerits, i think it benefits
common cases.
2005-04-29 09:05:21 +00:00
yamt 1e67869b4b uvm_map: don't leak a preallocated map entry on error. 2005-04-28 14:40:43 +00:00
yamt 7f37519f2c uvmfault_anonget: check uvm_reclaimable() where appropriate. 2005-04-27 15:19:17 +00:00
yamt 4c61e81438 uvmexp_print: print swpgavail as well. 2005-04-27 11:02:43 +00:00
simonb eddbeffa06 Use a cast to (long long) and 0x%llx to print out a paddr_t instead
of casting to (void *).  Fixes compile problems with 64-bit paddr_t
on 32-bit platforms.
2005-04-20 14:10:03 +00:00
yamt 01c07ef7bd fix unreasonably frequent "killed: out of swap" on systems which have
little or no swap.
- even on a severe swap shortage, if we have some amount of file-backed pages,
  don't bother to kill processes.
- if all pages in queue will be likely reactivated, just give up
  page type balancing rather than spinning unnecessarily.
2005-04-12 13:11:45 +00:00
dbj 2939014883 use voff_t instead of vaddr_t to hold file offset passed to pgo_put 2005-04-07 06:44:15 +00:00
yamt a7cd6f7a0e amap_wipeout: remove a comment which is no longer true.
despite of what comment said, i left preempt() call
because i don't think of any bad effects.
2005-04-06 13:58:40 +00:00
yamt b02ae403bb switch swap space allocation code to use blist instead of extent(9).
fix "warning: resource shortage: %d pages of swap lost".

extent(9) has some undesirable characteristics for swap allocation:
	- it involves alloc-to-free.
	- its operational cost is O(n*n) where n is number of entries.
2005-04-06 13:51:33 +00:00
yamt cde0e21683 unwrap short lines. 2005-04-01 12:37:27 +00:00
yamt 6b2d8b66a4 merge yamt-km branch.
- don't use managed mappings/backing objects for wired memory allocations.
  save some resources like pv_entry.  also fix (most of) PR/27030.
- simplify kernel memory management API.
- simplify pmap bootstrap of some ports.
- some related cleanups.
2005-04-01 11:59:21 +00:00
fvdl c487efe4a7 Fix some things regarding COMPAT_NETBSD32 and limits/VM addresses.
* For sparc64 and amd64, define *SIZ32 VM constants.
* Add a new function pointer to struct emul, pointing at a function
  that will return the default VM map address. The default function
  is uvm_map_defaultaddr, which just uses the VM_DEFAULT_ADDRESS
  macro. This gives emulations control over the default map address,
  and allows things to be mapped at the right address (in 32bit range)
  for COMPAT_NETBSD32.
* Add code to adjust the data and stack limits when a COMPAT_NETBSD32
  or COMPAT_SVR4_32 binary is executed.
* Don't use USRSTACK in kern_resource.c, use p_vmspace->vm_minsaddr
  instead (emulations might have set it differently)
* Since this changes struct emul, bump kernel version to 3.99.2

Tested on amd64, compile-tested on sparc64.
2005-03-26 05:12:34 +00:00
chs 6e3fb7b0d2 add back rev. 1.29 of vm/vm_map.c, which was apparently lost in the UVM merge:
msync(MS_INVALIDATE) should fail if any part of the region is wired.
2005-02-28 16:55:54 +00:00
chs 64d6a08278 use TRUE and FALSE instead of 1 and 0 for boolean_t. 2005-02-28 15:33:04 +00:00
chs 81a6b7303b add some locking assertions. 2005-02-28 15:31:04 +00:00
perry bcfcddbac1 nuke trailing whitespace 2005-02-26 22:31:44 +00:00
chs 467487d274 use vm_map_{min,max}() instead of dereferencing the vm_map pointer directly.
define and use vm_map_set{min,max}() for modifying these values.
remove the {min,max}_offset aliases for these vm_map fields to be more
namespace-friendly.  PR 26475.
2005-02-11 02:12:03 +00:00
yamt a8acd82f94 update a comment; malloc doesn't use uvm_kernacc anymore. 2005-02-08 08:22:37 +00:00
yamt 9fe116ce3a uvm_fault: fix integer overflow so that MADV_SEQUENTIAL
can work on large files.
2005-02-07 11:57:38 +00:00
chs 6390d0aeca hack around a UVM problem that causes hangs when large processes fork.
see PR 26908 for details.
2005-01-30 17:23:05 +00:00
chs ad79fc3015 move the call to link_pool_init() to the end of uvm_init(). needed for sun3. 2005-01-23 19:02:02 +00:00
chs b0c54c738d pmap_wired_count() is now available on all platforms,
remove the code for the case where it's not defined.
2005-01-23 15:58:13 +00:00
chs 7c203c91d4 reduce the size of user coredump files by not dumping regions of
the address space that have never been touched (such as much of the
virtual space allocated for pthread stacks).
2005-01-21 03:24:40 +00:00
atatat a076957818 Convert the PMAP_PREFER() macro from two arguments (offset and hint)
to four (adding size and direction).

In order for topdown uvm to be an option on ports using PMAP_PREFER,
they will need to "prefer" lower addresses if topdown is being used.
Additionally, at least one port also needs to know the size.
2005-01-17 04:37:20 +00:00
yamt b855149311 remove no longer needed #include. 2005-01-16 06:48:38 +00:00
chs a877481d76 deal with alpha's architectural failing of not being able to operate on
memory quantities smaller than 32 bits.
2005-01-15 15:10:49 +00:00
yamt 3068e2f45a don't use uvm_kmapent_alloc for non-intrsafe kernel submaps
(namely exec_map and phys_map) becuase:
- normal vmmpepl is fine for them.
- some of them are tightly sized.  eg. size of exec_map on vax is just NCARGS.

should fix vax boot failure reported by Johnny Billquist on current-users@.
2005-01-14 14:25:40 +00:00
yamt 22099ab744 in uvm_unmap_remove, always wakeup va waiters if any.
uvm_km_free_wakeup is now a synonym of uvm_km_free.
2005-01-13 11:50:32 +00:00
yamt e4666bf785 don't reserve (uvm_mapent_reserve) entries for malloc/pool backends
because it isn't necessary or safe.
reported and tested by Denis Lagno.  PR/28897.
2005-01-12 09:34:35 +00:00
chs 8975a0856f adjust the UBC mapping code to support non-vnode uvm_objects.
this means we can no longer look at the vnode size to determine how many
pages to request in a fault, which is good since for NFS the size can change
out from under us on the server anyway.  there's also a new flag UBC_UNMAP
for ubc_release(), so that the file system code can make the decision about
whether to cache mappings for files being used as executables.
2005-01-09 16:42:43 +00:00
yamt 22cf117f61 km_vacache_alloc: UVM_PROT_ALL rather than UVM_PROT_NONE
so that uvm_kernacc works.  PR/28861. (FUKAUMI Naoki)
2005-01-05 00:58:57 +00:00
yamt 546bb99833 reapply uvm_map.c rev.1.156 (use a zero-sized array instead of
c99 flexible array member) for ports which still use gcc 2.95.
from Havard Eidnes.
2005-01-03 19:46:22 +00:00
yamt 0c5ceb72e4 km_vacache_alloc: specify va hint correctly rather than
using stack garbage.  PR/28845.
2005-01-03 04:01:13 +00:00
yamt 3983ffcfb1 uvm_unmap_remove: debug check to ensure that
unmapped regions doesn't have any remaining page mappings.
2005-01-01 21:12:59 +00:00
yamt 592c954dc7 don't merge incompatible map entries. eg. private and shared. 2005-01-01 21:11:51 +00:00
yamt a880e5e2b5 in the case of !PMAP_MAP_POOLPAGE, gather pool backend allocations to
large chunks for kernel_map and kmem_map to ease kva fragmentation.
2005-01-01 21:08:02 +00:00
yamt 95c82bfee4 introduce vm_map_kernel, a subclass of vm_map, and
move some kernel-only members of vm_map to it.
2005-01-01 21:02:12 +00:00
yamt 1207308b90 for in-kernel maps,
- allocate kva for vm_map_entry from the map itsself and
  remove the static limit, MAX_KMAPENT.
- keep merged entries for later splitting to fix allocate-to-free problem.
  PR/24039.
2005-01-01 21:00:06 +00:00
yamt c4d95d51f4 uvm_fault: pass NULL pap to pmap_extract where we don't need paddr. 2005-01-01 09:14:49 +00:00
briggs ddcb68edd6 mlock(2) and munlock(2) are defined by our man pages (which agree with
those on opengroup.org) to return ENOMEM if trying to lock a region that
is not accessible.  So if uvm_map_pageable() returns EFAULT, make it ENOMEM.
2004-12-02 15:23:47 +00:00
yamt 90f65b5587 UVMHIST_LOG: avoid division. 2004-11-23 05:08:33 +00:00
yamt 040648dfd0 constify. 2004-11-23 04:57:17 +00:00
yamt f25d78c712 introduce UVMHIST_LOANHIST and sprinkle UVMHIST_LOGs. 2004-11-23 04:51:56 +00:00
yamt aec42f41c5 - prevent wired pages from being loaned, rather than just panicking.
caller should take care of failure by eg. falling back to dumb copy.
  PR/23285.
- add some related assertions.
2004-11-21 06:45:49 +00:00
yamt 05f25dcc2a move buffer queue related stuffs from buf.h to their own header, bufq.h. 2004-10-28 07:07:35 +00:00
yamt 62905a1302 uvm_pageidlezero: grab kernel_lock before uvm.fpageqlock. PR/27259. 2004-10-23 21:29:27 +00:00
yamt 56a653490c expose vm_page_zero_enable as vm.idlezero sysctl.
XXX assuming boolean_t == int.
2004-10-10 09:57:31 +00:00
yamt ffaa06d53c g/c stale declarations of page queues. 2004-10-07 10:56:26 +00:00
enami 682c3c9443 - Don't let pagedaemon sleep while draining buf.
- Estimate amount of memory to free at a time.
Address PR#27057 (and similar hangs I saw several months ago).
2004-10-03 08:47:48 +00:00
enami a55995c148 Count obj pages freed by pagedaemon. 2004-10-03 07:59:02 +00:00
yamt 49fe2034a3 uvm_map_printit:
- print wired_count if available.
- fix a printf format.
2004-09-25 04:19:38 +00:00
yamt 9555030270 make free page queue filo rather than fifo.
data in pages freed more recently are more likely on cpu cache.
2004-09-17 20:46:03 +00:00
yamt 175e99933e uvm_pagefree: when orphaning an A->K loaned page,
- decrement uvmexp.anonpages as it's no longer an anon page.
	- null out anon->u.an_page as the anon no longer own the page.
uvm_anfree: add related assertions.
2004-09-01 11:53:38 +00:00
yamt 23c60dbfe0 uvm_anfree: remove a comment which is no longer true. 2004-09-01 10:09:26 +00:00
thorpej 6c08646cb8 Garbage-collect pagemove(); nothing use it anymore (YAY!!!) 2004-08-28 22:12:40 +00:00
jdolecek 0139d61d6f uvm_grow(): avoid needless arithmetic and make LP64 safe 2004-08-28 12:44:22 +00:00
hannken 8c21bc6224 Add ffs internal snapshots. Written by Marshall Kirk McKusick for FreeBSD.
- Not enabled by default. Needs kernel option FFS_SNAPSHOT.
- Change parameters of ffs_blkfree.
- Let the copy-on-write functions return an error so spec_strategy
    may fail if the copy-on-write fails.
- Change genfs_*lock*() to use vp->v_vnlock instead of &vp->v_lock.
- Add flag B_METAONLY to VOP_BALLOC to return indirect block buffer.
- Add a function ffs_checkfreefile needed for snapshot creation.
- Add special handling of snapshot files:
    Snapshots may not be opened for writing and the attributes are read-only.
    Use the mtime as the time this snapshot was taken.
    Deny mtime updates for snapshot files.
- Add function transferlockers to transfer any waiting processes from
  one lock to another.
- Add vfsop VFS_SNAPSHOT to take a snapshot and make it accessible through
  a vnode.
- Add snapshot support to ls, fsck_ffs and dump.

Welcome to 2.0F.

Approved by: Jason R. Thorpe <thorpej@netbsd.org>
2004-05-25 14:54:55 +00:00
atatat db2f5beb7d Sysctl descriptions under vm subtree 2004-05-25 04:31:17 +00:00
he df7ebfa9c3 Move variable declaration up before the code. Fixes compile error
for vax, and also conforms better to KNF.
2004-05-19 22:02:05 +00:00
darrenr e6416b1b3c rather than just try to get a mapping from a device as only PROT_EXEC, work
down the list of protections until either we run out or we find one that the
device is willing to work with.
2004-05-19 13:20:27 +00:00
christos 6d5a568271 don't accept a negative number of swap devices; it will attempt to malloc
something very large and might crash the kernel; From Evgeny Demidov
2004-05-14 16:56:09 +00:00
yamt 5469c2b7c1 add assertions. 2004-05-12 20:09:50 +00:00
yamt 1b03fa5302 uvm_page_unbusy: add assertions and comments about PG_RELEASED anon pages. 2004-05-05 11:58:27 +00:00
yamt 8368dac6a2 fix a amap_wirerange deadlock problem by re-introducing
PG_RELEASED for anon pages.  PR/23171 from Christian Limpach.
for details, see discussion filed in the PR database.

uvm_anon_release: a new function to free anon-owned PG_RELEASED page.
uvm_anfree: we can't wait for the page here because the caller might hold
	amap lock.  instead, just mark the page as PG_RELEASED.
	who unbusy the page should check the PG_RELEASED.
uvm_aio_aiodone: uvm_anon_release() instead of uvm_page_unbusy()
	if appropriate.
uvmfault_anonget: check PG_RELEASED.
2004-05-05 11:54:32 +00:00
yamt bd712164d0 ubc_release: grab uobj's vmobjlock when calling uvm_page_unbusy(). 2004-05-05 11:35:40 +00:00
pk 2fb3dac280 Since a `vmspace' always includes a `vm_map' we can re-use vm_map's
reference count lock to also protect the vmspace's reference count.
2004-05-04 21:33:40 +00:00
petrov 1ac4411c10 Revert default uvm counters, rename UVMMAP_COUNTERS to UVMMAP_NOCOUNTERS. 2004-05-03 20:10:35 +00:00
pk 9b96c17df2 Make uvm_uarea_free an inline function. 2004-05-02 13:04:57 +00:00
petrov 5f4709f782 Replace uvm counters with evcnt, initialize them through __link_set (from Matt Thomas),
disable counters by default and add configuration option UVMMAP_COUNTERS.
2004-05-01 19:40:39 +00:00
enami 4b8bc2b80f Make strlen calls to be folded to constant at compile time. 2004-04-29 23:13:35 +00:00
junyoung 9262158d3e Fix typo in comments. 2004-04-27 09:50:43 +00:00
junyoung f539f210cc FINDSPACE_FIXED -> UVM_FLAG_FIXED in comment. 2004-04-27 09:45:02 +00:00
simonb b5d0e6bf06 Initialise (most) pools from a link set instead of explicit calls
to pool_init.  Untouched pools are ones that either in arch-specific
code, or aren't initialiased during initial system startup.

 Convert struct session, ucred and lockf to pools.
2004-04-25 16:42:40 +00:00
simonb 04680727b1 s/this this/this/. 2004-04-23 02:48:12 +00:00
christos 6bd1d6d4db Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
2004-04-21 01:05:31 +00:00
simonb 19f85c9cf1 Fix a tyop. 2004-04-05 01:39:07 +00:00
pk daff668b49 Use maxdmap and maxsmap instead of MAXDSIZ and MAXSSIZ. 2004-04-04 18:21:48 +00:00
yamt dabac1bc03 uvm_map_findspace: don't return unaligned address if alignment is specified.
discussed on tech-kern@.
2004-03-30 12:59:09 +00:00
he 8721979173 Conditionalize a few more declarations, as they may be defined as macros:
pmap_collect, pmap_reference, and pmap_remove (observed lossage for vax).
2004-03-27 00:59:55 +00:00
atatat 19af35fd0d Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.
2004-03-24 15:34:46 +00:00
junyoung 325f5482a8 Nuke __P(). 2004-03-24 07:55:01 +00:00
junyoung 1e2b269ded - Nuke __P().
- Drop trailing spaces.
2004-03-24 07:50:48 +00:00
junyoung 7e0c058612 Drop trailing spaces. 2004-03-24 07:47:32 +00:00
junyoung ff32ba0bff pmap_copy() and pmap_update() might be defined as macros in <machine/pmap.h>. 2004-03-23 14:15:59 +00:00
mycroft 2fef5d8dfc Something I posted to tech-kern a long time ago...
Slightly simplify uvm_map_extract() slightly by eliminating "oldstart".
2004-03-17 23:58:12 +00:00
jdolecek 43bafa5c97 fix typo in comment 2004-03-14 16:47:23 +00:00
pooka c5e500a486 Reflect dropping mappings in map_size.
Avoids panic on DIAGNOSTIC kernels.

ok by chs
2004-03-11 15:03:47 +00:00
dbj 5dc123ec73 add debugging assertion ensuring UBC_FAULTBUSY is only used with UBC_WRITE 2004-03-05 20:44:01 +00:00
yamt 9359a18b6a uvm_fault: check loan_count of neighborhood object page properly.
PR/24595 from Stephan Uphoff.
2004-03-02 11:43:44 +00:00
dsl bcaf57b039 Fix prev. so it compiles 2004-02-14 16:40:22 +00:00
jdolecek af46922ada add compat hook in check for zerodev; use this hook to recognize
the old ARM /dev/zero minor mapping #ifdef COMPAT_16
fixes second part of PR kern/23581 by Richard Earnshaw
2004-02-14 12:20:14 +00:00
drochner 41b5db514b make this compile whether DIAGNOSTIC is defined or not 2004-02-13 17:17:04 +00:00
yamt 546aea4d9c when breaking a loan from uobj,
insert the replacement page into the same position
as the original page on the object memq so that
genfs_putpages (and lfs) won't be confused.

noted by Stephan Uphoff (PR/24328)
2004-02-13 13:47:16 +00:00
wiz d20841bb64 Uppercase CPU, plural is CPUs. 2004-02-13 11:36:08 +00:00
yamt babebaa9f9 uvm_loanentry: add a missing uvmfault_unlockall. 2004-02-13 11:15:30 +00:00
matt a78a1b0777 Back out the changes in
http://mail-index.netbsd.org/source-changes/2004/01/29/0027.html
since they don't really fix the problem.

Incorpate one fix:  Mark uvm_map_entry's that were created with
UVM_FLAG_NOMERGE so that they will not be used as future merge
candidates.
2004-02-10 01:30:49 +00:00
dbj c32c758d2d s/fauling/faulting/ 2004-02-10 00:40:06 +00:00
yamt 1e18e59746 - borrow vmspace0 in uvm_proc_exit instead of uvmspace_free.
the latter is not a appropriate place to do so and it broke vfork.
- deactivate pmap before calling cpu_exit() to keep a balance of
  pmap_activate/deactivate.
2004-02-09 13:11:21 +00:00
yamt 8fb96e0be4 introduce a new patchable variable, uvm_debug_check_rbtree,
which is zero by default.
perform rbtree sanity checks only when it isn't zero
because the check is very heavy weight especially when
there're many entries.
2004-02-07 13:22:19 +00:00
yamt a45adbd9c7 don't deactivate pmap in exit1 because we'll touch the pmap later.
instead, borrow vmspace0 immediately before destroying the pmap
in uvmspace_free.
2004-02-07 10:05:52 +00:00
yamt 4124096ea8 uvm_kmapent_alloc:
in the case that there's no cached entries,
if kmem_map is already up, allocate a entry from it
so that we won't try to vm_map_lock recursively.
XXX assuming usage pattern of kmem_map.
2004-02-07 08:02:21 +00:00
he be19fc25f3 Since the playstation2 port still uses a variant of gcc 2.95.2,
change to use a zero-sized array instead of c99 flexible array
member in a struct.

OK'ed by yamt.
2004-02-02 23:13:44 +00:00
yamt 6f979c2127 uvm_loanuobjpages: fix a comment. 2004-01-30 12:01:27 +00:00
yamt c5ffc97d8e remove wrong assertions.
sparc's alloc_cpuinfo_global_va() partially unmaps kva range in kernel_map.

noted by Juergen Hannken-Illjes on current-users@.
2004-01-30 11:56:39 +00:00
tls aeaf748ff2 Buffer cache fixes to avoid thrashing between high and low water marks
and uncontrolled growth.

The key fix is from Dan Carasone, who noticed that buf_canfree() was
counting in _bytes_ but freeing in _buffers_, which caused the instant
drop to lowater observed by some users.

We now control the rate of growth; the probability of getting a new
allocation is inversely proportional to the current size of the
cache.  This idea is from a long-ago conversation with Kirk McKusick
and, if memory serves, was used for the file-system cache in some
other BSD variant at some point in history.

With growth and shrinkage more or less dealt with, we return the
default maximum cache size to 15%.  The default _minimum_ cache size
is raised from 1/16 of the maximum cache size to 1/8, since 1/16 was
chosen when the maximum size was 30% of memory.

Finally, after observing the behaviour of the pagedaemon and the
buffer cache drainer under pathological workloads (e.g. a benchmark
that steps through 75% of available memory backwards) I have moved
the call to buf_drain() to the beginning of the pagedaemon from the
end; if the pagedaemon bogs down, it still won't get run as often
as it should, but at least this way it will see the state of the
free count and free target _before_ the scan step does its thing.
2004-01-30 11:32:16 +00:00
yamt d6e6e2e5c8 some English fixes from Soren Jacobsen. 2004-01-29 12:07:29 +00:00
yamt 20c5bc5099 - split uvm_map() into two functions for the followings.
- for in-kernel maps, disable map entry merging so that
  unmap operations won't block. (workaround for PR/24039)
- for in-kernel maps, allocate kva for vm_map_entry from
  the map itsself and eliminate MAX_KMAPENT and
  uvm_map_entry_kmem_pool.
2004-01-29 12:06:02 +00:00
hannken 3db4e2acd8 Make VOP_STRATEGY(bp) a real VOP as discussed on tech-kern.
VOP_STRATEGY(bp) is replaced by one of two new functions:

- VOP_STRATEGY(vp, bp)  Call the strategy routine of vp for bp.
- DEV_STRATEGY(bp)      Call the d_strategy routine of bp->b_dev for bp.

DEV_STRATEGY(bp) is used only for block-to-block device situations.
2004-01-25 18:06:48 +00:00
dbj 5b4c9f2016 rearrange struct uvm_history to put the struct simplelock at the end.
This avoids problems with the kernel grovelling vmstat -u/-U when
using LOCKDEBUG, which changes the size of struct simplelock.
Replaced the original location of the simplelock with "int unused"
so that binary compatibility will be retained with old vmstat.
2004-01-24 21:29:03 +00:00
yamt b81e2fa5c5 uvm_coredump_walkmap: use UVM_OBJ_IS_DEVICE macro. 2004-01-16 12:43:16 +00:00
yamt 7f20b0c529 bump vnode hold count for page cache as well
to resolve unfairness between page cache and traditional buffer cache.
pointed by enami tsugutomo on current-users@.
2004-01-14 11:28:04 +00:00
yamt 0cad61498f sysctl_vm_updateminmax: fix swapped filemin and execmin.
the problem reported by Vesbula on current-users@.
2004-01-11 18:42:25 +00:00
yamt 7266a95907 store a i/o priority hint in struct buf for buffer queue discipline. 2004-01-10 14:39:50 +00:00
yamt 4b651870d9 #if 0 out unused ubc_flush(). 2004-01-07 12:18:16 +00:00
yamt 59afac32fe - get pages to loan out in uvm_loanuobjpages() rather than
having caller (nfsd, in this case) do so.
- tweak locking so that nfs loaned READ works on layered filesystems.
2004-01-07 12:17:10 +00:00
chs 7662f44874 fix lock initialization in uvm_anon_add(). from PR 23831. 2004-01-06 15:56:49 +00:00
jdolecek 089abdad44 Rearrange process exit path to avoid need to free resources from different
process context ('reaper').

From within the exiting process context:
* deactivate pmap and free vmspace while we can still block
* introduce MD cpu_lwp_free() - this cleans all MD-specific context (such
  as FPU state), and is the last potentially blocking operation;
  all of cpu_wait(), and most of cpu_exit(), is now folded into cpu_lwp_free()
* process is now immediatelly marked as zombie and made available for pickup
  by parent; the remaining last lwp continues the exit as fully detached
* MI (rather than MD) code bumps uvmexp.swtch, cpu_exit() is now same
  for both 'process' and 'lwp' exit

uvm_lwp_exit() is modified to never block; the u-area memory is now
always just linked to the list of available u-areas. Introduce (blocking)
uvm_uarea_drain(), which is called to release the excessive u-area memory;
this is called by parent within wait4(), or by pagedaemon on memory shortage.
uvm_uarea_free() is now private function within uvm_glue.c.

MD process/lwp exit code now always calls lwp_exit2() immediatelly after
switching away from the exiting lwp.

g/c now unneeded routines and variables, including the reaper kernel thread
2004-01-04 11:33:29 +00:00
pk 70f20a1217 Replace the traditional buffer memory management -- based on fixed per buffer
virtual memory reservation and a private pool of memory pages -- by a scheme
based on memory pools.

This allows better utilization of memory because buffers can now be allocated
with a granularity finer than the system's native page size (useful for
filesystems with e.g. 1k or 2k fragment sizes).  It also avoids fragmentation
of virtual to physical memory mappings (due to the former fixed virtual
address reservation) resulting in better utilization of MMU resources on some
platforms.  Finally, the scheme is more flexible by allowing run-time decisions
on the amount of memory to be used for buffers.

On the other hand, the effectiveness of the LRU queue for buffer recycling
may be somewhat reduced compared to the traditional method since, due to the
nature of the pool based memory allocation, the actual least recently used
buffer may release its memory to a pool different from the one needed by a
newly allocated buffer. However, this effect will kick in only if the
system is under memory pressure.
2003-12-30 12:33:13 +00:00
simonb 2b9ac03f55 No need to break a line - the full line is less than 80 chars long. 2003-12-21 11:38:46 +00:00
simonb b9fbceaf46 Unindent a code block that doens't need to be indented. 2003-12-19 06:02:50 +00:00
pk 3c96ae431b * Introduce uvm_km_kmemalloc1() which allows alignment and preferred offset
to be passed to uvm_map().

* Turn all uvm_km_valloc*() macros back into (inlined) functions to retain
  binary compatibility with any 3rd party modules.
2003-12-18 15:02:04 +00:00
pk 60181444ca Condense all existing variants of uvm_km_valloc into a single function:
uvm_km_valloc1(), and use it to express all of
	uvm_km_valloc()
	uvm_km_valloc_wait()
	uvm_km_valloc_prefer()
	uvm_km_valloc_prefer_wait()
	uvm_km_valloc_align()
in terms of it by macro expansion.
2003-12-18 08:15:42 +00:00
tsutsui 082caf94ca Allow sysctl(8) to update vm.{anon,exec,file}{min,max}.
XXX needs sysctl(9) man page to confirm this change..
2003-12-07 00:40:43 +00:00
atatat 13f8d2ce5f Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al.  Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.

Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded.  Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.

All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.

PS - I'm sorry, but there's a distinct lack of documentation at the
moment.  I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 19:38:21 +00:00
yamt f7d48e3571 mincore: don't treat an aobj as a device mapping. 2003-11-29 19:06:48 +00:00
chs e07f0b9362 eliminate uvm_useracc() in favor of checking the return value of
copyin() or copyout().

uvm_useracc() tells us whether the mapping permissions allow access to
the desired part of an address space, and many callers assume that
this is the same as knowing whether an attempt to access that part of
the address space will succeed.  however, access to user space can
fail for reasons other than insufficient permission, most notably that
paging in any non-resident data can fail due to i/o errors.  most of
the callers of uvm_useracc() make the above incorrect assumption.  the
rest are all misguided optimizations, which optimize for the case
where an operation will fail.  we'd rather optimize for operations
succeeding, in which case we should just attempt the access and handle
failures due to insufficient permissions the same way we handle i/o
errors.  since there appear to be no good uses of uvm_useracc(), we'll
just remove it.
2003-11-13 03:09:28 +00:00
chs 709a3b4e52 two changes in improve scalability:
(1) split the single list of pages allocated to a pool into three lists:
     completely full, partially full, and completely empty.
     there is no longer any need to traverse any list looking for a
     certain type of page.

 (2) replace the 8-element hash table for out-of-page page headers
     with a splay tree.

these two changes (together with the recent enhancements to the wait code)
give us linear scaling for a fork+exit microbenchmark.
2003-11-13 02:44:01 +00:00
rearnsha 31a79ddeb0 In vm_phsyseg_find, use u_int for start, len and try when doing a
binary search.  Avoids the need for signed division by 2.  Approved
by thorpej.
2003-11-10 16:13:05 +00:00
yamt 8b91732e18 fix wrong assertions.
they can be false due to alignment requiments (and PMAP_PREFER).
2003-11-06 12:45:26 +00:00
yamt 4a570157d7 add a missing pmap_update(). 2003-11-05 15:45:54 +00:00
yamt b479cef701 don't move hint backward. 2003-11-05 15:34:50 +00:00
yamt 171053e863 - fix a reversed comparison.
- fix "nextgap" case.
- make sure don't get addresses behind hint.
- deal with integer wraparounds better.
- assertions.
2003-11-05 15:09:09 +00:00
yamt 933834a7ae revert rev.1.70 as it was not needed.
uvm_map_lookup_entry() should handle addresses out of the map.
2003-11-03 04:39:11 +00:00
yamt 70538d0c22 add a DEBUG check if freed PG_ZERO pages are really zero-filled. 2003-11-03 03:58:28 +00:00
jdolecek 5e94c73334 kill unneded SYSVSHM includes
use ANSI C function definition for uvm_lwp_exit()
2003-11-02 16:53:43 +00:00
yamt c6d9c8814d fix a wrong assertion. pointed by Christian Limpach. 2003-11-02 07:58:52 +00:00
yamt 142a2d4058 - update uvm_map::size fewer places.
- add related assertions.
2003-11-01 19:56:09 +00:00
yamt c45bf442f2 commit rest of the previous (rbtree).
(i should check .rej files before commit, sorry)
2003-11-01 19:45:13 +00:00
yamt d6dc30aeba in uvm_pagefree and friends, if freed pages have been marked by
PG_ZERO flag, put them to PGFL_ZEROS queue rather than default one
so that we can re-use zero-filled pages efficiently.
2003-11-01 15:18:42 +00:00
yamt 57e554da69 track map entries and free spaces using red-black tree
to improve scalability of operations on the map.

originally done by Niels Provos for OpenBSD.
tweaked for NetBSD by me with some advices from enami tsugutomo.
discussed on tech-kern@ and tech-perform@.
2003-11-01 11:09:02 +00:00
yamt 922ad03e28 don't try to lookup addresses out of the map in uvm_coredump_walkmap(). 2003-11-01 10:43:27 +00:00
yamt 2022580e89 uvm_loanzero:
- after sleeping for memory, re-check if we have a page.
- put the allocated page to pageq to appease UVM_PAGE_TRKOWN.
- dequeue the page when doing ->K loan.
2003-10-27 12:47:33 +00:00
yamt bfda434436 whitespace. 2003-10-26 16:04:00 +00:00
jdolecek 4e7d0870dc update comment - kmem_map is created in kmeminit(), not uvm_km_init() 2003-10-26 08:05:00 +00:00
junyoung b28a286e6a KNF. 2003-10-25 23:05:45 +00:00
cl e30be76fce simplify tests:
The case where l_stat == LSONPROC and l_cpu == curcpu cannot happen
because the pagedaemon is the LWP on curcpu and the pagedaemon is a
kernel thread and the code is only used by the pagedaemon.

See also updated patch in PR kern/23095, which I ment to checkin
originally.
2003-10-24 13:07:33 +00:00
cl ed9c2d7075 don't uvm_swapout LWPs which are LSONPROC on another cpu.
uvm_swapout_threads will swapout LWPs which are running on another CPU:
- uvm_swapout_threads considers LWPs running on another CPU for swapout
  if their l_swtime is high
- uvm_swapout_threads considers LWPs on the runqueue for swapout if their
  l_swtime is high but these LWPs might be running by the time uvm_swapout
  is called

symptoms of failure: panic in setrunqueue

fixes PR kern/23095
2003-10-19 17:45:35 +00:00
scw 4355b16f71 In uvm_lwp_fork(), check if PMAP_UAREA() is defined and if so, invoke it
with the KVA of the newly-wired uarea.

This is useful on some architectures (e.g. xscale) where the uarea mapping
can be tweaked to use the mini-data cache instead of the main cache.
2003-10-13 20:43:03 +00:00
enami 57a6593f52 Fix indent. 2003-10-09 03:12:29 +00:00
atatat d4de28f890 When pulling back an amap to cover the new allocation along with the
previous entry, don't add the size to the extension -- it's already
been added to the end of the previous entry.
2003-10-09 02:44:54 +00:00
thorpej 8655c7d7eb Add a MAP_WIRED flag to mmap(2), which causes the new mapping to be
wired as if by mlock(2).
2003-10-07 00:17:09 +00:00
enami ae9b5cba84 Rewrite uvm_map_findspace() to improve readability and to fix a bug that
it may return space already in use as free space under some condition.
The symptom of the bug is that exec fails if stack is unlimited on
topdown VM kernel.
2003-10-02 00:02:10 +00:00
enami 0ca733e759 Some whitespace fixes. 2003-10-01 23:08:32 +00:00
enami aa87bee0c5 ansi'fy. 2003-10-01 22:50:15 +00:00
chs 066b5091f4 don't dereference a vm_page pointer after we free the page. 2003-09-26 04:03:39 +00:00
drochner da03a1c8cf Fix a reversed logic in swap deallocation which could lead to
uvm_swap_free() being called with a zero slot; this might have been
the reason for crashes with sysvshm and heavy swapping.
(PR kern/22752 by Tom Spindler)
Confirmed by Chuck Silvers.
2003-09-18 13:48:05 +00:00
enami a396bb4713 Swap where the vm map's max and min offset are stored so that they can be
used during map traversal.
2003-09-10 13:38:20 +00:00
pk 1d113dcde7 Can't rely on side-effects in KASSERT expressions which was pointed out to
me by YAMAMOTO Takashi.
2003-09-01 14:20:57 +00:00
yamt 7f7c9a3509 remove an obsolete comment.
(we now have only one inactive list.)
2003-09-01 12:16:17 +00:00
pk 9a4aea0127 When retiring a swap device with marked bad blocks on it we should update
the `# swap page in use' and `# swap page only' counters.  However, at the
time of swap device removal we can no longer figure out how many of the
bad swap pages are actually also `swap only' pages.

So, on swap I/O errors arrange things to not include the bad swap pages in
the `swpgonly' counter as follows: uvm_swap_markbad() decrements `swpgonly'
by the number of bad pages, and the various VM object deallocation routines
do not decrement `swpgonly' for swap slots marked as SWSLOT_BAD.
2003-08-28 13:12:17 +00:00
yamt 91161caf3c use VM_PAGE_TO_PHYS macro instead of using phys_addr directly. 2003-08-26 15:12:18 +00:00
chs 12f04351ad fix some indentation. 2003-08-24 18:12:25 +00:00
chs 939df36e55 add support for non-executable mappings (where the hardware allows this)
and make the stack and heap non-executable by default.  the changes
fall into two basic catagories:

 - pmap and trap-handler changes.  these are all MD:
   = alpha: we already track per-page execute permission with the (software)
	PG_EXEC bit, so just have the trap handler pay attention to it.
   = i386: use a new GDT segment for %cs for processes that have no
	executable mappings above a certain threshold (currently the
	bottom of the stack).  track per-page execute permission with
	the last unused PTE bit.
   = powerpc/ibm4xx: just use the hardware exec bit.
   = powerpc/oea: we already track per-page exec bits, but the hardware only
	implements non-exec mappings at the segment level.  so track the
	number of executable mappings in each segment and turn on the no-exec
	segment bit iff the count is 0.  adjust the trap handler to deal.
   = sparc (sun4m): fix our use of the hardware protection bits.
	fix the trap handler to recognize text faults.
   = sparc64: split the existing unified TSB into data and instruction TSBs,
	and only load TTEs into the appropriate TSB(s) for the permissions.
	fix the trap handler to check for execute permission.
   = not yet implemented: amd64, hppa, sh5

 - changes in all the emulations that put a signal trampoline on the stack.
   instead, we now put the trampoline into a uvm_aobj and map that into
   the process separately.

originally from openbsd, adapted for netbsd by me.
2003-08-24 17:52:28 +00:00
chs 4ffa07757d mprotect()'s "len" is really a size_t, and we can't do any useful
bounds-checking on it.
2003-08-24 16:32:50 +00:00
pk d022b5caad uao_pagein_page() & anon_pagein():
* return failure if the page cannot be retrieved.
	* wakeup any waiters when releasing a page after successful page in.
2003-08-11 16:54:10 +00:00
pk 96f1796f30 Only deactivate pages if their wired count is zero. 2003-08-11 16:48:05 +00:00
pk 3bef941831 Make sure to call uvm_swap_free() and uvm_swap_markbad() with valid (i.e.
positive) slot numbers.
2003-08-11 16:44:35 +00:00
pk 5869d91cb9 Introduce uvm_swapisfull(), which computes the available swap space by
taking into account swap devices that are in the process of being removed.
2003-08-11 16:33:30 +00:00
agc aad01611e7 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22364, verified by myself.
2003-08-07 16:26:28 +00:00
drochner 9c0942bc88 sync comments with reality 2003-08-02 14:12:51 +00:00
mrg 79eaf7449f de-__P()ify. 2003-07-21 00:54:43 +00:00
christos b6dc1230b9 PR/22062: Dheeraj S: Don't compare an integral type with NULL. 2003-07-06 16:19:18 +00:00
fvdl d5aece61d6 Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
2003-06-29 22:28:00 +00:00
thorpej a06b275edc Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget().  Turns out
  that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
  and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
  above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
  just to appease the above.
2003-06-29 18:43:21 +00:00
darrenr 960df3c8d1 Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records.  The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
2003-06-28 14:20:43 +00:00
christos 40e148ef6b PR/21948: Todd Vierling: Implement MAP_TRYFIXED for linux emulation. 2003-06-23 21:32:33 +00:00
wiz efa11218e8 Fix typo in panic message. From miod@openbsd. 2003-06-01 09:26:10 +00:00
simonb 88bd53e829 Consistancy nit- use parentheses around return argument. 2003-05-25 13:00:40 +00:00
thorpej 36da248c07 Back out the following chagne:
http://mail-index.netbsd.org/source-changes/2003/05/08/0068.html

There were some side-effects that I didn't anticipate, and fixing them
is proving to be more difficult than I thought, do just eject for now.
Maybe one day we can look at this again.

Fixes PR kern/21517.
2003-05-10 21:10:23 +00:00
thorpej b77900c3c2 Simplify the way the bounds of the managed kernel virtual address
space is advertised to UVM by making virtual_avail and virtual_end
first-class exported variables by UVM.  Machine-dependent code is
responsible for initializing them before main() is called.  Anything
that steals KVA must adjust these variables accordingly.

This reduces the number of instances of this info from 3 to 1, and
simplifies the pmap(9) interface by removing the pmap_virtual_space()
function call, and removing two arguments from pmap_steal_memory().

This also eliminates some kludges such as having to burn kernel_map
entries on space used by the kernel and stolen KVA.

This also eliminates use of VM_{MIN,MAX}_KERNEL_ADDRESS from MI code,
this giving MD code greater flexibility over the bounds of the managed
kernel virtual address space if a given port's specific platforms can
vary in this regard (this is especially true of the evb* ports).
2003-05-08 18:13:12 +00:00
gmcgarry 9b44363ff5 Don't use overloaded term "comm". From Greg A. Woods in PR#17394. 2003-05-04 01:54:26 +00:00
wiz 6a8058b52a Misc fixes from jmc@openbsd. 2003-05-03 19:01:05 +00:00
yamt 4f0cb3e45a fix ubc pager to take care of loan_count. 2003-05-03 18:05:16 +00:00
yamt 719bd826c5 use uvm_loanbreak in uvm_fault. 2003-05-03 17:57:50 +00:00
yamt dea6f8bc9a - export raw page loan out routine as uvm_loanuobjpages. (for nfsd)
- put code for loan-breaking into a function, uvm_loanbreak.
2003-05-03 17:54:32 +00:00
tls 85c8cfb533 Correct use of MAXBSIZE where MAXPHYS was intended. This is a necessary
first step towards per-device MAXPHYS, and has the beneficial side effect
of allowing clustering to MAXPHYS even on systems that need to run with
a reduced MAXBSIZE to get more metadata buffers.
2003-04-23 00:55:17 +00:00
yamt d99d457173 correct accounting of {exec,file}pages.
they are not updated correctly when breaking loan.
2003-04-22 14:28:15 +00:00
christos 59833f145c PR/2931: Eric Beltensen: Move boolean_t and TRUE/FALSE from uvm_param.h to
types.h
2003-04-19 21:42:46 +00:00
yamt f8b7159909 unbusy a page after put it on the queue.
fix a panic with UVM_PAGE_TRKOWN when doing swapoff.
2003-04-12 14:36:43 +00:00
thorpej 03befad98b In uvm_map_clean(), only call pgo_put if the object has one.
From Quentin Garnier <quatriemek.com!netbsd>.
2003-04-09 21:39:29 +00:00
thorpej 7360657293 Tweak the way the pagesize-related variables are set:
* Remove DEFAULT_PAGE_SIZE.  We don't use PAGE_SIZE the way Mach did.
* In uvm_setpagesize(), if we are called with uvmexp.pagesize == 0,
  then assert that PAGE_SIZE != 0 (i.e. a constant), and set uvmexp.pagesize
  accordingly.
* Provide defaults for MIN_PAGE_SIZE and MAX_PAGE_SIZE if not defined
  by <machine/vmparam.h>.  If PAGE_SIZE is not a constant, MIN_PAGE_SIZE
  and MAX_PAGE_SIZE must be provided.
* If MIN_PAGE_SIZE and MAX_PAGE_SIZE are not equal (i.e. PAGE_SIZE may
  not be a constant in all configurations), then ensure that PAGE_SIZE
  and friends expand to variable references for LKMs.
2003-04-09 16:34:10 +00:00
matt 7876614463 Nuke mem_size global since nothing in the kernel actually refers to it.
(mmm lint).
2003-03-14 08:35:05 +00:00
thorpej 2d5e311009 Make PGALLOC_VERBOSE compile where size_t != int. 2003-03-10 19:52:24 +00:00
thorpej 2a493af5b0 For PMAP_CACHE_VIVT platforms, make UBC_RELEASE_UNMAP evaluate to TRUE,
and add a comment explaining why.

Reviewed by Chuq Silvers.
2003-03-10 15:07:17 +00:00
tsutsui 004ae00514 Use cpu_number() in UVMHIST_LOG() rather than non-public ci_cpuid member
in struct cpu_info.
2003-03-08 15:17:23 +00:00
matt 6074e25e08 Add support for mmap(2) to be able to return memory aligned on a 2^n
boundary.
2003-03-06 00:41:51 +00:00
thorpej 72dd57106c Implement a minimal pager for the uvm_loanzero_object, which simply has
a "put" method which reactivates or dequeues the page.

Need for pager pointed out by enami tsugutomo.
2003-03-05 01:52:41 +00:00
thorpej d3f54e81dd Fix the following pathological scanario:
* User allocates ZFOD region, but does not actually touch the buffer
  to fault in the pages.
* In a loop, user writes this buffer to a network socket, triggering
  sosend_loan().
* uvm_loan() calls uvm_loanzero() once for each page in the loaned
  region (since the pages have not yet faulted in).  This causes a
  page to be allocated and zero'd.  The result is the kernel spends
  a lot of time allocating and zero'ing pages.

This fixes creates a special object which owns a single zero'd page.
This single zero'd page is used to satisfy all loans of non-resident
ZFOD mappings.

Thanks to Allen Briggs for discovering the problem and for providing
an initial patch.
2003-03-04 06:18:54 +00:00
matt 76dd2c90fa In uvm_map_space, if the current entry is above the new space use the
previous entry.  (not if the current entry starts at the end of the new
space; that case doesn't take into account if the new space had a specified
alignment).
2003-03-02 08:57:49 +00:00
matt d6729b1f53 When finding an aligned block, we need to truncate in topdown, not roundup. 2003-03-02 02:55:03 +00:00
thorpej eb14e86676 Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it.  This fixes a few places where either b_dep or b_interlock were
not properly initialized.
2003-02-25 20:35:31 +00:00
simonb a2bdcc915e Cast result of pgo_put() to (void) as is the style with other calls to
pgo_put() in UVM.

Pointed out by Andrew Brown.
2003-02-25 00:22:20 +00:00
pk 2931081a79 Make updating a file's reference and use count MP-safe. 2003-02-23 14:37:32 +00:00
simonb 0b2b1cc0cc Remove assigned-to but not used variable. 2003-02-23 04:53:51 +00:00
matt 23b48be61f fix a tpyo in a comment. 2003-02-21 16:38:44 +00:00
atatat df0a9badc6 Introduce "top down" memory management for mmap()ed allocations. This
means that the dynamic linker gets mapped in at the top of available
user virtual memory (typically just below the stack), shared libraries
get mapped downwards from that point, and calls to mmap() that don't
specify a preferred address will get mapped in below those.

This means that the heap and the mmap()ed allocations will grow
towards each other, allowing one or the other to grow larger than
before.  Previously, the heap was limited to MAXDSIZ by the placement
of the dynamic linker (and the process's rlimits) and the space
available to mmap was hobbled by this reservation.

This is currently only enabled via an *option* for the i386 platform
(though other platforms are expected to follow).  Add "options
USE_TOPDOWN_VM" to your kernel config file, rerun config, and rebuild
your kernel to take advantage of this.

Note that the pmap_prefer() interface has not yet been modified to
play nicely with this, so those platforms require a bit more work
(most notably the sparc) before they can use this new memory
arrangement.

This change also introduces a VM_DEFAULT_ADDRESS() macro that picks
the appropriate default address based on the size of the allocation or
the size of the process's text segment accordingly.  Several drivers
and the SYSV SHM address assignment were changed to use this instead
of each one picking their own "default".
2003-02-20 22:16:05 +00:00
perseant b397c875ae Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon.  To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:

* Create a writer daemon kernel thread whose purpose is to handle page
  writes for the pagedaemon, but which also takes over some of the
  functions of lfs_check().  This thread is started the first time an
  LFS is mounted.

* Add a "flags" parameter to GOP_SIZE.  Current values are
  GOP_SIZE_READ, meaning that the call should return the size of the
  in-core version of the file, and GOP_SIZE_WRITE, meaning that it
  should return the on-disk size.  One of GOP_SIZE_READ or
  GOP_SIZE_WRITE must be specified.

* Instead of using malloc(...M_WAITOK) for everything, reserve enough
  resources to get by and use malloc(...M_NOWAIT), using the reserves if
  necessary.  Use the pool subsystem for structures small enough that
  this is feasible.  This also obsoletes LFS_THROTTLE.

And a few that are not strictly necessary:

* Moves the LFS inode extensions off onto a separately allocated
  structure; getting closer to LFS as an LKM.  "Welcome to 1.6O."

* Unified GOP_ALLOC between FFS and LFS.

* Update LFS copyright headers to correct values.

* Actually cast to unsigned in lfs_shellsort, like the comment says.

* Keep track of which segments were empty before the previous
  checkpoint; any segments that pass two checkpoints both dirty and
  empty can be summarily cleaned.  Do this.  Right now lfs_segclean
  still works, but this should be turned into an effectless
  compatibility syscall.
2003-02-17 23:48:08 +00:00
atatat a57bcda26a Rework the way in which the map is traversed when dumping core. Now
we read-lock the map and call uvm_map_lookup_entry() instead of simply
walking from the header to the next and to the next, etc.

Dumping from sparsely populated amaps could cause faults that would
result in amaps being split, which (in turn) resulted in the core
dumping routines dumping some regions of memory twice.  This makes the
core file too large, the headers not match, gdb not work properly,
and so on.

Addresses PR 19260.
2003-02-14 16:25:12 +00:00
pk ff65229410 Include CPU number in UVM history logs. 2003-02-09 22:33:18 +00:00