All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] simpletrace: Inline runtime state check
Date: Tue, 19 Oct 2010 16:14:09 +0200	[thread overview]
Message-ID: <4CBDA7B1.6020902@siemens.com> (raw)

Instead of preparing all traced args, jumping into the common trace
function, even collecting a timestamp, do the check if a particular
tracepoint is enabled inline. Also, mark the enabled case unlikely to
motivate the compiler to push the trace code out of the fastpath.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 simpletrace.c |    4 ----
 tracetool     |    7 +++++--
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/simpletrace.c b/simpletrace.c
index deb1e07..224e4ab 100644
--- a/simpletrace.c
+++ b/simpletrace.c
@@ -148,10 +148,6 @@ static void trace(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3,
      */
     clock_gettime(CLOCK_MONOTONIC, &ts);
 
-    if (!trace_list[event].state) {
-        return;
-    }
-
     rec->event = event;
     rec->timestamp_ns = ts.tv_sec * 1000000000LL + ts.tv_nsec;
     rec->x1 = x1;
diff --git a/tracetool b/tracetool
index 7010858..9532409 100755
--- a/tracetool
+++ b/tracetool
@@ -146,6 +146,8 @@ linetoh_begin_simple()
 {
     cat <<EOF
 #include "simpletrace.h"
+
+extern TraceEvent trace_list[];
 EOF
 
     simple_event_num=0
@@ -179,7 +181,9 @@ linetoh_simple()
     cat <<EOF
 static inline void trace_$name($args)
 {
-    trace$argc($trace_args);
+    if (unlikely(trace_list[$simple_event_num].state)) {
+        trace$argc($trace_args);
+    }
 }
 EOF
 
@@ -190,7 +194,6 @@ linetoh_end_simple()
 {
     cat <<EOF
 #define NR_TRACE_EVENTS $simple_event_num
-extern TraceEvent trace_list[NR_TRACE_EVENTS];
 EOF
 }
 
-- 
1.7.1

             reply	other threads:[~2010-10-19 14:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-19 14:14 Jan Kiszka [this message]
2010-10-19 15:18 ` [Qemu-devel] Re: [PATCH] simpletrace: Inline runtime state check Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CBDA7B1.6020902@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.