public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* probe when thread is queued
@ 2013-02-05 20:33 Mehul Choube
  2013-02-05 21:28 ` David Smith
  0 siblings, 1 reply; 4+ messages in thread
From: Mehul Choube @ 2013-02-05 20:33 UTC (permalink / raw)
  To: systemtap

Hi,

I want to probe when does a thread go into "queued" state (i.e off cpu but not for IO).
But following method gives error:

======= cmd output - start =======

sles11sp1:/stap_scripts # uname -a
Linux sles11sp1 2.6.32.12-0.7-default #1 SMP 2010-05-20 11:14:20 +0200 x86_64 x86_64 x86_64 GNU/Linux

sles11sp1:/stap_scripts # stap -v
A script must be specified.
SystemTap translator/driver (version 1.0/0.137 non-git sources)

sles11sp1:/stap_scripts # stap -e 'probe scheduler.cpu_off { if (task_prev->state == 0) { printf ("pid %d queued\n", task_prev->pid); } }'
parse error: expected ')'
        saw: operator '->' at <input>:1:40
     source: probe scheduler.cpu_off { if (task_prev->state == 0) { printf ("pid %d queued\n", task_prev->pid); } }
                                                    ^
parse error: expected 'probe', 'global', 'function', or '%{'
        saw: operator '}' at <input>:1:102
     source: probe scheduler.cpu_off { if (task_prev->state == 0) { printf ("pid %d queued\n", task_prev->pid); } }
                                                                                                                  ^
2 parse error(s).
Pass 1: parse failed.  Try again with another '--vp 1' option.

sles11sp1:/stap_scripts # stap -e 'probe scheduler.cpu_off { if ($prev->state == 0) { printf ("pid %d queued\n", $prev->pid); } }'
semantic error: not accessible at this address (0xffffffff8139499b): identifier '$prev' at <input>:1:31
        source: probe scheduler.cpu_off { if ($prev->state == 0) { printf ("pid %d queued\n", $prev->pid); } }
                                              ^
Pass 2: analysis failed.  Try again with another '--vp 01' option.

sles11sp1:/stap_scripts # stap -e 'probe scheduler.cpu_off { if (@cast(task_prev, "task_struct", "kernel")->state == 0) { printf ("pid %d queued\n", @cast(task_prev, "task_struct", "kernel")->pid); } }'
semantic error: not accessible at this address (0xffffffff8139499b): identifier '$prev' at /usr/share/systemtap/tapset/scheduler.stp:38:17
        source:     task_prev = $prev
                                ^
Pass 2: analysis failed.  Try again with another '--vp 01' option.

======= cmd output - end =======

Please suggest a way to obtain the info.



Thanks,
Mehul

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: probe when thread is queued
  2013-02-05 20:33 probe when thread is queued Mehul Choube
@ 2013-02-05 21:28 ` David Smith
  2013-02-06  6:31   ` Mehul Choube
  0 siblings, 1 reply; 4+ messages in thread
From: David Smith @ 2013-02-05 21:28 UTC (permalink / raw)
  To: Mehul Choube; +Cc: systemtap

On 02/05/2013 02:33 PM, Mehul Choube wrote:
> stap -e 'probe scheduler.cpu_off { if (task_prev->state == 0) { printf ("pid %d queued\n", task_prev->pid); } }'

The way stap works, the convenience variables have no type information.
Add the type information back with the @cast operator. So, all your
'task_prev' references would look like '@cast(task_prev, "task_struct")'.

Here's the whole thing (somewhat mangled by my mailer):

# stap -v -e 'probe scheduler.cpu_off { if (@cast(task_prev,
"task_struct")->state == 0) { printf ("pid %d queued\n",
@cast(task_prev, "task_struct")->pid); } }'

-- 
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: probe when thread is queued
  2013-02-05 21:28 ` David Smith
@ 2013-02-06  6:31   ` Mehul Choube
  2013-02-06 20:02     ` Josh Stone
  0 siblings, 1 reply; 4+ messages in thread
