From: Paolo Bonzini <pbonzini@redhat.com>
To: Frederic Konrad <fred.konrad@greensocs.com>,
qemu-devel@nongnu.org, mttcg@greensocs.com
Cc: mark.burton@greensocs.com, alex.bennee@linaro.org,
a.rigo@virtualopensystems.com, guillaume.delbergue@greensocs.com
Subject: Re: [Qemu-devel] [RFC PATCH 1/3] cpus: protect queued_work_* with work_mutex.
Date: Fri, 10 Jul 2015 17:34:24 +0200 [thread overview]
Message-ID: <559FE600.7040500@redhat.com> (raw)
In-Reply-To: <559FE58C.6040400@greensocs.com>
On 10/07/2015 17:32, Frederic Konrad wrote:
>>>
>
> I think something like that can work because we don't have two
> flush_queued_work at the same time on the same CPU?
Yes, this works; there is only one consumer.
Holding locks within a callback can be very painful, especially if there
is a chance that the callback will take a very coarse lock such as big
QEMU lock. It can cause AB-BA deadlocks.
Paolo
> static void flush_queued_work(CPUState *cpu)
> {
> struct qemu_work_item *wi;
>
> if (cpu->queued_work_first == NULL) {
> return;
> }
>
> qemu_mutex_lock(&cpu->work_mutex);
> while ((wi = cpu->queued_work_first)) {
> cpu->queued_work_first = wi->next;
> qemu_mutex_unlock(&cpu->work_mutex);
> wi->func(wi->data);
> qemu_mutex_lock(&cpu->work_mutex);
> wi->done = true;
> if (wi->free) {
> g_free(wi);
> }
> }
> cpu->queued_work_last = NULL;
> qemu_mutex_unlock(&cpu->work_mutex);
>
> qemu_cond_broadcast(&qemu_work_cond);
> }
next prev parent reply other threads:[~2015-07-10 15:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-10 15:19 [Qemu-devel] [RFC PATCH 0/3] Multithread TCG async_safe_work part fred.konrad
2015-07-10 15:19 ` [Qemu-devel] [RFC PATCH 1/3] cpus: protect queued_work_* with work_mutex fred.konrad
2015-07-10 15:22 ` Paolo Bonzini
2015-07-10 15:32 ` Frederic Konrad
2015-07-10 15:34 ` Paolo Bonzini [this message]
2015-07-10 15:43 ` Frederic Konrad
2015-07-10 15:19 ` [Qemu-devel] [RFC PATCH 2/3] cpus: add a tcg_executing flag fred.konrad
2015-07-10 15:19 ` [Qemu-devel] [RFC PATCH 3/3] cpus: introduce async_run_safe_work_on_cpu fred.konrad
2015-07-10 15:23 ` Paolo Bonzini
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=559FE600.7040500@redhat.com \
--to=pbonzini@redhat.com \
--cc=a.rigo@virtualopensystems.com \
--cc=alex.bennee@linaro.org \
--cc=fred.konrad@greensocs.com \
--cc=guillaume.delbergue@greensocs.com \
--cc=mark.burton@greensocs.com \
--cc=mttcg@greensocs.com \
--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 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.