qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	qemu-devel@nongnu.org, Alex Bligh <alex@alex.org.uk>,
	Paolo Bonzini <pbonzini@redhat.com>,
	MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Subject: Re: [Qemu-devel] [PATCH 2/4] timer: protect timers_state's clock with seqlock
Date: Tue, 6 Aug 2013 11:30:02 +0200	[thread overview]
Message-ID: <20130806093002.GA3501@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <1375688006-16780-3-git-send-email-pingfank@linux.vnet.ibm.com>

On Mon, Aug 05, 2013 at 03:33:24PM +0800, Liu Ping Fan wrote:
> diff --git a/cpus.c b/cpus.c
> index 85e743d..ab92db9 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -107,12 +107,17 @@ static int64_t qemu_icount;
>  typedef struct TimersState {
>      int64_t cpu_ticks_prev;
>      int64_t cpu_ticks_offset;
> +    /* QemuClock will be read out of BQL, so protect is with private lock.
> +     * As for cpu_ticks, no requirement to read it outside BQL.
> +     * Lock rule: innermost
> +     */

Please document exactly which fields the lock protects.

>  /* enable cpu_get_ticks() */
>  void cpu_enable_ticks(void)
>  {
> +    /* Here, the really thing protected by seqlock is cpu_clock. */

What is cpu_clock?

> @@ -364,6 +383,9 @@ static const VMStateDescription vmstate_timers = {
>  
>  void configure_icount(const char *option)
>  {
> +    QemuMutex *mutex = g_malloc0(sizeof(QemuMutex));
> +    qemu_mutex_init(mutex);
> +    seqlock_init(&timers_state.clock_seqlock, mutex);

We always set up this mutex, so it could be a field in timers_state.
That avoids the g_malloc() without g_free().

  parent reply	other threads:[~2013-08-06  9:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-05  7:33 [Qemu-devel] [PATCH 0/4]: timers thread-safe stuff Liu Ping Fan
2013-08-05  7:33 ` [Qemu-devel] [PATCH 1/4] seqlock: introduce read-write seqlock Liu Ping Fan
2013-08-05  7:33 ` [Qemu-devel] [PATCH 2/4] timer: protect timers_state's clock with seqlock Liu Ping Fan
2013-08-05 13:29   ` Paolo Bonzini
2013-08-06  5:58     ` liu ping fan
2013-08-06  7:31       ` Paolo Bonzini
2013-08-06  9:30   ` Stefan Hajnoczi [this message]
2013-08-07  5:46     ` liu ping fan
2013-08-05  7:33 ` [Qemu-devel] [PATCH 3/4] qemu-thread: add QemuEvent Liu Ping Fan
2013-08-05  7:33 ` [Qemu-devel] [PATCH 4/4] timer: make qemu_clock_enable sync between disable and timer's cb Liu Ping Fan
2013-08-05 10:53   ` Paolo Bonzini
2013-08-05 10:00 ` [Qemu-devel] [PATCH 0/4]: timers thread-safe stuff Alex Bligh
2013-08-06  5:37   ` liu ping fan
2013-08-06  6:14     ` Alex Bligh

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=20130806093002.GA3501@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=alex@alex.org.uk \
    --cc=jan.kiszka@siemens.com \
    --cc=kwolf@redhat.com \
    --cc=morita.kazutaka@lab.ntt.co.jp \
    --cc=pbonzini@redhat.com \
    --cc=pingfank@linux.vnet.ibm.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).