Subject: Re: Sparseness of kernel structures on i386?
To: None <tls@rek.tjls.com>
From: Frank van der Linden <frank@fwi.uva.nl>
List: port-i386
Date: 12/08/1996 14:43:45
Quoting Thor Lancelot Simon,

> The only question I have left is this:  Why is NKPDE_MAX 32?  I've been told
> on several occasions that you don't want more kernel PDE's than you need, but
> I don't really have a firm grasp of why, except that it diminishes the total
> amount of VA space available to user processes.  Aside from that, why
> shouldn't NKPDE_MAX be, say, 512?

Well, currently the kernel has a max of 124Mb of VA space (just compute
VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS). Since you need one PDE
per 4 Mb (one PDE -> 1024 PTEs -> 1024 * 4096  = 4Mb), you can have 
a maximum of 31 PDEs. On the i386 the kernel lives in the same VA space
as userland, so you do want to restrict the space it takes somehow.

> Theo was kind enough to point out to me that OpenBSD has the following code in
> machdep.c, which would seem easy enough to pick up:

>         /* Restrict to at most 70% filled kvm */
>         if (bufpages * MAXBSIZE * 7 / 10 >
>             (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS))
>                 bufpages = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) /
>                     MAXBSIZE * 7 / 10;

Yeah, I thought about doing this just then, I didn't know OpenBSD already
had that. What is a good value though? 70%? It's guessing. But of course,
the buffer space computation is based on the same sort of percentage
calculation as well, so..

- Frank