Richard> On Wed, 7 May 2003, Roland Dreier wrote: The kernel
Richard> stack, at least for ix86, is only one, set upon startup
Richard> at 8192 bytes above a label called init_task_unit. The
Richard> kernel must have a separate stack and, contrary to what
Richard> I've been reading on this list, it can't have more kernel
Richard> stacks than CPUs and, I don't see a separate stack
Richard> allocated for different CPUs.
Roland> This is total nonsense. Please don't confuse matters by
Roland> spreading misinformation like this. Every task has a
Roland> separate (8K) kernel stack. Look at the implementation of
Roland> do_fork() and in particular alloc_task_struct().
Roland> If there were only one kernel stack, what do you think
Roland> would happen if a process went to sleep in kernel code?
Richard> No, No. That is a process stack. Every process has it's
Richard> own, entirely seperate stack. This stack is used only in
Richard> user mode. The kernel has it's own stack. Every time you
Richard> switch to kernel mode either by calling the kernel or by
Richard> a hardware interrupt, the kernel's stack is used.
Again, this is nonsense and misinformation. Look at do_fork() and
alloc_task_struct(). Do you see how alloc_task_struct() is just
defined to be __get_free_pages(GFP_KERNEL,1) for i386? Do you
understand that that just allocates two pages (8K) of kernel memory?
Do you see that it is never mapped into userspace, and that anyway
a userspace process can use far more than 8K of stack?
That 8K of memory is used for the kernel stack for a particular
process. When a process makes a system call, that specific stack is
used as the kernel stack.
Richard> When a task sleeps, it sleeps in kernel mode. The kernel
Richard> schedules other tasks until the sleeper has been
Richard> satisfied either by time or by event.
Right. Now think about where the kernel stack for the process that is
sleeping in the kernel is kept.
- Roland
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/