Skip to contentSkip to conversation

copy_thread preserves kernel stack

DISCUSSION Keith Owens 2 participants 2 messages Jul 3, 2003 – Jul 7, 2003

lore
Share & tools
lore
#0 lore raw

The ia64 version of copy_thread() preserves the parent kernel stack which takes stack space away from the child thread, increasing the risk of stack overflow. The i386 version of copy_thread() creates a pristine stack for the new thread.

ia64 has a comment "Note: if we get called through kernel_thread() then the memory above "(highest addr)" is valid kernel stack memory that needs to be copied as well". i386 kernel threads work fine without the extra stack wastage, so there is no generic reason to save the parent backtrace. Apart from unwind problems, I can see no reason for ia64 to preserve the parent's task in kernel threads. Any objections to me doing a patch that constructs an empty stack for ia64 kernel threads?

#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Keith Owens

Keith> ia64 has a comment "Note: if we get called through Keith> kernel_thread() then the memory above "(highest addr)" is Keith> valid kernel stack memory that needs to be copied as well". Keith> i386 kernel threads work fine without the extra stack Keith> wastage, so there is no generic reason to save the parent Keith> backtrace. Apart from unwind problems, I can see no reason Keith> for ia64 to preserve the parent's task in kernel threads. Keith> Any objections to me doing a patch that constructs an empty Keith> stack for ia64 kernel threads?

If the patch is clean, I wouldn't have a problem with it. (Please make sure that the call-chain of the child thread is properly terminated, so the unwinder knows when to stop.)

(There used to be only few kernel threads, with little risk of kernel
stack overflows, but nowadays (2.5.xx) the situation is quite different, so it probably makes sense to make this change).

	--david