From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrJsg-0005kX-Eu for qemu-devel@nongnu.org; Wed, 28 Oct 2015 02:06:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrJsc-0001jo-Ke for qemu-devel@nongnu.org; Wed, 28 Oct 2015 02:06:42 -0400 Received: from mail-pa0-x22e.google.com ([2607:f8b0:400e:c03::22e]:35119) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrJsc-0001ji-GG for qemu-devel@nongnu.org; Wed, 28 Oct 2015 02:06:38 -0400 Received: by pasz6 with SMTP id z6so246124106pas.2 for ; Tue, 27 Oct 2015 23:06:37 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 28 Oct 2015 07:06:26 +0100 Message-Id: <1446012388-9586-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1446012388-9586-1-git-send-email-pbonzini@redhat.com> References: <1446012388-9586-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 1/2] trace: count number of enabled events List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: stefanha@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 --- 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