Troubleshooting for PAE under FreeBSD

Background

In last post, we discussed how to enable PAE functionality on a FreeBSD machine. But some people may also concern the memory usage limitation of single process.

By default, every process can only allocate 512 MB memory for data size, which is defined as MAXDSIZ in kernel configuration file. To break the barrier, simply set a variable in /boot/loader.conf

kern.maxdsiz="2048M"

or adjust the value of MAXDSIZ in kernel configuration file for static setting:

options MAXDSIZ=(2048UL*1024*1024)

But if you set the value too high without further consideration, it might be the beginning of disaster…

Why kernel panic?

Many people have experienced this error message in boot while the MAXDSIZ is equal or lager than 3072M, then reboot.

panic: going nowhere without my init

It’s because the memory space used by kernel is pre-defined as 1 GB, by the option KVA (Kernel Virtual Address space). In PAE enabled system, each process can access total 4 GB memory, including 1GB for kernel and 3GB for data of process. When memory usage of the process exceed the limit, the kernel get panic.

Workaround

More room can be obtained by carefully decrease the memory space of kernel. Simply decrease the value of KVA related option in kernel configuration file:

options KVA_PAGES=260

Due to constraints in loader(8) on i386, it must be a multiple of 4. In general case (non-PAE configuration), 256 = 1 GB of kernel address space [1]. But in PAE mode, the value needs to be double non-PAE. By default, 512 for PAE kernels means (512/2)*4 = 2GB. According to the value, 260, in LINT. Set KVA_PAGES to 512 might be a good idea!!

Besides KVA_PAGES, there are some kernel variables need tuning as well, e.g., kern.maxvnodes, kern.maxfiles, etc, calculated by the amount of physical memory.

Reference

[1] /usr/src/sys/i386/conf/NOTES

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *