All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: How to check is tracepoint is currently enabled (UST)
       [not found] <48CF5AC71E61DB46B70D0F388054EFFD359C62DE@VAL-E-02.valcartier.drdc-rddc.gc.ca>
@ 2014-06-25 14:49 ` Jonathan Rajotte-Julien
       [not found] ` <53AAE15C.3040100@ericsson.com>
  1 sibling, 0 replies; 6+ messages in thread
From: Jonathan Rajotte-Julien @ 2014-06-25 14:49 UTC (permalink / raw)
  To: lttng-dev

You can also list all ust events available for tracing via the command "lttng list -u". 

Make sure that the application you want to trace is running. 

On 06/25/2014 10:40 AM, Thibault, Daniel wrote:
> ----------------------------------------------------------------------
> Date: Sun, 22 Jun 2014 19:27:31 +0400
> From: Dmitri Shubin <sbn@tbricks.com>
> 
>> In dtrace it's possible to check if some probe is currently enabled or not (to avoid argument preparation for disabled probes).
>> But I'm unable to find similar feature in lttng-ust (at least it's not mentioned in lttng-ust man page).
>>
>> Am I missed it or it's not implemented on purpose?
> 
>    Use the list command.  A command such as 'lttng list <session_name>' will list the known events and their enabled/disabled status.  You can filter the command's output by specifying a domain (--userspace) and/or a channel (--channel <channel_name>).  For example:
> 
> (begin example)
> $ lttng create some_session
> Session some_session created.
> Traces will be written in /home/username/lttng-traces/ some_session-20140625-102709
> $ lttng enable-event -u some_event
> UST event some_event created in channel channel0
> $ lttng list some_session -u --channel channel0
> Tracing session some_session: [inactive]
>     Trace path: /home/username/lttng-traces/ some_session-20140625-102709
> 
> === Domain: UST global ===
> 
> Buffer type: per UID
> 
> - channel0: [enabled]
> 
>     Attributes:
>       overwrite mode: 0
>       subbuffers size: 131072
>       number of subbufers: 4
>       switch time interval: 0
>       read time interval: 0
>       output: mmap()
> 
>     Events:
>       some_event (type: tracepoint) [enabled]
> (end example)
> 
>    You can take a look at /usr/src/lttng-tools/src/bin/lttng/commands/list.c to see how the information is obtained.
> 
> Daniel U. Thibault
> Protection des systèmes et contremesures (PSC) | Systems Protection & Countermeasures (SPC)
> Cyber sécurité pour les missions essentielles (CME) | Mission Critical Cyber Security (MCCS)
> RDDC - Centre de recherches de Valcartier | DRDC - Valcartier Research Centre
> 2459 route de la Bravoure
> Québec QC  G3J 1X5
> CANADA
> Vox : (418) 844-4000 x4245
> Fax : (418) 844-4538
> NAC : 918V QSDJ <http://www.travelgis.com/map.asp?addr=918V%20QSDJ>
> Gouvernement du Canada | Government of Canada
> <http://www.valcartier.drdc-rddc.gc.ca/>
> 
> _______________________________________________
> lttng-dev mailing list
> lttng-dev@lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
> 

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

* Re: How to check is tracepoint is currently enabled (UST)
       [not found] ` <53AAE15C.3040100@ericsson.com>
@ 2014-06-25 15:36   ` Simon Marchi
  2014-06-27 10:32   ` Dmitri Shubin
       [not found]   ` <CAFXXi0=XEwjPfLwxsGim6_FwRqGD-YM9o1zTVFRWbmyigGDPcw@mail.gmail.com>
  2 siblings, 0 replies; 6+ messages in thread
From: Simon Marchi @ 2014-06-25 15:36 UTC (permalink / raw)
  To: Jonathan Rajotte-Julien; +Cc: lttng-dev

I am pretty sure that Dmitri is talking about a check that you can use
in your application, to see if a specific tracepoint is enabled. If
some data that you pass to the tracepoint is expensive to compute, yo
might want to avoid computing it when tracing is disabled.

