Subject: Re: System crash with too much memory
To: None <darcy@NetBSD.org>
From: Greg A. Woods <woods@weird.com>
List: tech-kern
Date: 04/24/2003 13:23:35
[ On Wednesday, April 23, 2003 at 17:14:53 (-0400), D'Arcy J.M. Cain wrote: ]
> Subject: Re: System crash with too much memory
>
> Original nbuf: 50810
> 
> If you multiply that by MAXBSIZE (65536) you get 3329884160 which looks 
> negative as a signed so the test fails.  By clamping to 8000 the result looks 
> positive (524288000) and thus the test succeeds and it is reduced.

Some parts of the kernel need still more cleanup of inappropriate use of
signed integers and more arithmetic overflow checks probably need to be
added too.

> Anyone know why we need the #ifdef VM_MAX_KERNEL_BUF?

You've probably found the place(s) it's defined now, such as in
src/sys/arch/i386/include/vmparam.h.

I think the sparc definition shows the purpose the best:

#define KERNBASE        0xf0000000      /* start of kernel virtual space */
#define KERNEND         0xfe000000      /* end of kernel virtual space */
/* Arbitrarily only use 1/4 of the kernel address space for buffers. */
#define VM_MAX_KERNEL_BUF       ((KERNEND - KERNBASE)/4)


>  Is it safe to test nbuf 
> before going into this block?

"safe"?  Sure why not?

-- 
								Greg A. Woods

+1 416 218-0098;            <g.a.woods@ieee.org>;           <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>