qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Glauber Costa <glommer@redhat.com>
To: Paolo Bonzini <bonzini@gnu.org>
Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [RFC] queue_work proposal
Date: Thu, 3 Sep 2009 08:07:50 -0300	[thread overview]
Message-ID: <20090903110750.GN30340@mothafucka.localdomain> (raw)
In-Reply-To: <4A9F71E9.3090900@gnu.org>

On Thu, Sep 03, 2009 at 09:36:09AM +0200, Paolo Bonzini wrote:
>
>> +    env->queued_total++;
>> +
>> +    if (env == qemu_get_current_env()) {
>> +        env->queued_total++;
>
> Why increment twice? (though queued_total is write only and queued_local  
> is unused, so...)
yeah, you got it =p

As I said, I just dumped whatever I had.

>
>> +        func(data);
>> +        return;
>> +    }
>> +
>> +    wii = qemu_mallocz(sizeof(*wii));
>> +    wii->func = func;
>> +    wii->data = data;
>> +    wii->wait = wait;
>> +    TAILQ_INSERT_TAIL(&env->queued_work, wii, entry);
>> +
>> +    qemu_thread_signal(env->thread, SIGUSR1);
>> +
>> +    while (wait&&  !wii->done) {
>> +        qemu_cond_wait(env->work_cond,&qemu_global_mutex);
>> +    }
>
> You need to lock qemu_global_mutex around this while statement, or to  
> add env->queue_mutex and include the TAILQ_INSERT_TAIL in the mutex.
Thanks for catching. The later is clearly preferred , IMHO, for scalability
purposes.

  reply	other threads:[~2009-09-03 11:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-03  0:52 [Qemu-devel] [RFC] queue_work proposal Glauber Costa
2009-09-03  7:36 ` [Qemu-devel] " Paolo Bonzini
2009-09-03 11:07   ` Glauber Costa [this message]
2009-09-03  8:45 ` [Qemu-devel] " Avi Kivity
2009-09-03 11:15   ` Glauber Costa
2009-09-03 11:32     ` Avi Kivity
2009-09-03 12:11       ` Glauber Costa
2009-09-03 13:43         ` Avi Kivity
2009-09-03 16:46           ` Glauber Costa

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=20090903110750.GN30340@mothafucka.localdomain \
    --to=glommer@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=bonzini@gnu.org \
    --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).