From: Paolo Bonzini <pbonzini@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
qemu-block@nongnu.org, Alberto Garcia <berto@igalia.com>
Subject: Re: [Qemu-devel] [PATCH] throttle-groups: fix restart coroutine iothread race
Date: Fri, 11 Jan 2019 15:36:56 +0100 [thread overview]
Message-ID: <9bf9a0c7-c04c-0c12-e58d-6a2e41b0af4f@redhat.com> (raw)
In-Reply-To: <20190109110144.18633-1-stefanha@redhat.com>
On 09/01/19 12:01, Stefan Hajnoczi wrote:
> g_free(data);
> +
> + tgm->restart_pending--;
> + aio_wait_kick();
> }
>
> static void throttle_group_restart_queue(ThrottleGroupMember *tgm, bool is_write)
> @@ -430,6 +433,8 @@ static void throttle_group_restart_queue(ThrottleGroupMember *tgm, bool is_write
> * be no timer pending on this tgm at this point */
> assert(!timer_pending(tgm->throttle_timers.timers[is_write]));
>
> + tgm->restart_pending++;
> +
> co = qemu_coroutine_create(throttle_group_restart_queue_entry, rd);
> aio_co_enter(tgm->aio_context, co);
> }
> @@ -538,6 +543,7 @@ void throttle_group_register_tgm(ThrottleGroupMember *tgm,
>
> tgm->throttle_state = ts;
> tgm->aio_context = ctx;
> + tgm->restart_pending = 0;
>
> qemu_mutex_lock(&tg->lock);
> /* If the ThrottleGroup is new set this ThrottleGroupMember as the token */
> @@ -584,6 +590,9 @@ void throttle_group_unregister_tgm(ThrottleGroupMember *tgm)
> return;
> }
>
> + /* Wait for throttle_group_restart_queue_entry() coroutines to finish */
> + AIO_WAIT_WHILE(tgm->aio_context, tgm->restart_pending > 0);
> +
Could you change this to atomic_inc/dec, and atomic_read here? It would
be nice to avoid more uses of the AioContext lock.
Paolo
prev parent reply other threads:[~2019-01-11 14:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-09 11:01 [Qemu-devel] [PATCH] throttle-groups: fix restart coroutine iothread race Stefan Hajnoczi
2019-01-09 13:49 ` Alberto Garcia
2019-01-09 15:34 ` Alberto Garcia
2019-01-11 13:19 ` Alberto Garcia
2019-01-11 13:24 ` Kevin Wolf
2019-01-11 14:14 ` Alberto Garcia
2019-01-14 13:35 ` Stefan Hajnoczi
2019-01-14 14:40 ` Alberto Garcia
2019-01-14 16:15 ` Stefan Hajnoczi
2019-01-14 16:26 ` Alberto Garcia
2019-01-14 16:31 ` Stefan Hajnoczi
2019-01-14 20:56 ` Alberto Garcia
2019-01-15 14:18 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2019-01-15 14:49 ` Alberto Garcia
2019-01-11 14:36 ` Paolo Bonzini [this message]
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=9bf9a0c7-c04c-0c12-e58d-6a2e41b0af4f@redhat.com \
--to=pbonzini@redhat.com \
--cc=berto@igalia.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--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).