stack_used() not accurate?
Mike Snitzer
snitzer@gmail.com
Thu May 29 22:09:00 GMT 2008
On Thu, May 29, 2008 at 12:29 PM, Frank Ch. Eigler <fche@redhat.com> wrote:
>
> "Mike Snitzer" <snitzer@gmail.com> writes:
>
>> [...] I'll be exploring other implementations, but any suggestions
>> would be very welcome.
>
> THREAD_SIZE should give a good normal kernel stack size. The
> kprobe-context stack pointer would be better decoded from its pt_regs
> rather than that embedded-c &a hack.
I came up with the following for x86_64:
%( arch == "x86_64" %?
function stack_used_new:long() %{
unsigned long free = THREAD_SIZE;
if (CONTEXT->regs) {
u64 curbase = (u64)task_stack_page(current);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
unsigned long sp = CONTEXT->regs->sp;
#else
unsigned long sp = CONTEXT->regs->rsp;
#endif
free = sp - (curbase + sizeof(struct thread_info));
}
THIS->__retvalue = THREAD_SIZE - free;
%}
%)
I haven't looked at x86 yet.
Mike
More information about the Systemtap
mailing list