Commit Graph

46 Commits

Author SHA1 Message Date
thorpej a180cee23b Pool deals fairly well with physical memory shortage, but it doesn't
deal with shortages of the VM maps where the backing pages are mapped
(usually kmem_map).  Try to deal with this:

* Group all information about the backend allocator for a pool in a
  separate structure.  The pool references this structure, rather than
  the individual fields.
* Change the pool_init() API accordingly, and adjust all callers.
* Link all pools using the same backend allocator on a list.
* The backend allocator is responsible for waiting for physical memory
  to become available, but will still fail if it cannot callocate KVA
  space for the pages.  If this happens, carefully drain all pools using
  the same backend allocator, so that some KVA space can be freed.
* Change pool_reclaim() to indicate if it actually succeeded in freeing
  some pages, and use that information to make draining easier and more
  efficient.
* Get rid of PR_URGENT.  There was only one use of it, and it could be
  dealt with by the caller.

From art@openbsd.org.
2002-03-08 20:48:27 +00:00
bouyer 149c671b66 extent_alloc_subregion1(): when a candidate region doesn't fit after being
rounded up to respect boundary limits, adjust newstart and last before
skiping to the next region. Otherwise we may check the same candidate
region against the start of the next region, no the one immediatly following
the hole, leading to corrupted map.