From: Mehul Choube @ 2013-02-06  6:31 UTC (permalink / raw)
  To: systemtap

It still gives error:

======= cmd out start =======

sles11sp1:/stap_scripts # stap -v -e 'probe scheduler.cpu_off { if (@cast(task_prev, "task_struct")->state == 0) { printf ("pid %d queued\n", @cast(task_prev, "task_struct")->pid); } }'
Pass 1: parsed user script and 59 library script(s) in 100usr/0sys/104real ms.
semantic error: not accessible at this address (0xffffffff8139499b): identifier '$prev' at /usr/share/systemtap/tapset/scheduler.stp:38:17
        source:     task_prev = $prev
                                ^
Pass 2: analyzed script: 1 probe(s), 2 function(s), 0 embed(s), 0 global(s) in 260usr/130sys/401real ms.
Pass 2: analysis failed.  Try again with another '--vp 01' option.

======= cmd out end =======



Thanks,
Mehul

-----Original Message-----
From: David Smith [mailto:dsmith@redhat.com] 
Sent: Wednesday, February 06, 2013 2:58 AM
To: Mehul Choube
Cc: systemtap@sourceware.org
Subject: Re: probe when thread is queued

On 02/05/2013 02:33 PM, Mehul Choube wrote:
> stap -e 'probe scheduler.cpu_off { if (task_prev->state == 0) { printf ("pid %d queued\n", task_prev->pid); } }'

The way stap works, the convenience variables have no type information.
Add the type information back with the @cast operator. So, all your
'task_prev' references would look like '@cast(task_prev, "task_struct")'.

Here's the whole thing (somewhat mangled by my mailer):

# stap -v -e 'probe scheduler.cpu_off { if (@cast(task_prev,
"task_struct")->state == 0) { printf ("pid %d queued\n",
@cast(task_prev, "task_struct")->pid); } }'

-- 
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: probe when thread is queued
  2013-02-06  6:31   ` Mehul Choube
@ 2013-02-06 20:02     ` Josh Stone
  0 siblings, 0 replies; 4+ messages in thread
From: Josh Stone @ 2013-02-06 20:02 UTC (permalink / raw)
  To: Mehul Choube; +Cc: systemtap

On 02/05/2013 10:31 PM, Mehul Choube wrote:
> It still gives error:
> 
> ======= cmd out start =======
> 
> sles11sp1:/stap_scripts # stap -v -e 'probe scheduler.cpu_off { if (@cast(task_prev, "task_struct")->state == 0) { printf ("pid %d queued\n", @cast(task_prev, "task_struct")->pid); } }'
> Pass 1: parsed user script and 59 library script(s) in 100usr/0sys/104real ms.
> semantic error: not accessible at this address (0xffffffff8139499b): identifier '$prev' at /usr/share/systemtap/tapset/scheduler.stp:38:17
>         source:     task_prev = $prev
>                                 ^
> Pass 2: analyzed script: 1 probe(s), 2 function(s), 0 embed(s), 0 global(s) in 260usr/130sys/401real ms.
> Pass 2: analysis failed.  Try again with another '--vp 01' option.
> 
> ======= cmd out end =======

This is probably because the function 'context_switch' is often inlined,
and variable availability often suffers.

Both your kernel and stap versions are pretty old, but still new enough
that I think it should be able to use the tracepoint version of this
probe, which should have better variable access.  Does your kernel have
CONFIG_TRACEPOINTS=y enabled?

Another option is to note that scheduler.cpu_off runs while still in the
context of the departing thread, i.e. $prev == task_current().  So you
could use task_current() for each @cast instead.

We do have a task tapset which encapsulates the same information as
those @casts, so task_state(task_current()) will get you "->state", and
task_tid(task_current()) or even tid() will get you "->pid".  (We use
the userspace view that TID == kernel pid and PID == kernel tgid.)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-02-06 20:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-05 20:33 probe when thread is queued Mehul Choube
2013-02-05 21:28 ` David Smith
2013-02-06  6:31   ` Mehul Choube
2013-02-06 20:02     ` Josh Stone

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).