diff options
author | tanimura <tanimura@FreeBSD.org> | 2000-12-13 10:01:00 +0000 |
---|---|---|
committer | tanimura <tanimura@FreeBSD.org> | 2000-12-13 10:01:00 +0000 |
commit | a8dbeb3f7b850f093f2892563882b3afcecd5e8e (patch) | |
tree | 5cfdc93fb25655fb4c56646dcc64ce1e405c28e8 /sys/vm/vm_zone.c | |
parent | 90d90d0c248fbcde27a7d443098c2bf514aaa199 (diff) | |
download | FreeBSD-src-a8dbeb3f7b850f093f2892563882b3afcecd5e8e.zip FreeBSD-src-a8dbeb3f7b850f093f2892563882b3afcecd5e8e.tar.gz |
- If swap metadata does not fit into the KVM, reduce the number of
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
Diffstat (limited to 'sys/vm/vm_zone.c')
-rw-r--r-- | sys/vm/vm_zone.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sys/vm/vm_zone.c b/sys/vm/vm_zone.c index c592c91..b5ade30 100644 --- a/sys/vm/vm_zone.c +++ b/sys/vm/vm_zone.c @@ -80,8 +80,11 @@ int zinitna(vm_zone_t z, vm_object_t obj, char *name, int size, int nentries, int flags, int zalloc) { - int totsize; + int totsize, oldzflags; + vm_zone_t oldzlist; + oldzflags = z->zflags; + oldzlist = zlist; if ((z->zflags & ZONE_BOOT) == 0) { z->zsize = (size + ZONE_ROUNDING - 1) & ~(ZONE_ROUNDING - 1); simple_lock_init(&z->zlock); @@ -112,8 +115,12 @@ zinitna(vm_zone_t z, vm_object_t obj, char *name, int size, zone_kmem_kvaspace += totsize; z->zkva = kmem_alloc_pageable(kernel_map, totsize); - if (z->zkva == 0) + if (z->zkva == 0) { + /* Clean up the zlist in case we messed it. */ + if ((oldzflags & ZONE_BOOT) == 0) + zlist = oldzlist; return 0; + } z->zpagemax = totsize / PAGE_SIZE; if (obj == NULL) { @@ -156,11 +163,10 @@ zinit(char *name, int size, int nentries, int flags, int zalloc) { vm_zone_t z; - z = (vm_zone_t) malloc(sizeof (struct vm_zone), M_ZONE, M_NOWAIT); + z = (vm_zone_t) malloc(sizeof (struct vm_zone), M_ZONE, M_NOWAIT | M_ZERO); if (z == NULL) return NULL; - z->zflags = 0; if (zinitna(z, NULL, name, size, nentries, flags, zalloc) == 0) { free(z, M_ZONE); return NULL; |