RE: prompt script exiting

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

RE: prompt script exiting

bibo,mao-2
Hi Cohen,

Currently in the script when exit() is called, the global variant flag _stp_exit_flag will be set as 1. I do know whether judge the value of _stp_exit_flag just before kprobe/kretprobe handler running. And then when it is set as 1, kprobe/kretprobe handler return immediately, and then collect data will be more accurate when it is used for measurement.

Regards
Bibo,mao

>-----Original Message-----
>From: [hidden email] [mailto:[hidden email]]
>On Behalf Of William Cohen
>Sent: 2005年12月3日 4:08
>To: SystemTAP
>Subject: prompt script exiting
>
>When running the testsuite with the recent version of systemtap
>(snapshot from this morning, 2005-12-02) I found that syscalls2.exp
>would consistently fail. The the tests uses an exit() in the script when
>a probe fires 100 times. The syscalls2.exp allows a little slop and the
>probe to fire after the exit but before being removed. However, the
>changes in how exit operates makes create a longer wait before scripts
>actually exits. On the test runs I saw the probe fire 232, 200, 267, and
>420 times on various machines, much more than the 150 times allowed in
>the test.
>
>Do we expect the script to exit promptly when the exit() is encountered
>in the script? People taking measurements will want to know about this
>because it could significantly affect the data their scripts collect.
>For the time being we can just document this as how it behaves. It
>should be fairly easy for users to have a predicate in their
>instrumentation, so it is a pretty minor issue.
>
>-Will

Reply | Threaded
Open this post in threaded view
|

Re: prompt script exiting

Frank Ch. Eigler

"Mao, Bibo" <[hidden email]> writes:

> [...]  I do know whether judge the value of _stp_exit flag just
> before kprobe/kretprobe handler running. And then when it is set as
> 1, kprobe/kretprobe handler return immediately [...]

The _stp_exit flag could be associated with the translator's overall
session_state flag, which has an STAP_SESSION_STOPPING value.  This is
used during that phase when the "end" probes are run, and causes other
probes to return early.  The tapset exit() function could set that in
addition to calling the runtime function.

- FChE
Reply | Threaded
Open this post in threaded view
|

Re: prompt script exiting

William Cohen
Frank Ch. Eigler wrote:

> "Mao, Bibo" <[hidden email]> writes:
>
>
>>[...]  I do know whether judge the value of _stp_exit flag just
>>before kprobe/kretprobe handler running. And then when it is set as
>>1, kprobe/kretprobe handler return immediately [...]
>
>
> The _stp_exit flag could be associated with the translator's overall
> session_state flag, which has an STAP_SESSION_STOPPING value.  This is
> used during that phase when the "end" probes are run, and causes other
> probes to return early.  The tapset exit() function could set that in
> addition to calling the runtime function.
>
> - FChE

That sounds like it would operate in the manner that people would
expect. Right now there can be a fairly delay between the exit()
occuring in the script and the data collection begin shutdown.

What happens if there are two scripts running? Is this flag local to the
script or a global? If it is global and there are two systemtap
scription running with one of them is exiting, the other script script
would also be affected and not collect data.

-Will
Reply | Threaded
Open this post in threaded view
|

Re: prompt script exiting

Frank Ch. Eigler
Hi -

wcohen wrote:

> That [systemtap_session change] sounds like it would operate in the
> manner that people would expect. [...]

Yeah.  Would you mind testing it and committing it if it works?

> What happens if there are two scripts running? Is this flag local to
> the script or a global? [...]

"global" in the systemtap sense means shared amongst probe handlers of
the same systemtap session.  There is no "global" data in the sense of
kernel-wide at all, except perhaps in kprobes internals.

- FChE
Reply | Threaded
Open this post in threaded view
|

Re: prompt script exiting

William Cohen
Frank Ch. Eigler wrote:

> Hi -
>
> wcohen wrote:
>
>
>>That [systemtap_session change] sounds like it would operate in the
>>manner that people would expect. [...]
>
>
> Yeah.  Would you mind testing it and committing it if it works?
>
>
>>What happens if there are two scripts running? Is this flag local to
>>the script or a global? [...]
>
>
> "global" in the systemtap sense means shared amongst probe handlers of
> the same systemtap session.  There is no "global" data in the sense of
> kernel-wide at all, except perhaps in kprobes internals.
>
> - FChE
Here is a one-liner that appears to fix the problem.
systemtap.samples/syscalls2.exp works when it is installed.

2005-12-12  Will Cohen  <[hidden email]>

        * tapset/logging.stp (function_exit): Make sure systemtap
        probes stop collection additional data.



-Will

Index: logging.stp
===================================================================
RCS file: /cvs/systemtap/src/tapset/logging.stp,v
retrieving revision 1.6
diff -u -r1.6 logging.stp
--- logging.stp 18 Nov 2005 21:57:30 -0000 1.6
+++ logging.stp 12 Dec 2005 20:16:34 -0000
@@ -21,6 +21,7 @@
 
 // NB: exit() does *not* cause immediate return from current function/probe
 function exit () %{
+    atomic_set (&session_state, STAP_SESSION_STOPPING);
     _stp_exit ();
 %}