Until such time as the swap subsystem can be converted to use The One True

Allocator, prevent panics if (MAXPHYS/PAGE_SIZE) > BLIST_MAX_ALLOC.
From Wolfgang Stukenbrock in PR#41765.
This commit is contained in:
jakllsch 2012-11-27 20:15:55 +00:00
parent baa08254b2
commit 793070a537
1 changed files with 15 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_swap.c,v 1.161 2012/02/05 16:08:28 rmind Exp $ */
/* $NetBSD: uvm_swap.c,v 1.162 2012/11/27 20:15:55 jakllsch Exp $ */
/*
* Copyright (c) 1995, 1996, 1997, 2009 Matthew R. Green
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.161 2012/02/05 16:08:28 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.162 2012/11/27 20:15:55 jakllsch Exp $");
#include "opt_uvmhist.h"
#include "opt_compat_netbsd.h"
@ -1534,6 +1534,19 @@ uvm_swap_alloc(int *nslots /* IN/OUT */, bool lessok)
if (uvmexp.nswapdev < 1)
return 0;
/*
* XXXJAK: BEGIN HACK
*
* blist_alloc() in subr_blist.c will panic if we try to allocate
* too many slots.
*/
if (*nslots > BLIST_MAX_ALLOC) {
if (__predict_false(lessok == false))
return 0;
*nslots = BLIST_MAX_ALLOC;
}
/* XXXJAK: END HACK */
/*
* lock data lock, convert slots into blocks, and enter loop
*/