This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: stack_used() not accurate?
- From: "Mike Snitzer" <snitzer at gmail dot com>
- To: "Frank Ch. Eigler" <fche at redhat dot com>
- Cc: "Wenji Huang" <wenji dot huang at oracle dot com>, systemtap at sourceware dot org
- Date: Thu, 29 May 2008 17:23:13 -0400
- Subject: Re: stack_used() not accurate?
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=pX5pc+R8TndtEJBapX1vVh/OOkyveO3Am4VY+zcfyHA=; b=R4zEB3Vy1xOA+hOAotlQRSPamGaBD4MdcUV13dd6ojuXvHtkOr/gHLgplax4n/qDTBEMCVyxlwKu7c+Zov/qYkL3KRBSLKQlJ9ssoS9mrLVKWHWi88BfaRG1+xYiKj0QUZlcX4Syde29aavyf+E4rX3ipv9K26H/fX3NGkoqS+w=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=orjn9GFoCGcH1/6GWLe2GN7VlESZAMb5QWyMMaX/YCODXHlfSs0E6+W3SJOiwGGhxJZni7qzy2QlNGCvXe/Gi2NyLCXXvssMjfr4H5qXLOoef05IHK2QamMNyP3dLUIUmpXkvMF4VW/1dhUkRD4GYw+ntcMjGiOcqStNMsidXuA=
- References: <170fa0d20805281912r54e0f931h9bdbc9e9c7880b7e@mail.gmail.com> <483E720D.8050808@oracle.com> <y0mprr59nf4.fsf@ton.toronto.redhat.com> <170fa0d20805290843t4c8efa40x86a5705ee97d4d8b@mail.gmail.com> <y0m1w3l9iqh.fsf@ton.toronto.redhat.com>
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