diff options
author | alfred <alfred@FreeBSD.org> | 2001-08-02 07:54:58 +0000 |
---|---|---|
committer | alfred <alfred@FreeBSD.org> | 2001-08-02 07:54:58 +0000 |
commit | 1d105403d04e4606c3ab825795b3eb9c0a32dee4 (patch) | |
tree | 4c75eb100528b58c774d303dd993b51ed2659efe /sys/vm | |
parent | 09aa99ee9b983560f256b152c7ceac0ddda97b9b (diff) | |
download | FreeBSD-src-1d105403d04e4606c3ab825795b3eb9c0a32dee4.zip FreeBSD-src-1d105403d04e4606c3ab825795b3eb9c0a32dee4.tar.gz |
Fixups for the initial allocation by dillon:
1) allocate fewer buckets
2) when failing to allocate swap zone, keep reducing the zone by
a third rather than a half in order to reduce the chance of
allocating way too little.
I also moved around some code for readability.
Suggested by: dillon
Reviewed by: dillon
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/swap_pager.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 6df4113..f2d6061 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -329,19 +329,27 @@ swap_pager_swap_init() n = min(cnt.v_page_count, (kernel_map->max_offset - kernel_map->min_offset) / PAGE_SIZE) * 2; n2 = n; - while (n > 0 - && (swap_zone = zinit( + do { + swap_zone = zinit( "SWAPMETA", sizeof(struct swblock), n, ZONE_INTERRUPT, 1 - )) == NULL) - n >>= 1; + ); + if (swap_zone != NULL) + break; + /* + * if the allocation failed, try a zone two thirds the + * size of the previous attempt. + */ + n -= ((n + 2) / 3); + } while (n > 0); + if (swap_zone == NULL) - printf("WARNING: failed to init swap_zone!\n"); + panic("failed to zinit swap_zone."); if (n2 != n) - printf("Swap zone entries reduced to %d.\n", n); + printf("Swap zone entries reduced from %d to %d.\n", n2, n); n2 = n; /* @@ -353,7 +361,7 @@ swap_pager_swap_init() * swhash_mask: hash table index mask */ - for (n = 1; n < n2 ; n <<= 1) + for (n = 1; n < n2 / 8; n *= 2) ; swhash = malloc(sizeof(struct swblock *) * n, M_VMPGDATA, M_WAITOK | M_ZERO); |