[RFC] 16K page size for kernel thread stack (patch)

Stacey Son sson at FreeBSD.org
Tue Feb 18 16:49:06 UTC 2014


Hi all:

For mips64 the current size of 8K is not enough for the kernel thread stack.  For more information, see:

http://www.freebsd.org/cgi/query-pr.cgi?pr=177876

The following patch increases the size of the kernel thread stack to 16K by using a single 16K sized page.  See the patch at:

http://people.freebsd.org/~sson/mips/kstack/kstack_large_page.diff

Here is what it looks like doing a 'show tlb' in the kernel debugger (SMP build):

db> show tlb
Beginning TLB dump for CPU 0...
#0      => c000000010d20000 (pagemask 6000)
 Lo0    12c41f  (0x4b10000)
 Lo1    1       (0)
#1      => c000000000000000 (pagemask 0)
 Lo0    3999f   (0xe66000)
 Lo1    399df   (0xe67000)
^^^ WIRED ENTRIES ^^^
#2      => 16010206e (pagemask 0)
 Lo0    91c9a   (0x2472000)
 Lo1    91c5a   (0x2471000)
[...]

This keeps the wired TLB entries down to one (or two, in the case of SMP) unlike the previous fix that uses a second TLB entry to increase the kstack size.  See:

http://freebsd.1045724.n5.nabble.com/More-trapframe-panics-tp5879903p5880565.html

To use a single 16K page, however, it requires that the physical (4K) pages for the kstacks to be contiguous when they are allocated in vm_thread_new().  To do this vm_page_alloc_contig() is used instead of vm_page_grab().  This adds a bit more mips arch dependent code to sys/vm/vm_glue.c.

Currently, the second half of the kstack tlb entry is not used for anything.  It could be used to increase the kstack to 32K or maybe for the struct pcpu entry (which would reduce the wired TLB entries to just one in the case of SMP).  Using it for the struct pcpu is a bit tricky, however, given that the virtual address space needs to be contiguous.

Best Regards,

-stacey.




More information about the freebsd-mips mailing list