diff options
author | wpaul <wpaul@FreeBSD.org> | 2004-03-22 00:28:38 +0000 |
---|---|---|
committer | wpaul <wpaul@FreeBSD.org> | 2004-03-22 00:28:38 +0000 |
commit | e3bae61eeded23dcd28e10872a88650bb92eca50 (patch) | |
tree | 7e1e4bf4854b697c3f0bc634de79e1b313f13557 /sys | |
parent | f76d5bc2811481474b4366b43803b485a0725ff6 (diff) | |
download | FreeBSD-src-e3bae61eeded23dcd28e10872a88650bb92eca50.zip FreeBSD-src-e3bae61eeded23dcd28e10872a88650bb92eca50.tar.gz |
The kthread_create() API is supposed to allow you to create threads
with more than the normal amount of stack pages, however the stack
pointer always wound up being initialized using KSTACK_PAGES. It
should be using td->td_kstack_pages instead. This means that although
the vm subsystem would give you all the stack pages you asked for,
%esp would always be initialized as if you had just 2 pages, and
the rest would go to waste.
I wanted to use the 'give me more stack pages' feature of kthread_create()
because the Intel 2200BG NDIS driver does an alloca() of about 5000 bytes,
which wrecks the stack with the default 2 page size, and I was baffled
that no matter how much code I shoved into thread contexts with
allegedly larger stacks, the thing would still crash unless I changed
KSTACK_PAGES.
Note: this bug is present in _ALL_ arches at this point. Peter has
promised to merge this fix into all of them.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/i386/i386/vm_machdep.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index 9828918..4c3fa5d 100644 --- a/sys/i386/i386/vm_machdep.c +++ b/sys/i386/i386/vm_machdep.c @@ -172,7 +172,8 @@ cpu_fork(td1, p2, td2, flags) #endif /* Point the pcb to the top of the stack */ - pcb2 = (struct pcb *)(td2->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; + pcb2 = (struct pcb *)(td2->td_kstack + + td2->td_kstack_pages * PAGE_SIZE) - 1; td2->td_pcb = pcb2; /* Copy p1's pcb */ @@ -346,8 +347,8 @@ void cpu_thread_setup(struct thread *td) { - td->td_pcb = - (struct pcb *)(td->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; + td->td_pcb = (struct pcb *)(td->td_kstack + + td->td_kstack_pages * PAGE_SIZE) - 1; td->td_frame = (struct trapframe *)((caddr_t)td->td_pcb - 16) - 1; td->td_pcb->pcb_ext = NULL; } |