Add entry about varying the size of the kernel address space.

This commit is contained in:
Dag-Erling Smørgrav 1999-03-20 13:17:41 +00:00
parent 50312aa0ae
commit 546c55a617
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=4551

View file

@ -1,4 +1,4 @@
<!-- $Id: hackers.sgml,v 1.12 1999-02-17 03:08:21 jkoshy Exp $ -->
<!-- $Id: hackers.sgml,v 1.13 1999-03-20 13:17:41 des Exp $ -->
<!-- The FreeBSD Documentation Project -->
<sect>
@ -502,4 +502,80 @@ Cc: current@FreeBSD.ORG
<htmlurl url="http://www.freebsd.org/cgi/man.cgi?ld"
name="ELF linker">.
<sect1>
<heading>Increasing or reducing the kernel address space</heading>
<p>
By default, the kernel address space is 256 MB on FreeBSD 3.x
and 1 GB on FreeBSD 4.x. If you run a network-intensive server
(e.g. a large FTP or HTTP server), you might find that 256 MB is
not enough.
<p>
So how do you increase the address space? There are two aspects
to this. First, you need to tell the kernel to reserve a larger
portion of the address space for itself. Second, since the
kernel is loaded at the top of the address space, you need to
lower the load address so it doesn't bump its head against the
ceiling.
<p>
The first goal is achieved by increasing the value of
<tt/NKPDE/ in <tt>src/sys/i386/include/pmap.h</tt>. Here's what
it looks like for a 1 GB address space:
<verb>
#ifndef NKPDE
#ifdef SMP
#define NKPDE 254 /* addressable number of page tables/pde's */
#else
#define NKPDE 255 /* addressable number of page tables/pde's */
#endif /* SMP */
#endif
</verb>
<p>
To find the correct value of <tt/NKPDE/, divide the desired
address space size (in megabytes) by four, then subtract one for
UP and two for SMP.
<p>
To achieve the second goal, you need to compute the correct load
address: simply subtract the address space size (in bytes) from
0x100100000; the result is 0xc0100000 for a 1 GB address space.
Set <tt/LOAD_ADDRESS/ in <tt>src/sys/i386/conf/Makefile.i386</tt>
to that value; then set the location counter in the beginning of
the section listing to the same value, as follows:
<verb>
OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
OUTPUT_ARCH(i386)
ENTRY(btext)
SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/obj/elf/home/src/tmp/usr/i386-unknown-freebsdelf/lib);
SECTIONS
{
/* Read-only sections, merged into text segment: */
. = 0xc0100000 + SIZEOF_HEADERS;
.interp : { *(.interp) }
</verb>
<p>
Then reconfig and rebuild your kernel. You will probably have
problems with <tt/ps(1)/, <tt/top(1)/ and the like; <tt/make
world/ should take care of it (or a manual rebuild of
<tt/libkvm/, <tt/ps/ and <tt/top/ after copying the patched
<tt/pmap.h/ to <tt>/usr/include/vm/</tt>.
<p>
NOTE: the size of the kernel address space must be a multiple of
four megabytes.
<p>
<em>[<url url="mailto:dg@freebsd.org" name="David Greenman">
adds: <em> I think the kernel address space needs to be a power
of two, but I'm not certain about that. The old(er) boot code
used to monkey with the high order address bits and I think
expected at least 256MB granularity.]</em>
</sect>