public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* stap -x option
@ 2007-07-27 18:23 Sanket Somnath Hase
  2007-07-27 19:14 ` Martin Hunt
  2007-07-28  0:05 ` William Cohen
  0 siblings, 2 replies; 7+ messages in thread
From: Sanket Somnath Hase @ 2007-07-27 18:23 UTC (permalink / raw)
  To: systemtap

Hi folks,

a ) I was curious to know if we can provide more than one target to stap. Say I want to run the same script for more than one processes .

b) Is there any benefit in running single script ( effectively single kernel module ) for all the processes under consideration  against running same script for each process individually ( and effectively  having many kernel modules which look for same set of events but for different targets ).

Looking forward to hear from you ,

Thanks ,
Sanket

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

* Re: stap -x option
  2007-07-27 18:23 stap -x option Sanket Somnath Hase
@ 2007-07-27 19:14 ` Martin Hunt
  2007-07-28 17:47   ` Mike Mason
  2007-07-28  0:05 ` William Cohen
  1 sibling, 1 reply; 7+ messages in thread
From: Martin Hunt @ 2007-07-27 19:14 UTC (permalink / raw)
  To: Sanket Somnath Hase; +Cc: systemtap

On Fri, 2007-07-27 at 13:59 -0400, Sanket Somnath Hase wrote:
> Hi folks,
> 
> a ) I was curious to know if we can provide more than one target to stap. 
> Say I want to run the same script for more than one processes .

-x is probably not needed now that we handle command line args. However
it is a nice complement to -c.

Anyway, what you want is easy to do use command line args. For example,

probe begin {
        printf("tracing pids %d and %d\n", $1, $2)
}

probe syscall.open {
        p = pid()
        if (p == $1 || p == $2)
                printf("%d: open (%s)\n", p, argstr)
}
Save the above as trace.stp and then
> stap trace.stp 123 456

> 
> b) Is there any benefit in running single script ( effectively single kernel module ) 
> for all the processes under consideration  against running same script for each process 
> individually ( and effectively  having many kernel modules which look for same set of 
> events but for different targets ).

Obviously multiple scripts will use more system resources. Other than
that, it is really up to you.  If you are doing the same for all
processes then it makes the most sense to have one script.

Martin


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

* Re: stap -x option
  2007-07-27 18:23 stap -x option Sanket Somnath Hase
  2007-07-27 19:14 ` Martin Hunt
@ 2007-07-28  0:05 ` William Cohen
  2007-07-28  3:50   ` Sanket Somnath Hase
  2007-07-28 21:22   ` Mike Mason
  1 sibling, 2 replies; 7+ messages in thread
From: William Cohen @ 2007-07-28  0:05 UTC (permalink / raw)
  To: Sanket Somnath Hase; +Cc: systemtap

Sanket Somnath Hase wrote:
> Hi folks,
> 
> a ) I was curious to know if we can provide more than one target to stap. Say I want to run the same script for more than one processes .
> 
> b) Is there any benefit in running single script ( effectively single kernel module ) for all the processes under consideration  against running same script for each process individually ( and effectively  having many kernel modules which look for same set of events but for different targets ).
> 
> Looking forward to hear from you ,
> 
> Thanks ,
> Sanket
> 

It seems like one could have a begin probe parse a string argument with the list 
of pid interested in and enter them into a associative array using strtol and 
tokenize functions in a begin probe. Then have the probe check the associative 
array each time it fires. Maybe something like the attached script. This will 
need a newer version of systemtap that include the tokenize() function. The 
comment for syscall.read show how to check the associative array. Running the 
example something like this:

stap pids2watch.stp "124 456"
watching pids:
124
456


There are two issues with multiple probes. One is there will be additional 
overhead if there are more probes to run at a probe point. The other issue is 
that systemtap avoids recompiling the scripts when possible. It checks to see if 
a kernel module has been previously generated for a script, if so it reuses the 
module. If you attempt to use multiple instances of a script, systemtap may 
indicate that it can't load the module. The kernel only allow one instance of a 
module to be loaded into the kernel. You may need to resort to using the "-m" 
option to produce different modules to load.

-Will

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

* Re: stap -x option
  2007-07-28  0:05 ` William Cohen
@ 2007-07-28  3:50   ` Sanket Somnath Hase
  2007-07-28 21:22   ` Mike Mason
  1 sibling, 0 replies; 7+ messages in thread
From: Sanket Somnath Hase @ 2007-07-28  3:50 UTC (permalink / raw)
  To: William Cohen; +Cc: systemtap


Will,
Thanks for the reply. However I have a  one question. 

" It checks to see if a kernel module has been previously
generated for a script, if so it reuses the module. If you attempt to use
multiple instances of a script, systemtap may indicate that it can't load
the module. "

a)
As per your above comments , if systemtap does reuse pre-existing modules for the same script , why should it even try loading module for one more such script ? Is there any threshold on the no of scripts that can reuse the same module ? And having crossed it systemtap tries to load a module ? 


b) I believe that the kernel module that is being loaded is the final outcome that will do the tracing activity. Even if I am running the same script multiple number of times but if I am using a different target , how is this info about different target getting passed , provided systemtap will reuse already loaded module ?  

Thanks ,
Sanket.