This fixes the panic seen on sparc64 with scsi drivers, and probably fixes
PR 15489.
2002-02-09 01:00:09 +00:00
lukem adc783d537 add RCSIDs 2001-11-12 15:25:01 +00:00
enami 405f874060 extent_alloc_subregion shouldn't allocate a region pasts the end of subregion. 2001-08-27 13:35:44 +00:00
thorpej 2fbef8e269 Assert that no locks are held if we're called with EX_WAITSPACE.
From Bill Sommerfeld.
2001-06-05 04:39:56 +00:00
thorpej 626cb1c3ce Use pool_init() rather then pool_create(). 2001-05-09 23:38:20 +00:00
marcus 11ac2c3105 STDC cleanup: multi line string literal removed. 2001-04-27 00:06:11 +00:00
thorpej 131ac36401 pool_handle_t -> struct pool * 2000-12-06 18:05:57 +00:00
augustss ce60088d05 Define ltsleep() in the case of _EXTENT_TESTING so regressions testing
works again.
2000-08-12 23:56:50 +00:00
sommerfeld a6cdaddbe6 Use ltsleep(... PNORELOCK ) instead of simple_unlock()/tsleep() 2000-08-12 16:29:36 +00:00
mrg 4384010332 more extent_alloc() fixes:
check that newstart + size - 1 doesn't overflow the end of the extent, rather
than the "dontcross" value, which can easily overflow the end of an extent
when being asked for an object with a large boundary requirement.  this test
is more valid, in any case, and fixes extent_alloc() failure when the start of
the extent is not "aligned".
2000-07-07 14:10:48 +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
pk ac2055bc9a Fix-up (#if 0'd) printf() formats. 2000-06-24 12:46:57 +00:00
mrg 8c758332be in extent_alloc_subregion1(), check for EXTENT_ALIGN() overflow when
doing the boundary-case check.  approved by thorpej.
2000-06-16 16:48:56 +00:00
thorpej 1e0957307e Make this build as a regression test with the latest simple lock
changes.
2000-06-06 17:32:50 +00:00
jhawk a403c3e1c3 Kludge:
Change #define's of the form
	#define panic(a) printf(a)
to
	#define \
	panic(a) printf(a)
to prevent ctags(1) from detecting there is a tag.
Otherwise, the tags file claims panic() is in subr_extent.c
instead of subr_prf.c.
2000-05-24 02:22:36 +00:00
thorpej e3203cc4b6 Detect if kmem is up, and if not, ignore EX_MALLOCOK. 1999-10-11 22:57:17 +00:00
ross d13c150e3b include <string.h> for memset(3) when compiling userland test setup 1999-06-27 06:18:33 +00:00
thorpej 4476366369 Make sure the regression test compiles. 1999-06-07 02:25:05 +00:00
pk 0e286f5c1f Guard our global resource `expool' against all interrupts. 1999-06-06 22:14:53 +00:00
drochner 4a60ccd128 fix 2 problems with subregion allocation:
-a subregion start was ignored if all previous allocations were before
the subregion, reported by Lennart Augustsson in PR kern/7539
-an existing allocation which overlaps the beginning of the subregion
was ignored (ie overlapped) if is is not the last allocation
1999-05-11 11:02:54 +00:00
mycroft bb815bda9e Fix a thinko in the previous.
Also:
* Do the boundary check when creating a new region as well.
* If we crossed the boundary, don't just throw away the region; lop off the
  beginning and see if we still fit.
SB16 is now fully functional on the Alpha.
1999-02-18 18:52:29 +00:00
mycroft ca00239fe9 Speed up the calculation of dontcross; use EXTENT_ALIGN to calculate it
directly rather than using a loop.  Also adjust so that we can allocate at
the end of the integer range.
1999-02-18 18:13:50 +00:00
thorpej 94962b67c7 Fix some printf format problems on Alpha. 1999-02-12 00:46:11 +00:00
chs 3bd133da7d no need to do locking in extext_destroy(). 1999-01-22 07:57:59 +00:00
christos 34c5a58bb4 Make copyrights consistent; fix weird/trailing spaces add missing (c) etc. 1998-09-12 17:20:02 +00:00
pk 3718fc4aa7 Allow the result of an extent allocation to be congruous to an arbitrary
number modulo the given alignment.
To do this the function extent_alloc_subregion() takes an additional `skew'
parameter.  For compatibility's sake, this function has been renamed to
extent_alloc_subregion1().
1998-09-10 20:52:13 +00:00
pk 6f107350c1 Make user-mode testing work again. 1998-09-01 17:59:36 +00:00
pk 5e3bbeb1e1 Fix a case of duplicate allocation in extent_alloc_subregion() triggered
by specifying a start address that happens to be beyond all currently
regions.
1998-09-01 17:57:44 +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
sommerfe 1c2f0a15fd Don't create the extent region pool until one of our callers is of the
opinion that it's safe to call malloc.
1998-07-24 06:40:45 +00:00
pk 4e465abf3f Use a memory pool instead of malloc to allocate region descriptors. 1998-07-23 20:57:17 +00:00
pk 3036bcf8e5 Close a descriptor leak. This proved especially detrimental under heavy
paging.
1998-07-15 12:38:29 +00:00
thorpej 618c279d16 Add fine-grained locking. Still one refinement to make, which will be
done in a separate commit.
1998-06-06 02:25:46 +00:00
thorpej 6428828e64 Const'ify the extent name. 1998-01-21 22:33:49 +00:00
jtc 324ce8d6cb Fix tipo inherited from old version of TNF copyright template. 1997-10-09 07:37:50 +00:00
thorpej fc8c3e00e0 Bring changes from marc-pcmcia branch down to the trunk. 1997-08-29 00:47:18 +00:00
thorpej e98c5a9b1c Fix two boundary/overflow errors in extent_alloc_subregion():
(1): "substart == ex->ex_end" and "subend == ex->ex_start"
     are completely legal parameters for extent_alloc_subregion()
(2): "(subend - substart) + 1" can cause an overflow if the whole
    numeric range is covered by the extent.
Submitted by Matthias Drochner <drochner@zelz26.zel.kfa-juelich.de>
in PR #3119.
1997-05-12 23:36:32 +00:00
cgd e77b6879f7 Feature:
If not compiled with -D_KERNEL, include different includes and
do so macro magic so that this will fit sanely into test harnesses.
When used in user-land, this should be compiled with -D_EXTENT_TESTING.

Bug fixes:
(extent_insert_and_optimize) You can't do things like:
	LIST_REMOVE(elem->...le_next, ...);
	free(elem->...le_next, ...);
They just don't work (and will corrupt your list and/or malloc free list).

(extent_alloc_region_descriptor) Unless you wait, malloc can fail.
Don't accidentally deref a potentially-NULL pointer.
1996-11-21 18:46:34 +00:00
thorpej 52c0d38a1a Several changes:
- Rename EX_NOBLOB to EX_NOCOALESCE; it's much more descriptive of
  what's going on.
- In extent_free_region_descriptor(), if we're a fixed extent,
  freeing a dynamically allocated region descriptor, and someone
  is waiting on the freelist, let the waiter have it, rather than
  free'ing it back to the system.
- Use ALIGN(), rather than our homegrown EXTENT_ALIGN(), when dealing
  with map overhead.  Privatize the EXTENT_ALIGN() macro; there's no need
  to export it.
- Implement EX_BOUNDZERO flag.  This changes the boundary line policy in
  extent_alloc() and extent_alloc_subregion(); boundary lines are
  computed relative to 0, rather then the start of the extent.
- Fix a nasty race between multiple participants doing region and
  descriptor allocation.
- Add a new flag to specify that it's ok to wait for space in the
  extent: EX_WAITSPACE.
- Blow away an unnecessary splhigh()/splx().
- Put a bunch of sanity code inside #ifdef DIAGNOSTIC/#endif.
1996-10-17 08:27:35 +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
thorpej 3946240709 Fix unititialized variable warning. Pointed out by Aaron Brown. 1996-07-25 20:41:48 +00:00
thorpej aba7675464 In extent_alloc_subregion(), don't adjust the initial boundary check
value if we're not concerned with boundary checking.  Avoids a stupid
infinite loop.
1996-07-23 23:09:10 +00:00
thorpej 6041e29f1f My extent map manager. Sort of like resource maps, but more flexible.
Understands allocation aligment and boundary restrictions, "specific region"
allocations, and suballocations.  Capable of statically or dynamically
allocating map overhead.

Many thanks to Matthias Drochner for running the code for me, and sending
me bug fixes, optimizations, and suggestions.  Also, many thanks to
Chris Demetriou for his extremely helpful suggestions.

XXX No manual page yet.  One is forthcoming, as soon as I can scare up
the time to write one.  This has been sitting on my plate for quite a
while, and several projects are waiting for it.  Time to move on.
1996-06-23 00:10:08 +00:00