> #define tracepoint_enabled(provider, name) caa_unlikely(__tracepoint_##provider##___##name.state)

Dmitri, that macro that you posted, does it work for you?

Otherwise, you can simply embed the code in the call to tracepoint:

    tracepoint(hello, world, expensive_work(data));

In the expansion of the "tracepoint" macro [1], expensive_work is only
called if the tracepoint is enabled, so you don't pay the cost if the
tracepoint is disabled.

If the code that you need to run to compute your data is not a single
function call, you can: (a) make it a function or (b) use gcc's
statement expressions [2]. For example, instead of:

    /* Here we call get_data and compute_median even if tracing is disabled. */
    struct data* data = get_data();
    int median = compute_median(data);
    free(data);
    tracepoint(hello, world, median);

you could do:
    /* Here we _don't_ call get_data and compute_median when tracing
is disabled. */
    tracepoint(hello, world, ({
        struct data* data = get_data();
        int median = compute_median(data);
        free(data);
        median;
    }));

The statement expression will only be executed if the tracepoint is
enabled (you can verify that by adding a printf in there).

Does it answer you question?

Simon

[1] http://git.lttng.org/?p=lttng-ust.git;a=blob;f=include/lttng/tracepoint.h;h=c5a09d815db1383e539c8c455e8477dda29a579a;hb=HEAD#l47
[2] https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html

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

* Re: How to check is tracepoint is currently enabled (UST)
       [not found] ` <53AAE15C.3040100@ericsson.com>
  2014-06-25 15:36   ` Simon Marchi
@ 2014-06-27 10:32   ` Dmitri Shubin
       [not found]   ` <CAFXXi0=XEwjPfLwxsGim6_FwRqGD-YM9o1zTVFRWbmyigGDPcw@mail.gmail.com>
  2 siblings, 0 replies; 6+ messages in thread
From: Dmitri Shubin @ 2014-06-27 10:32 UTC (permalink / raw)
  To: Jonathan Rajotte-Julien; +Cc: lttng-dev


[-- Attachment #1.1: Type: text/plain, Size: 3438 bytes --]

Daniel and Jonathan,

Thanks for your replies!

Sorry I wasn't clear enough -- I want to check it in my application to
avoid 'heavy' calculation of probe arguments when the probe is actually
disabled.
Please see this blog entry for description of dtrace feature in question --
http://dtrace.org/blogs/ahl/2006/05/08/user-land-tracing-gets-better-and-better/


On Wed, Jun 25, 2014 at 6:49 PM, Jonathan Rajotte-Julien <
jonathan.rajotte-julien@ericsson.com> wrote:

> You can also list all ust events available for tracing via the command
> "lttng list -u".
>
> Make sure that the application you want to trace is running.
>
> On 06/25/2014 10:40 AM, Thibault, Daniel wrote:
> > ----------------------------------------------------------------------
> > Date: Sun, 22 Jun 2014 19:27:31 +0400
> > From: Dmitri Shubin <sbn@tbricks.com>
> >
> >> In dtrace it's possible to check if some probe is currently enabled or
> not (to avoid argument preparation for disabled probes).
> >> But I'm unable to find similar feature in lttng-ust (at least it's not
> mentioned in lttng-ust man page).
> >>
> >> Am I missed it or it's not implemented on purpose?
> >
> >    Use the list command.  A command such as 'lttng list <session_name>'
> will list the known events and their enabled/disabled status.  You can
> filter the command's output by specifying a domain (--userspace) and/or a
> channel (--channel <channel_name>).  For example:
> >
> > (begin example)
> > $ lttng create some_session
> > Session some_session created.
> > Traces will be written in /home/username/lttng-traces/
> some_session-20140625-102709
> > $ lttng enable-event -u some_event
> > UST event some_event created in channel channel0
> > $ lttng list some_session -u --channel channel0
> > Tracing session some_session: [inactive]
> >     Trace path: /home/username/lttng-traces/ some_session-20140625-102709
> >
> > === Domain: UST global ===
> >
> > Buffer type: per UID
> >
> > - channel0: [enabled]
> >
> >     Attributes:
> >       overwrite mode: 0
> >       subbuffers size: 131072
> >       number of subbufers: 4
> >       switch time interval: 0
> >       read time interval: 0
> >       output: mmap()
> >
> >     Events:
> >       some_event (type: tracepoint) [enabled]
> > (end example)
> >
> >    You can take a look at
> /usr/src/lttng-tools/src/bin/lttng/commands/list.c to see how the
> information is obtained.
> >
> > Daniel U. Thibault
> > Protection des systèmes et contremesures (PSC) | Systems Protection &
> Countermeasures (SPC)
> > Cyber sécurité pour les missions essentielles (CME) | Mission Critical
> Cyber Security (MCCS)
> > RDDC - Centre de recherches de Valcartier | DRDC - Valcartier Research
> Centre
> > 2459 route de la Bravoure
> > Québec QC  G3J 1X5
> > CANADA
> > Vox : (418) 844-4000 x4245
> > Fax : (418) 844-4538
> > NAC : 918V QSDJ <http://www.travelgis.com/map.asp?addr=918V%20QSDJ>
> > Gouvernement du Canada | Government of Canada
> > <http://www.valcartier.drdc-rddc.gc.ca/>
> >
> > _______________________________________________
> > lttng-dev mailing list
> > lttng-dev@lists.lttng.org
> > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
> >
>
>
> _______________________________________________
> lttng-dev mailing list
> lttng-dev@lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>

