diff mbox series

[RFC,05/21] trace: keep a count of trace-point hits

Message ID 20181005154910.3099-6-alex.bennee@linaro.org
State New
Headers show
Series Trace updates and plugin RFC | expand

Commit Message

Alex Bennée Oct. 5, 2018, 3:48 p.m. UTC
When working via the HMP to dynamically enable trace points it would
be useful to know if trace points are currently being hit. As the cost
is low we can simply increment a counter as we consider if we are
going to trace the event.

This cannot be precise as we don't take care to use atomic accesses
but it is usefully indicative.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

---
 scripts/tracetool/backend/simple.py | 2 ++
 trace/event-internal.h              | 1 +
 2 files changed, 3 insertions(+)

-- 
2.17.1

Comments

Richard Henderson Oct. 6, 2018, 6:26 p.m. UTC | #1
On 10/5/18 8:48 AM, Alex Bennée wrote:
> @@ -81,6 +81,8 @@ def generate_c(event, group):

>          cond = "trace_event_get_state(%s)" % event_id

>  

>      out('',

> +        '    %(event_obj)s.count++;',

> +        '',

>          '    if (!%(cond)s) {',

>          '        return;',

>          '    }',


Is it really "hit" if the condition isn't true?  And you'd want to document the
non-atomicity in a comment, lest it be "fixed" later.


r~
diff mbox series

Patch

diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backend/simple.py
index c2fd1c24c4..eaa19a1032 100644
--- a/scripts/tracetool/backend/simple.py
+++ b/scripts/tracetool/backend/simple.py
@@ -81,6 +81,8 @@  def generate_c(event, group):
         cond = "trace_event_get_state(%s)" % event_id
 
     out('',
+        '    %(event_obj)s.count++;',
+        '',
         '    if (!%(cond)s) {',
         '        return;',
         '    }',
diff --git a/trace/event-internal.h b/trace/event-internal.h
index f63500b37e..8ab3a29941 100644
--- a/trace/event-internal.h
+++ b/trace/event-internal.h
@@ -37,6 +37,7 @@  typedef struct TraceEvent {
     const char * name;
     const bool sstate;
     uint16_t *dstate;
+    uint64_t count;
 } TraceEvent;
 
 void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state);