From: "Lluís Vilanova" <vilanova@ac.upc.edu>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v4 12/17] trace: dynamically allocate trace_dstate in CPUState
Date: Thu, 22 Sep 2016 14:47:57 +0200 [thread overview]
Message-ID: <8760ponls2.fsf@fimbulvetr.bsc.es> (raw)
In-Reply-To: <1474533652-31170-13-git-send-email-berrange@redhat.com> (Daniel P. Berrange's message of "Thu, 22 Sep 2016 09:40:47 +0100")
Daniel P Berrange writes:
> The CPUState struct has a bitmap tracking which VCPU
> events are currently active. This is indexed based on
> the event ID values, and sized according the maximum
> TraceEventVCPUID enum value.
> When we start dynamically assigning IDs at runtime,
> we can't statically declare a bitmap without making
> an assumption about the max event count. This problem
> can be solved by dynamically allocating the per-CPU
> dstate bitmap.
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
> include/qom/cpu.h | 8 +++++---
> qom/cpu.c | 6 +++++-
> trace/control.c | 5 +++++
> trace/control.h | 7 +++++++
> 4 files changed, 22 insertions(+), 4 deletions(-)
> diff --git a/include/qom/cpu.h b/include/qom/cpu.h
> index ce0c406..ec5ad86 100644
> --- a/include/qom/cpu.h
> +++ b/include/qom/cpu.h
> @@ -27,7 +27,6 @@
> #include "qemu/bitmap.h"
> #include "qemu/queue.h"
> #include "qemu/thread.h"
> -#include "trace/generated-events.h"
> typedef int (*WriteCoreDumpFunction)(const void *buf, size_t size,
> void *opaque);
> @@ -350,8 +349,11 @@ struct CPUState {
> struct KVMState *kvm_state;
> struct kvm_run *kvm_run;
> - /* Used for events with 'vcpu' and *without* the 'disabled' properties */
> - DECLARE_BITMAP(trace_dstate, TRACE_VCPU_EVENT_COUNT);
> + /* Used for events with 'vcpu' and *without* the 'disabled' properties
> + * Dynamically allocated based on bitmap requried to hold upto
upto -> up to
For more than one line, comments are usually:
/*
* text...
*/
> + * trace_get_vcpu_event_count() entries.
> + */
> + unsigned long *trace_dstate;
> /* TODO Move common fields from CPUArchState here. */
> int cpu_index; /* used by alpha TCG */
> diff --git a/qom/cpu.c b/qom/cpu.c
> index f783b5a..48bbf67 100644
> --- a/qom/cpu.c
> +++ b/qom/cpu.c
> @@ -29,6 +29,7 @@
> #include "qemu/error-report.h"
> #include "sysemu/sysemu.h"
> #include "hw/qdev-properties.h"
> +#include "trace/control.h"
> bool cpu_exists(int64_t id)
> {
> @@ -350,12 +351,15 @@ static void cpu_common_initfn(Object *obj)
> qemu_mutex_init(&cpu->work_mutex);
> QTAILQ_INIT(&cpu->breakpoints);
> QTAILQ_INIT(&cpu->watchpoints);
> - bitmap_zero(cpu->trace_dstate, TRACE_VCPU_EVENT_COUNT);
> +
> + cpu->trace_dstate = bitmap_new(trace_get_vcpu_event_count());
> }
> static void cpu_common_finalize(Object *obj)
> {
> + CPUState *cpu = CPU(obj);
> cpu_exec_exit(CPU(obj));
> + g_free(cpu->trace_dstate);
Now that you factored this into the cpu var, use it to call cpu_exec_exit too.
> }
> static int64_t cpu_common_get_arch_id(CPUState *cpu)
> diff --git a/trace/control.c b/trace/control.c
> index 7be654d..9704f4d 100644
> --- a/trace/control.c
> +++ b/trace/control.c
> @@ -310,3 +310,8 @@ void trace_init_vcpu_events(void)
> }
> }
> }
> +
> +uint32_t trace_get_vcpu_event_count(void)
> +{
> + return TRACE_VCPU_EVENT_COUNT;
> +}
> diff --git a/trace/control.h b/trace/control.h
> index 45ee4fb..feb5397 100644
> --- a/trace/control.h
> +++ b/trace/control.h
> @@ -235,6 +235,13 @@ char *trace_opt_parse(const char *optarg);
> void trace_init_vcpu_events(void);
> +/**
> + * trace_get_vcpu_event_count:
> + *
> + * Return the number of known vcpu-specific events
> + */
> +uint32_t trace_get_vcpu_event_count(void);
> +
> #include "trace/control-internal.h"
> #endif /* TRACE__CONTROL_H */
> --
> 2.7.4
next prev parent reply other threads:[~2016-09-22 12:48 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-22 8:40 [Qemu-devel] [PATCH v4 00/17] Refactor trace to allow modular build Daniel P. Berrange
2016-09-22 8:40 ` [Qemu-devel] [PATCH v4 01/17] trace: add trace event iterator APIs Daniel P. Berrange
2016-09-23 13:39 ` Stefan Hajnoczi
2016-09-22 8:40 ` [Qemu-devel] [PATCH v4 02/17] trace: convert code to use event iterators Daniel P. Berrange
2016-09-22 12:20 ` Lluís Vilanova
2016-09-22 12:45 ` Daniel P. Berrange
2016-09-22 8:40 ` [Qemu-devel] [PATCH v4 03/17] trace: remove some now unused functions Daniel P. Berrange
2016-09-23 13:39 ` Stefan Hajnoczi
2016-09-22 8:40 ` [Qemu-devel] [PATCH v4 04/17] trace: remove global 'uint16 dstate[]' array Daniel P. Berrange
2016-09-23 13:51 ` Stefan Hajnoczi
2016-09-22 8:40 ` [Qemu-devel] [PATCH v4 05/17] trace: remove duplicate control.h includes in generated-tracers.h Daniel P. Berrange
2016-09-23 13:52 ` Stefan Hajnoczi
2016-09-22 8:40 ` [Qemu-devel] [PATCH v4 06/17] trace: break circular dependency in event-internal.h Daniel P. Berrange
2016-09-22 12:22 ` Lluís Vilanova
2016-09-23 13:53 ` Stefan Hajnoczi
2016-09-22 8:40 ` [Qemu-devel] [PATCH v4 07/17] trace: give each trace event a named TraceEvent struct Daniel P. Berrange
2016-09-22 12:26 ` Lluís Vilanova
2016-09-23 14:10 ` Stefan Hajnoczi
2016-09-22 8:40 ` [Qemu-devel] [PATCH v4 08/17] trace: remove the TraceEventID and TraceEventVCPUID enums Daniel P. Berrange
2016-09-22 12:35 ` Lluís Vilanova
2016-09-22 12:44 ` Daniel P. Berrange
2016-09-22 16:12 ` Lluís Vilanova
2016-09-22 18:42 ` Lluís Vilanova
2016-09-23 14:12 ` Stefan Hajnoczi
2016-09-23 14:23 ` Stefan Hajnoczi
2016-09-22 8:40 ` [Qemu-devel] [PATCH v4 09/17] trace: emit name <-> ID mapping in simpletrace header Daniel P. Berrange
2016-09-22 8:40 ` [Qemu-devel] [PATCH v4 10/17] trace: don't abort qemu if ftrace can't be initialized Daniel P. Berrange
2016-09-22 8:40 ` [Qemu-devel] [PATCH v4 11/17] trace: provide mechanism for registering trace events Daniel P. Berrange
2016-09-22 12:44 ` Lluís Vilanova
2016-09-22 12:48 ` Daniel P. Berrange
2016-09-22 8:40 ` [Qemu-devel] [PATCH v4 12/17] trace: dynamically allocate trace_dstate in CPUState Daniel P. Berrange
2016-09-22 12:47 ` Lluís Vilanova [this message]
2016-09-22 8:40 ` [Qemu-devel] [PATCH v4 13/17] trace: dynamically allocate event IDs at runtime Daniel P. Berrange
2016-09-22 12:50 ` Lluís Vilanova
2016-09-22 8:40 ` [Qemu-devel] [PATCH v4 14/17] trace: get rid of generated-events.h/generated-events.c Daniel P. Berrange
2016-09-22 12:59 ` Lluís Vilanova
2016-09-22 8:40 ` [Qemu-devel] [PATCH v4 15/17] trace: rename _read_events to read_events Daniel P. Berrange
2016-09-22 8:40 ` [Qemu-devel] [PATCH v4 16/17] trace: push reading of events up a level to tracetool main Daniel P. Berrange
2016-09-22 8:40 ` [Qemu-devel] [PATCH v4 17/17] trace: pass trace-events to tracetool as a positional param Daniel P. Berrange
2016-09-22 13:00 ` Lluís Vilanova
2016-09-22 13:04 ` [Qemu-devel] [PATCH v4 00/17] Refactor trace to allow modular build 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=8760ponls2.fsf@fimbulvetr.bsc.es \
--to=vilanova@ac.upc.edu \
--cc=berrange@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 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.