public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Josh Stone <jistone@redhat.com>
To: contemplating zombie <contemplatingzombie@gmail.com>
Cc: systemtap@sourceware.org
Subject: Re: Puzzling output of stp script
Date: Sun, 25 Dec 2011 11:07:00 -0000	[thread overview]
Message-ID: <4EF6BAEB.7000006@redhat.com> (raw)
In-Reply-To: <CAO_gTC5M4q3-CS_xuY8C2BQ-4teLUer6DSEZpRdKp8_PJ-ep_w@mail.gmail.com>

On 12/24/2011 10:31 AM, contemplating zombie wrote:
> Hi,
> 
> I am new to systemtap and I was trying out following example script
> given in the documentation:
> 
> probe kernel.function("*@net/socket.c") {
>       printf ("%s -> %s\n", thread_indent(1), probefunc())
> }
> 
> probe kernel.function("*@net/socket.c").return {
>       printf ("%s <- %s\n", thread_indent(-1), probefunc())
> }
> 
> I sshed into a remote machine and executed it. What I see is that the
> stack frames just keep on growing to right and do not return. Won't
> that cause a stack overflow eventually?

The reason is that you are probing more functions on entry than you are
on return.  There's no stack issue; the probes are just imbalanced.

There are two flavors of entry probe: .call and .inline.  If you don't
specify, then you get a union of both.  However, .return probes only
work for the .call flavor, because there is no real return from inlined
functions.

So when you need balanced probes for entering and leaving functions, use
.call and .return.  You could also be clever and represent the .inline
separately with thread_indent(0).

>      0 sshd(804): -> sock_poll
>     11 sshd(804): <- sock_poll
>      0 sshd(804): -> sock_aio_read
>      2 sshd(804):  -> alloc_sock_iocb
>      3 sshd(804):  <- alloc_sock_iocb
>      5 sshd(804):  -> do_sock_read
>      7 sshd(804):   -> __sock_recvmsg
>      9 sshd(804):    -> __sock_recvmsg_nosec
>     15 sshd(804):    <- sock_aio_read

Notice right here, you got a return from sock_aio_read, jumping back
over three other "calls".  I'll bet that do_sock_read, __sock_recvmsg,
and __sock_recvmsg_nosec were all inlined in your kernel.

  parent reply	other threads:[~2011-12-25  5:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAO_gTC6yXVN-6a-aj6YFy4Z_7wGaMRzbHTWWWdQOyWgD=g0rOQ@mail.gmail.com>
2011-12-24 19:14 ` contemplating zombie
2011-12-24 22:56   ` Adrien Kunysz
2011-12-25  5:56     ` contemplating zombie
2011-12-25 11:07   ` Josh Stone [this message]
2011-12-25 20:20     ` Adrien Kunysz
2011-12-25 23:59       ` Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EF6BAEB.7000006@redhat.com \
    --to=jistone@redhat.com \
    --cc=contemplatingzombie@gmail.com \
    --cc=systemtap@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).