From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: stefanha@redhat.com
Subject: [Qemu-devel] [PATCH 1/2] trace: count number of enabled events
Date: Wed, 28 Oct 2015 07:06:26 +0100 [thread overview]
Message-ID: <1446012388-9586-2-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1446012388-9586-1-git-send-email-pbonzini@redhat.com>
This lets trace_event_get_state_dynamic quickly return false. Right
now there is hardly any benefit because there are also many assertions
and indirections, but the next patch will streamline all of this.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
trace/control-internal.h | 4 +++-
trace/control.c | 2 ++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/trace/control-internal.h b/trace/control-internal.h
index 5a8df28..271bddb 100644
--- a/trace/control-internal.h
+++ b/trace/control-internal.h
@@ -14,6 +14,7 @@
extern TraceEvent trace_events[];
+extern int trace_events_enabled_count;
static inline TraceEventID trace_event_count(void)
@@ -54,13 +55,14 @@ static inline bool trace_event_get_state_static(TraceEvent *ev)
static inline bool trace_event_get_state_dynamic(TraceEvent *ev)
{
assert(ev != NULL);
- return ev->dstate;
+ return unlikely(trace_events_enabled_count) && ev->dstate;
}
static inline void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
{
assert(ev != NULL);
assert(trace_event_get_state_static(ev));
+ trace_events_enabled_count += state - ev->dstate;
ev->dstate = state;
}
diff --git a/trace/control.c b/trace/control.c
index 995beb3..95fbc07 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -16,6 +16,8 @@
#endif
#include "qemu/error-report.h"
+int trace_events_enabled_count;
+
TraceEvent *trace_event_name(const char *name)
{
assert(name != NULL);
--
2.5.0
next prev parent reply other threads:[~2015-10-28 6:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-28 6:06 [Qemu-devel] [PATCH for-2.5 0/2] trace: decrease overhead of simpletrace and stderr backends Paolo Bonzini
2015-10-28 6:06 ` Paolo Bonzini [this message]
2015-10-28 6:06 ` [Qemu-devel] [PATCH 2/2] trace: track enabled events in a separate array Paolo Bonzini
2015-10-28 14:44 ` [Qemu-devel] [PATCH for-2.5 0/2] trace: decrease overhead of simpletrace and stderr backends 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=1446012388-9586-2-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).