diff mbox

[v2,6/6] trace: use -1 instead of TRACE_VCPU_EVENT_COUNT as magic value

Message ID 1473872922-23449-7-git-send-email-berrange@redhat.com
State New
Headers show

Commit Message

Daniel P. Berrangé Sept. 14, 2016, 5:08 p.m. UTC
The TraceEvent struct vcpu_id field uses the constant
TRACE_VCPU_EVENT_COUNT as a magic value to indicate this
is not a per-VCPU event. The max count value will be
different for each event group though, so this is no
longer suitable. Instead use the value (size_t)-1 which
is guaranteed to be available across all event groups.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 scripts/tracetool/format/events_c.py | 2 +-
 trace/control-internal.h             | 2 +-
 trace/control.h                      | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

Comments

LluĂ­s Vilanova Sept. 14, 2016, 11:12 p.m. UTC | #1
Daniel P Berrange writes:

> The TraceEvent struct vcpu_id field uses the constant
> TRACE_VCPU_EVENT_COUNT as a magic value to indicate this
> is not a per-VCPU event. The max count value will be
> different for each event group though, so this is no
> longer suitable. Instead use the value (size_t)-1 which
> is guaranteed to be available across all event groups.

The tracetool script should assert used vcpu IDs never reach ~0. Also, this
patch is better sent with your actual event group patches (see comments on patch
5).

Cheers,
  Lluis
diff mbox

Patch

diff --git a/scripts/tracetool/format/events_c.py b/scripts/tracetool/format/events_c.py
index a2f457f..104135f 100644
--- a/scripts/tracetool/format/events_c.py
+++ b/scripts/tracetool/format/events_c.py
@@ -34,7 +34,7 @@  def generate(events, backend):
         if "vcpu" in e.properties:
             vcpu_id = "TRACE_VCPU_" + e.name.upper()
         else:
-            vcpu_id = "TRACE_VCPU_EVENT_COUNT"
+            vcpu_id = "(uint32_t)-1";
         out('    { .id = %(id)s, .vcpu_id = %(vcpu_id)s,'
             ' .name = \"%(name)s\",'
             ' .sstate = %(sstate)s,',
diff --git a/trace/control-internal.h b/trace/control-internal.h
index 2981f11..d5ceb42 100644
--- a/trace/control-internal.h
+++ b/trace/control-internal.h
@@ -38,7 +38,7 @@  static inline uint32_t trace_event_get_vcpu_id(TraceEvent *ev)
 
 static inline bool trace_event_is_vcpu(TraceEvent *ev)
 {
-    return ev->vcpu_id != TRACE_VCPU_EVENT_COUNT;
+    return ev->vcpu_id != (uint32_t)-1;
 }
 
 static inline const char * trace_event_get_name(TraceEvent *ev)
diff --git a/trace/control.h b/trace/control.h
index d660fd2..545be29 100644
--- a/trace/control.h
+++ b/trace/control.h
@@ -71,7 +71,7 @@  static uint32_t trace_event_get_id(TraceEvent *ev);
  *
  * Get the per-vCPU identifier of an event.
  *
- * Special value #TRACE_VCPU_EVENT_COUNT means the event is not vCPU-specific
+ * Special value (uint32_t)-1 means the event is not vCPU-specific
  * (does not have the "vcpu" property).
  */
 static uint32_t trace_event_get_vcpu_id(TraceEvent *ev);