dslinux/linux-2.6.x/drivers/mmc scsd_c.c scsd_s.S

Malcolm malcolm.parsons at gmail.com
Mon Aug 28 23:05:59 CEST 2006


On 8/28/06, Amadeus <amadeus at iksw-muees.de> wrote:
> On Monday 28 August 2006 14:41, Malcolm wrote:
> > Yes, but we were talking about kernel stacks, not user stacks.
> >
> > AFAIK they are not the same.
>
> I have checked. There is no stack switching on system calls.
> There is an own stack for interrupts, but not for normal kernel code.

When an exception occurs, the CPU switches to Supervisor mode.
In supervisor mode, registers R13(SP) and R14(LR) are banked.
So the stack has already been switched when the assembly code in the
kernel processes a system call.

vector_swi saves these banked registers using
    stmdb   r8, {sp, lr}^           @ Calling sp, lr

So, the kernel isn't using the user stack for the system call.

As system calls can block (not return to the caller immediately), it
is not possible to use the same kernel stack for all processes.

So there must be a kernel stack per process.

LWN agrees with me:

http://lwn.net/Articles/150580/

"Cutting the kernel stack size in half reduces the kernel's
per-process overhead and eliminates a major consumer of multi-page
allocations."

"kernel stack...per-process"

I have not found the code that switches to a different kernel stack,
but I'm sure it's there.
Nor have I found where the kernel stack is allocated.

-- 
Malcolm Parsons



More information about the dslinux-devel mailing list