[-- Attachment #1.2: Type: text/html, Size: 4787 bytes --]

[-- Attachment #2: Type: text/plain, Size: 155 bytes --]

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

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

* Re: How to check is tracepoint is currently enabled (UST)
       [not found]   ` <CAFXXi0=XEwjPfLwxsGim6_FwRqGD-YM9o1zTVFRWbmyigGDPcw@mail.gmail.com>
@ 2014-06-28  9:15     ` Dmitri Shubin
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitri Shubin @ 2014-06-28  9:15 UTC (permalink / raw)
  To: Simon Marchi; +Cc: lttng-dev


[-- Attachment #1.1: Type: text/plain, Size: 1219 bytes --]

Hi Simon,

Thank you for reply!

On Wed, Jun 25, 2014 at 7:36 PM, Simon Marchi <simon.marchi@polymtl.ca>
wrote:

> I am pretty sure that Dmitri is talking about a check that you can use
> in your application, to see if a specific tracepoint is enabled. If
> some data that you pass to the tracepoint is expensive to compute, yo
> might want to avoid computing it when tracing is disabled.
>

Yes, exactly.
Here is nice explanation from dtrace author --
http://dtrace.org/blogs/ahl/2006/05/08/user-land-tracing-gets-better-and-better/
(see Is-Enabled probes)



> > #define tracepoint_enabled(provider, name)
> caa_unlikely(__tracepoint_##provider##___##name.state)
>
> Dmitri, that macro that you posted, does it work for you?
>

Yes, looks working AFAIKT.
I.e. if (tracepoint_enabled()) { printf(); } gives correct enabled/disabled
state.


Otherwise, you can simply embed the code in the call to tracepoint:
>

Thanks for suggestions!
Moving argument evaluation to function is a bit tedious.
Statement expressions looks nicer, but their portability is questionable
(although clang that we use seems to support them).

So from my point of view having tracepoint_enabled() macro is the best
possible solution.

Thanks!

[-- Attachment #1.2: Type: text/html, Size: 2291 bytes --]

[-- Attachment #2: Type: text/plain, Size: 155 bytes --]

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

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

* Re: How to check is tracepoint is currently enabled (UST)
@ 2014-06-25 14:40 Thibault, Daniel
  0 siblings, 0 replies; 6+ messages in thread
From: Thibault, Daniel @ 2014-06-25 14:40 UTC (permalink / raw)
  To: lttng-dev

----------------------------------------------------------------------
Date: Sun, 22 Jun 2014 19:27:31 +0400
From: Dmitri Shubin <sbn@tbricks.com>

> In dtrace it's possible to check if some probe is currently enabled or not (to avoid argument preparation for disabled probes).
> But I'm unable to find similar feature in lttng-ust (at least it's not mentioned in lttng-ust man page).
>
> Am I missed it or it's not implemented on purpose?

   Use the list command.  A command such as 'lttng list <session_name>' will list the known events and their enabled/disabled status.  You can filter the command's output by specifying a domain (--userspace) and/or a channel (--channel <channel_name>).  For example:

(begin example)
$ lttng create some_session
Session some_session created.
Traces will be written in /home/username/lttng-traces/ some_session-20140625-102709
$ lttng enable-event -u some_event
UST event some_event created in channel channel0
$ lttng list some_session -u --channel channel0
Tracing session some_session: [inactive]
    Trace path: /home/username/lttng-traces/ some_session-20140625-102709

=== Domain: UST global ===

Buffer type: per UID

- channel0: [enabled]

    Attributes:
      overwrite mode: 0
      subbuffers size: 131072
      number of subbufers: 4
      switch time interval: 0
      read time interval: 0
      output: mmap()

    Events:
      some_event (type: tracepoint) [enabled]
(end example)

   You can take a look at /usr/src/lttng-tools/src/bin/lttng/commands/list.c to see how the information is obtained.

Daniel U. Thibault
Protection des systèmes et contremesures (PSC) | Systems Protection & Countermeasures (SPC)
Cyber sécurité pour les missions essentielles (CME) | Mission Critical Cyber Security (MCCS)
RDDC - Centre de recherches de Valcartier | DRDC - Valcartier Research Centre
2459 route de la Bravoure
Québec QC  G3J 1X5
CANADA
Vox : (418) 844-4000 x4245
Fax : (418) 844-4538
NAC : 918V QSDJ <http://www.travelgis.com/map.asp?addr=918V%20QSDJ>
Gouvernement du Canada | Government of Canada
<http://www.valcartier.drdc-rddc.gc.ca/>

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

* How to check is tracepoint is currently enabled (UST)
@ 2014-06-22 15:27 Dmitri Shubin
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitri Shubin @ 2014-06-22 15:27 UTC (permalink / raw)
  To: lttng-dev


[-- Attachment #1.1: Type: text/plain, Size: 464 bytes --]

Hi,

In dtrace it's possible to check if some probe is currently enabled or not
(to avoid argument preparation for disabled probes).
But I'm unable to find similar feature in lttng-ust (at least it's not
mentioned in lttng-ust man page).

Am I missed it or it's not implemented on purpose?

From what I see in lttng/tracepoint.h it can be implemented like

#define tracepoint_enabled(provider,
name) caa_unlikely(__tracepoint_##provider##___##name.state)

Thanks!

[-- Attachment #1.2: Type: text/html, Size: 656 bytes --]

[-- Attachment #2: Type: text/plain, Size: 155 bytes --]

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

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

end of thread, other threads:[~2014-06-28  9:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <48CF5AC71E61DB46B70D0F388054EFFD359C62DE@VAL-E-02.valcartier.drdc-rddc.gc.ca>
2014-06-25 14:49 ` How to check is tracepoint is currently enabled (UST) Jonathan Rajotte-Julien
     [not found] ` <53AAE15C.3040100@ericsson.com>
2014-06-25 15:36   ` Simon Marchi
2014-06-27 10:32   ` Dmitri Shubin
     [not found]   ` <CAFXXi0=XEwjPfLwxsGim6_FwRqGD-YM9o1zTVFRWbmyigGDPcw@mail.gmail.com>
2014-06-28  9:15     ` Dmitri Shubin
2014-06-25 14:40 Thibault, Daniel
  -- strict thread matches above, loose matches on Subject: below --
2014-06-22 15:27 Dmitri Shubin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.