> Sanket Somnath Hase wrote:
>> Hi folks,
>> 
>> a ) I was curious to know if we can provide more than one target to
>> stap. Say I want to run the same script for more than one processes .
>> 
>> b) Is there any benefit in running single script ( effectively single
>> kernel module ) for all the processes under consideration  against
>> running same script for each process individually ( and effectively
>> having many kernel modules which look for same set of events but for
>> different targets ).
>> 
>> Looking forward to hear from you ,
>> 
>> Thanks , Sanket
>> 
> 
> It seems like one could have a begin probe parse a string argument with
> the list of pid interested in and enter them into a associative array
> using strtol and tokenize functions in a begin probe. Then have the probe
> check the associative array each time it fires. Maybe something like the
> attached script. This will need a newer version of systemtap that include
> the tokenize() function. The comment for syscall.read show how to check
> the associative array. Running the example something like this:
> 
> stap pids2watch.stp "124 456" watching pids: 124 456
> 
> 
> There are two issues with multiple probes. One is there will be
> additional overhead if there are more probes to run at a probe point. The
> other issue is that systemtap avoids recompiling the scripts when
> possible. It checks to see if a kernel module has been previously
> generated for a script, if so it reuses the module. If you attempt to use
> multiple instances of a script, systemtap may indicate that it can't load
> the module. The kernel only allow one instance of a module to be loaded
> into the kernel. You may need to resort to using the "-m" option to
> produce different modules to load.
> 
> -Will
> 
> 

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

* Re: stap -x option
  2007-07-27 19:14 ` Martin Hunt
@ 2007-07-28 17:47   ` Mike Mason
  0 siblings, 0 replies; 7+ messages in thread
From: Mike Mason @ 2007-07-28 17:47 UTC (permalink / raw)
  To: Martin Hunt; +Cc: Sanket Somnath Hase, systemtap

Martin Hunt wrote:
> On Fri, 2007-07-27 at 13:59 -0400, Sanket Somnath Hase wrote:
>> Hi folks,
>>
>> a ) I was curious to know if we can provide more than one target to stap. 
>> Say I want to run the same script for more than one processes .
> 
> -x is probably not needed now that we handle command line args. However
> it is a nice complement to -c.

Both -x and -c are still needed.  They serve slightly different purposes.

Mike

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

* Re: stap -x option
  2007-07-28  0:05 ` William Cohen
  2007-07-28  3:50   ` Sanket Somnath Hase
@ 2007-07-28 21:22   ` Mike Mason
  2007-07-28 21:46     ` Frank Ch. Eigler
  1 sibling, 1 reply; 7+ messages in thread
From: Mike Mason @ 2007-07-28 21:22 UTC (permalink / raw)
  To: William Cohen; +Cc: Sanket Somnath Hase, systemtap

William Cohen wrote:

[snip]

> 
> There are two issues with multiple probes. One is there will be 
> additional overhead if there are more probes to run at a probe point. 
> The other issue is that systemtap avoids recompiling the scripts when 
> possible. It checks to see if a kernel module has been previously 
> generated for a script, if so it reuses the module. If you attempt to 
> use multiple instances of a script, systemtap may indicate that it can't 
> load the module. The kernel only allow one instance of a module to be 
> loaded into the kernel. You may need to resort to using the "-m" option 
> to produce different modules to load.

While I think it's best to avoid running multiple instances of the same
script, it should still be allowed.  I ran into this yesterday when
I wanted to test the impact of running multiple instances of a script
I wrote.  Using -m to accomplish this is cumbersome.  Could we simply 
add an option that tells stap to ignore the cache?  It's simple, as 
the following diff shows:

Index: main.cxx
===================================================================
RCS file: /cvs/systemtap/src/main.cxx,v
retrieving revision 1.74
diff -r1.74 main.cxx
102a103
>     << "   -d         disable cache support" << endl
278c279
<       int grc = getopt (argc, argv, "hVMvtp:I:e:o:R:r:m:kgPc:x:D:bs:uq");
---
>       int grc = getopt (argc, argv, "hVMvtp:I:e:o:R:r:m:kgPc:x:D:bs:uqd");
311a313,316
>         case 'd':
>           s.use_cache = false;
>           break;
>

Then, if you run into module name conflicts, simply run stap with -d.

Mike

> 
> -Will

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

* Re: stap -x option
  2007-07-28 21:22   ` Mike Mason
@ 2007-07-28 21:46     ` Frank Ch. Eigler
  0 siblings, 0 replies; 7+ messages in thread
From: Frank Ch. Eigler @ 2007-07-28 21:46 UTC (permalink / raw)
  To: Mike Mason; +Cc: Sanket Somnath Hase, systemtap

Mike Mason <mmlnx@us.ibm.com> writes:

> [...]
> While I think it's best to avoid running multiple instances of the same
> script, it should still be allowed.  [...]
> Using -m to accomplish this is cumbersome.  

Please try again with the "-m"-related changes dsmith just checked in.

> Could we simply add an option that tells stap to ignore the cache?

It's not the caching per se that's the problem, but that the default
module name (stap_<getpid>) is reasonably unique but hard to express
with "-m".

Martin pointed out that load-time module renaming is an option too
(see "modprobe -o NAME MODULE").  A good solution could be to do this
automatically at staprun time.


- FChE

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

end of thread, other threads:[~2007-07-28 21:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-27 18:23 stap -x option Sanket Somnath Hase
2007-07-27 19:14 ` Martin Hunt
2007-07-28 17:47   ` Mike Mason
2007-07-28  0:05 ` William Cohen
2007-07-28  3:50   ` Sanket Somnath Hase
2007-07-28 21:22   ` Mike Mason
2007-07-28 21:46     ` Frank Ch. Eigler

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