qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Jiri Slaby <jslaby@suse.cz>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v4 1/1] pci-host: add educational driver
Date: Wed, 21 Jan 2015 17:40:23 +0100	[thread overview]
Message-ID: <54BFD677.2070905@redhat.com> (raw)
In-Reply-To: <1421857693-12014-1-git-send-email-jslaby@suse.cz>



On 21/01/2015 17:28, Jiri Slaby wrote:
> +        if (atomic_fetch_or(&edu->status, EDU_STATUS_COMPUTING) & EDU_STATUS_COMPUTING) {

Theoretically the other thread could see EDU_STATUS_COMPUTING here and
not enter the condvar wait.  So...

> +            break;
> +        }
> +        qemu_mutex_lock(&edu->thr_mutex);
> +        edu->fact = val;
> +        qemu_cond_signal(&edu->thr_cond);
> +        qemu_mutex_unlock(&edu->thr_mutex);

... just one change:

   if (atomic_read(&edu->status) & EDU_STATUS_COMPUTING) {
       break;
   }
   /* EDU_STATUS_COMPUTING cannot go 0->1 concurrently, because
    * it is only set in this function and it is under the iothread
    * mutex.
    */
   qemu_mutex_lock(&edu->thr_mutex);
   edu->fact = val;
   atomic_or(&edu->status), EDU_STATUS_COMPUTING);
   qemu_cond_signal(&edu->thr_cond);
   qemu_mutex_unlock(&edu->thr_mutex);

If you are okay with this change, I'll apply the patch to my tree.

Paolo

  reply	other threads:[~2015-01-21 16:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-21 16:28 [Qemu-devel] [PATCH v4 1/1] pci-host: add educational driver Jiri Slaby
2015-01-21 16:40 ` Paolo Bonzini [this message]
2015-01-21 16:44   ` Jiri Slaby
2015-01-21 16:48   ` [Qemu-devel] [PATCH v5 1/1] hw: misc, " Jiri Slaby
2015-01-21 16:58     ` Paolo Bonzini
2015-01-21 23:37     ` Eric Blake
2015-01-22  8:22       ` [Qemu-devel] [PATCH 1/1] edu: fix license information Jiri Slaby
2015-01-22  9:04         ` Markus Armbruster
2015-01-22  9:04           ` Jiri Slaby
2015-01-22  9:41             ` Markus Armbruster
2015-01-22 15:39         ` Eric Blake
2015-01-22 15:53           ` Paolo Bonzini
2015-01-22 19:10             ` Jiri Slaby
2015-01-23  7:40               ` Markus Armbruster
2015-01-21 23:49     ` [Qemu-devel] [PATCH v5 1/1] hw: misc, add educational driver Eric Blake

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=54BFD677.2070905@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=jslaby@suse.cz \
    --cc=qemu-devel@nongnu.org \
    /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).