Kernel thread stack usage

Marcel Moolenaar xcllnt at mac.com
Mon Nov 12 11:16:10 PST 2007


On Nov 12, 2007, at 11:06 AM, Alexander Motin wrote:

> For i386 platform we have registers pointing current stack head. To  
> simplify my example I have used address of local variable for that.  
> Probably for ia64 we should just use one more register or algorithm  
> to take into account second stack growing upward.

Remember that taking the address of a local variable automatically
prevents that variable from being register-promoted. As such, it
increases stack pressure :-)

I think GCC has an intrinsic to get the current frame pointer. You
may want to use that instead. Granted, this would not help ia64,
but it's better than taking the address of a local variable. For
ia64 you can do as you suggest and add a second "algorithm". This
means you probably want to make it machine specific in the first
place (i.e. add a MD function that returns an approximation of the
number of bytes of stack space in use).

-- 
Marcel Moolenaar
xcllnt at mac.com




More information about the freebsd-arch mailing list