From: Stefan Hajnoczi <stefanha@gmail.com>
To: "Lluís Vilanova" <vilanova@ac.upc.edu>
Cc: qemu-devel@nongnu.org, "Eduardo Habkost" <ehabkost@redhat.com>,
"Riku Voipio" <riku.voipio@iki.fi>,
"Blue Swirl" <blauwirbel@gmail.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH 4/6] trace: Add per-vCPU tracing states for events with the 'vcpu' property
Date: Thu, 9 Jun 2016 13:07:56 +0100 [thread overview]
Message-ID: <20160609120756.GA15369@stefanha-x1.localdomain> (raw)
In-Reply-To: <145641258612.30097.7127731954660712163.stgit@localhost>
[-- Attachment #1: Type: text/plain, Size: 3501 bytes --]
On Thu, Feb 25, 2016 at 04:03:06PM +0100, Lluís Vilanova wrote:
@@ -332,6 +334,16 @@ struct CPUState {
> struct KVMState *kvm_state;
> struct kvm_run *kvm_run;
>
> +#define TRACE_VCPU_DSTATE_TYPE uint32_t
> + TRACE_VCPU_DSTATE_TYPE trace_dstate;
Please use typedef instead of #define.
> + /*
> + * Ensure 'trace_dstate' can encode event states as a bitmask. This limits
> + * the number of events with the 'vcpu' property and *without* the
> + * 'disabled' property.
> + */
> + bool too_many_vcpu_events[
> + TRACE_VCPU_EVENT_COUNT > sizeof(TRACE_VCPU_DSTATE_TYPE)*8 ? -1 : 0];
Why limit ourselves to a scalar when "qemu/bitops.h" and "qemu/bitmap.h"
provide functions for arbitrary length bitmaps?
See DECLARE_BITMAP(), set_bit(), clear_bit(), test_bit().
> @@ -61,7 +69,7 @@ static inline bool trace_event_get_state_static(TraceEvent *ev)
> static inline bool trace_event_get_state_dynamic_by_id(TraceEventID id)
> {
> /* it's on fast path, avoid consistency checks (asserts) */
> - return unlikely(trace_events_enabled_count) && trace_events_dstate[id];
> + return unlikely(trace_events_enabled_count) && (trace_events_dstate[id] > 0);
typeof(trace_events_dstate[0]) is size_t, so trace_events_dstate[id] > 0
is equivalent to trace_events_dstate[id] (due to unsigned). Why change
this line?
> +void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
> +{
> + CPUState *cpu;
> + assert(ev != NULL);
> + assert(trace_event_get_state_static(ev));
> + if (trace_event_get_cpu_id(ev) != trace_event_cpu_count()) {
> + CPU_FOREACH(cpu) {
> + trace_event_set_cpu_state_dynamic(cpu, ev, state);
> + }
> + } else {
> + TraceEventID id = trace_event_get_id(ev);
> + trace_events_enabled_count += state - trace_events_dstate[id];
> + trace_events_dstate[id] = state;
> + }
> +}
I find it a little confusing to use different semantics for
trace_events_dstate[] elements depending on trace_event_get_cpu_id(ev)
!= trace_event_cpu_count(). In other words, it either acts as a vcpu
enabled counter or as an enable/disable flag.
That said, it's nice to preserve the non-cpu_id case since it was
written by Paolo as a performance optimization. Changing it could
introduce a regression so I think your approach is okay.
> +
> +void trace_event_set_cpu_state_dynamic(CPUState *cpu,
> + TraceEvent *ev, bool state)
> +{
> + TraceEventID id;
> + TraceEventVCPUID cpu_id;
> + TRACE_VCPU_DSTATE_TYPE bit;
> + bool state_pre;
> + assert(cpu != NULL);
> + assert(ev != NULL);
> + assert(trace_event_get_state_static(ev));
> + assert(trace_event_get_cpu_id(ev) != trace_event_cpu_count());
> + id = trace_event_get_id(ev);
> + cpu_id = trace_event_get_cpu_id(ev);
> + bit = ((TRACE_VCPU_DSTATE_TYPE)1) << cpu_id;
> + state_pre = cpu->trace_dstate & bit;
> + if ((state_pre == 0) != (state == 0)) {
Simpler expression:
if (state_pre != state)
> @@ -21,7 +21,10 @@
> #include "qemu/error-report.h"
>
> int trace_events_enabled_count;
> -bool trace_events_dstate[TRACE_EVENT_COUNT];
> +/* With the 'vcpu' property, counts how many vCPUs have it enabled. */
> +size_t trace_events_dstate[TRACE_EVENT_COUNT];
The number of cpus has type int (see CPUState *qemu_get_cpu(int index)).
Why did you choose size_t?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2016-06-09 12:08 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-25 15:02 [Qemu-devel] [PATCH0/6] trace: Per-vCPU tracing states Lluís Vilanova
2016-02-25 15:02 ` [Qemu-devel] [PATCH 1/6] trace: Identify events with the 'vcpu' property Lluís Vilanova
2016-06-09 12:11 ` Stefan Hajnoczi
2016-02-25 15:02 ` [Qemu-devel] [PATCH 2/6] disas: Remove unused macro '_' Lluís Vilanova
2016-06-09 8:18 ` Stefan Hajnoczi
2016-06-09 10:34 ` Lluís Vilanova
2016-02-25 15:03 ` [Qemu-devel] [PATCH 3/6] [trivial] trace: Cosmetic changes on fast-path tracing Lluís Vilanova
2016-06-09 12:11 ` Stefan Hajnoczi
2016-06-13 9:04 ` Paolo Bonzini
2016-06-13 13:39 ` Lluís Vilanova
2016-02-25 15:03 ` [Qemu-devel] [PATCH 4/6] trace: Add per-vCPU tracing states for events with the 'vcpu' property Lluís Vilanova
2016-06-09 12:07 ` Stefan Hajnoczi [this message]
2016-06-09 14:17 ` Lluís Vilanova
2016-06-10 16:25 ` Stefan Hajnoczi
2016-06-10 17:52 ` Lluís Vilanova
2016-06-13 8:38 ` Paolo Bonzini
2016-06-13 12:17 ` Lluís Vilanova
2016-06-13 9:13 ` Paolo Bonzini
2016-06-13 12:15 ` Lluís Vilanova
2016-06-13 14:08 ` Paolo Bonzini
2016-06-13 16:39 ` Lluís Vilanova
2016-06-14 8:39 ` Stefan Hajnoczi
2016-06-14 9:13 ` Paolo Bonzini
2016-06-14 12:17 ` Lluís Vilanova
2016-06-13 14:38 ` Lluís Vilanova
2016-02-25 15:03 ` [Qemu-devel] [PATCH 5/6] trace: Conditionally trace events based on their per-vCPU state Lluís Vilanova
2016-06-09 12:09 ` Stefan Hajnoczi
2016-02-25 15:03 ` [Qemu-devel] [PATCH 6/6] trace: Add QAPI/QMP interfaces to query and control per-vCPU tracing state Lluís Vilanova
2016-06-09 12:10 ` Stefan Hajnoczi
2016-03-07 19:35 ` [Qemu-devel] [PATCH0/6] trace: Per-vCPU tracing states Lluís Vilanova
2016-06-01 12:14 ` Lluís Vilanova
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=20160609120756.GA15369@stefanha-x1.localdomain \
--to=stefanha@gmail.com \
--cc=afaerber@suse.de \
--cc=blauwirbel@gmail.com \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
--cc=stefanha@redhat.com \
--cc=vilanova@ac.upc.edu \
/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).