This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: stack_used() not accurate?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]