Commit Graph

70 Commits

Author SHA1 Message Date
enami 996ee10484 Introduce new function malloc_roundup(), suggested by Bill Sommerfeld
on tech-kern.
2001-12-05 01:29:04 +00:00
enami 769949847d KNF and other cosmetic changes. 2001-12-04 23:56:36 +00:00
jdolecek c152d680d8 Add M_CANFAIL malloc(9) flag. This flag changes behaviour in M_WAITOK
case when the requested memory size can't ever be granted - instead
of panic, malloc(9) would return failure (NULL).
Note kernel code should do proper bound checking, rather than
depend on M_CANFAIL. This flag is only supposed to be used in very
special cases, where common bound checking is not appropriate.

Discussed on tech-kern@, name ``M_CANFAIL'' suggested by Chuck Cranor.
2001-12-04 20:13:19 +00:00
enami b3d722b5b5 Since we know that `va' is non-NULL here, no need to test if it is NULL. 2001-11-30 01:54:21 +00:00
enami f7fa67fcfc Use round_page() instead of roundup(, PAGE_SIZE).
Suggested by chs@netbsd.org.
2001-11-21 01:30:04 +00:00
lukem 576eed5512 Add new malloc(9) flag M_ZERO - zeros memory before returning.
From Poul-Henning Kamp's equivalent enhancement in FreeBSD.
2001-11-17 03:50:27 +00:00
lukem adc783d537 add RCSIDs 2001-11-12 15:25:01 +00:00
chs 64c6d1d2dc a whole bunch of changes to improve performance and robustness under load:
- remove special treatment of pager_map mappings in pmaps.  this is
   required now, since I've removed the globals that expose the address range.
   pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
   no longer any need to special-case it.
 - eliminate struct uvm_vnode by moving its fields into struct vnode.
 - rewrite the pageout path.  the pager is now responsible for handling the
   high-level requests instead of only getting control after a bunch of work
   has already been done on its behalf.  this will allow us to UBCify LFS,
   which needs tighter control over its pages than other filesystems do.
   writing a page to disk no longer requires making it read-only, which
   allows us to write wired pages without causing all kinds of havoc.
 - use a new PG_PAGEOUT flag to indicate that a page should be freed
   on behalf of the pagedaemon when it's unlocked.  this flag is very similar
   to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
   pageout fails due to eg. an indirect-block buffer being locked.
   this allows us to remove the "version" field from struct vm_page,
   and together with shrinking "loan_count" from 32 bits to 16,
   struct vm_page is now 4 bytes smaller.
 - no longer use PG_RELEASED for swap-backed pages.  if the page is busy
   because it's being paged out, we can't release the swap slot to be
   reallocated until that write is complete, but unlike with vnodes we
   don't keep a count of in-progress writes so there's no good way to
   know when the write is done.  instead, when we need to free a busy
   swap-backed page, just sleep until we can get it busy ourselves.
 - implement a fast-path for extending writes which allows us to avoid
   zeroing new pages.  this substantially reduces cpu usage.
 - encapsulate the data used by the genfs code in a struct genfs_node,
   which must be the first element of the filesystem-specific vnode data
   for filesystems which use genfs_{get,put}pages().
 - eliminate many of the UVM pagerops, since they aren't needed anymore
   now that the pager "put" operation is a higher-level operation.
 - enhance the genfs code to allow NFS to use the genfs_{get,put}pages
   instead of a modified copy.
 - clean up struct vnode by removing all the fields that used to be used by
   the vfs_cluster.c code (which we don't use anymore with UBC).
 - remove kmem_object and mb_object since they were useless.
   instead of allocating pages to these objects, we now just allocate
   pages with no object.  such pages are mapped in the kernel until they
   are freed, so we can use the mapping to find the page to free it.
   this allows us to remove splvm() protection in several places.

The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.
2001-09-15 20:36:31 +00:00
thorpej bbd3d01db5 Artur Grabowski's simple brute-force malloc debugger, which uses
guard pages.  Can only debug one malloc type at a time, and nothing
larger than 1 page.  But can be useful for debugging certain types
of "data modified on freelist" type problems.

Modified from code in OpenBSD.
2001-08-17 00:48:29 +00:00
thorpej a279b0973b Reduce some complexity in the fault path -- Rather than maintaining
an spl-protected "interrupt safe map" list, simply require that callers
of uvm_fault() never call us in interrupt context (MD code must make
the assertion), and check for interrupt-safe maps in uvmfault_lookup()
before we lock the map.
2001-06-26 17:55:14 +00:00
thorpej a160a0b77c Make the kmemstats limits unsigned, and use unsigned arithmetic
to compute them.  Prevents overflows when using a very large number
of kmem pages.

From chopps@netbsd.org.
2001-06-26 16:02:27 +00:00
thorpej 67a875a8c9 Assert that no locks are held if we're called with M_WAITOK. 2001-06-05 04:39:02 +00:00
chs 821ec03ed9 replace vm_map{,_entry}_t with struct vm_map{,_entry} *. 2001-06-02 18:09:08 +00:00
jdolecek 34c8ae80da constify 2001-01-18 20:28:15 +00:00
thorpej a624c70966 Use splvm(), not the home-grown splmem(). 2001-01-14 02:08:35 +00:00
chs 22d140fd0b ifdef DEBUG, increase the max size we'll overwrite in freed memory blocks
to detect modifications after frees from 32 bytes to 1 page.
2000-11-24 00:34:32 +00:00
mrg 32aa199ccf remove include of <vm/vm.h> 2000-06-27 17:41:07 +00:00
mrg 2f159a1bac remove/move more mach vm header files:
<vm/pglist.h> -> <uvm/uvm_pglist.h>
	<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
	<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
	<vm/vm_object.h> -> nothing
	<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
2000-06-26 14:20:25 +00:00
sommerfeld 137a54db78 Improve #error message slightly. 2000-05-26 23:18:26 +00:00
thorpej e633df2afa __predict_false() the check for bogus malloc type, running out of space
in kmem_map, and the DIAGNOSTIC error checks.
2000-05-08 20:02:21 +00:00
augustss 264f1d27c6 Get rid of register declarations. 2000-03-30 09:27:11 +00:00
thorpej eb9cbbe294 Add some very simple code to auto-size the kmem_map. We take the
amount of physical memory, divide it by 4, and then allow machine
dependent code to place upper and lower bounds on the size.  Export
the computed value to userspace via the new "vm.nkmempages" sysctl.

NKMEMCLUSTERS is now deprecated and will generate an error if you
attempt to use it.  The new option, should you choose to use it,
is called NKMEMPAGES, and two new options NKMEMPAGES_MIN and
NKMEMPAGES_MAX allow the user to configure the bounds in the kernel
config file.
2000-02-11 19:22:52 +00:00
thorpej 9069b40366 Add a sanity check to ensure that a region being free()'d is actually
within the KVA range malloc() would return.
2000-02-01 19:37:58 +00:00
ragge 184f8b2c39 First round of discarding the CL* macros. 1999-12-03 21:43:19 +00:00
fvdl 0b1963121a Add Kirk McKusick's soft updates code to the trunk. Not enabled by
default, as the copyright on the main file (ffs_softdep.c) is such
that is has been put into gnusrc. options SOFTDEP will pull this
in. This code also contains the trickle syncer.

Bump version number to 1.4O
1999-11-15 18:49:07 +00:00
chs 327e64d87b remove simplelockrecurse, it's no longer needed. 1999-07-19 03:17:42 +00:00
thorpej 2c3dc83a64 Keep interrupt-safe maps on an additional queue. In uvm_fault(), if we're
looking up a kernel address, check to see if the address is on this
"interrupt-safe" list.  If so, return failure immediately.  This prevents
a locking screw if a page fault is taken on an interrupt-safe map in or
out of interrupt context.
1999-06-04 23:38:41 +00:00
thorpej e50ef977d1 Don't use a read lock on an intrsafe map; these maps can only use exclusive,
non-sleeping locks.
1999-05-28 19:40:09 +00:00
thorpej 2580d306ab Change the vm_map's "entries_pageable" member to a r/o flags member, which
has PAGEABLE and INTRSAFE flags.  PAGEABLE now really means "pageable",
not "allocate vm_map_entry's from non-static pool", so update all map
creations to reflect that.  INTRSAFE maps are maps that are used in
interrupt context (e.g. kmem_map, mb_map), and thus use the static
map entry pool (XXX as does kernel_map, for now).  This will eventually
change now these maps are locked, as well.
1999-05-26 19:16:28 +00:00
mrg d2397ac5f7 completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
1999-03-24 05:50:49 +00:00
chs 254ae63e2c avoid math on void *. 1999-01-22 07:55:49 +00:00
thorpej d90b3d3438 Add dump_kmemstats(), callable from DDB to show kmem statistics. From
Chuck Silvers via Chuck Cranor.
1998-12-02 20:35:28 +00:00
chs 61458d7dfa LOCKDEBUG enhancements for non-MP:
keep a list of locked locks.
use this to print where the lock was locked
when we either go to sleep with a lock held
or try to free a locked lock.
1998-11-04 06:19:55 +00:00
christos 34c5a58bb4 Make copyrights consistent; fix weird/trailing spaces add missing (c) etc. 1998-09-12 17:20:02 +00:00
thorpej f3d7e7e21c Add some braces to make egcs happy (ambiguous else warning). 1998-08-18 06:11:35 +00:00
eeh a2dd74ed79 Merge paddr_t changes into the main branch. 1998-08-13 02:10:37 +00:00
perry 275d1554aa Abolition of bcopy, ovbcopy, bcmp, and bzero, phase one.
bcopy(x, y, z) ->  memcpy(y, x, z)
ovbcopy(x, y, z) -> memmove(y, x, z)
   bcmp(x, y, z) ->  memcmp(x, y, z)
  bzero(x, y)    ->  memset(x, 0, y)
1998-08-04 04:03:10 +00:00
thorpej ad7a87400a defopt LOCKDEBUG 1998-05-20 01:32:29 +00:00
fvdl e5bc90f40c Merge with Lite2 + local changes 1998-03-01 02:20:01 +00:00
mrg d90485202c - add defopt's for UVM, UVMHIST and PMAP_NEW.
- remove unnecessary UVMHIST_DECL's.
1998-02-10 14:08:44 +00:00
thorpej 1305ecbe62 Allow callers of uvm_km_suballoc() to specify where the base of the
submap _must_ begin, by adding a "fixed" boolean argument.
1998-02-08 06:15:53 +00:00
chs 0711fdaf0b fix a locking problem by replacing the call to uvm_kernacc()
with an inlined version that uses kmem_map instead of kernel_map.
1998-02-07 02:40:36 +00:00
mrg 1a8c7604f4 initial import of the new virtual memory system, UVM, into -current.
UVM was written by chuck cranor <chuck@maria.wustl.edu>, with some
minor portions derived from the old Mach code.  i provided some help
getting swap and paging working, and other bug fixes/ideas.  chuck
silvers <chuq@chuq.com> also provided some other fixes.

this is the rest of the MI portion changes.

this will be KNF'd shortly.  :-)
1998-02-05 07:59:28 +00:00
thorpej 66abe4217c Implement an activity log for malloc() and free(), useful for tracking
down "Data modified on freelist" and "muliple free" problems.

The log is activated by the MALLOCLOG option, and the size of the
event ring buffer is controlable via the MALLOGLOGSIZE option (default
is 100000 entries).

From Chris Demetriou, cleaned up a little by me per suggestions in the
e-mail from Chris that contained the code.
1998-01-21 22:24:32 +00:00
mycroft 57f5a4a68d Add another bit of const poisoning. 1997-10-09 13:05:59 +00:00
mycroft 8579e3480d Make memname[] const (but only shallow, since the array may be modified). 1997-10-09 13:02:18 +00:00
thorpej 7b30910b48 KMEMSTATS is a header option; pull in "opt_kmemstats.h". 1997-02-02 21:22:16 +00:00
tls e9a5b29d40 add #ifdef KMEMSTATS around variable otherwise unused; now compiles with KMEMSTATS turned off. 1997-01-30 06:50:46 +00:00
christos f443b89c92 backout previous kprintf change 1996-10-13 02:32:29 +00:00
christos 60d201973e printf -> kprintf, sprintf -> ksprintf 1996-10-10 22:46:11 +00:00