From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Juan Quintela <quintela@redhat.com>
Cc: Laurent Vivier <lvivier@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Thomas Huth <thuth@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [PATCH 4/4] migration: Make sure that we don't call write() in case of error
Date: Wed, 18 Dec 2019 16:33:01 +0000 [thread overview]
Message-ID: <20191218163301.GJ3707@work-vm> (raw)
In-Reply-To: <20191218050439.5989-5-quintela@redhat.com>
* Juan Quintela (quintela@redhat.com) wrote:
> If we are exiting due to an error/finish/.... Just don't try to even
> touch the channel with one IO operation.
>
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
> migration/ram.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/migration/ram.c b/migration/ram.c
> index 4b44578e57..909ef6d237 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -1601,6 +1601,12 @@ struct {
> QemuSemaphore channels_ready;
> /* multifd ops */
> MultiFDMethods *ops;
> + /*
> + * Have we already run terminate threads. There is a race when it
> + * happens that we got one error while we are exiting.
> + * We will use atomic operations. Only valid values are 0 and 1.
> + */
> + int exiting;
> } *multifd_send_state;
>
> /*
> @@ -1629,6 +1635,10 @@ static int multifd_send_pages(RAMState *rs)
> MultiFDPages_t *pages = multifd_send_state->pages;
> uint64_t transferred;
>
> + if (atomic_read(&multifd_send_state->exiting)) {
> + return -1;
> + }
> +
> qemu_sem_wait(&multifd_send_state->channels_ready);
> for (i = next_channel;; i = (i + 1) % migrate_multifd_channels()) {
> p = &multifd_send_state->params[i];
> @@ -1710,6 +1720,10 @@ static void multifd_send_terminate_threads(Error *err)
> }
> }
>
> + if (atomic_xchg(&multifd_send_state->exiting, 1)) {
> + return;
> + }
That could do with a comment on it; I think what you're saying is
'don't do send_terminate_threads twice'
With a comment,
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> for (i = 0; i < migrate_multifd_channels(); i++) {
> MultiFDSendParams *p = &multifd_send_state->params[i];
>
> @@ -1824,6 +1838,10 @@ static void *multifd_send_thread(void *opaque)
>
> while (true) {
> qemu_sem_wait(&p->sem);
> +
> + if (atomic_read(&multifd_send_state->exiting)) {
> + break;
> + }
> qemu_mutex_lock(&p->mutex);
>
> if (p->pending_job) {
> @@ -1938,6 +1956,7 @@ int multifd_save_setup(Error **errp)
> multifd_send_state->pages = multifd_pages_init(page_count);
> qemu_sem_init(&multifd_send_state->channels_ready, 0);
> multifd_send_state->ops = multifd_ops[migrate_multifd_method()];
> + atomic_set(&multifd_send_state->exiting, 0);
>
> for (i = 0; i < thread_count; i++) {
> MultiFDSendParams *p = &multifd_send_state->params[i];
> --
> 2.23.0
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
prev parent reply other threads:[~2019-12-18 16:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-18 5:04 [PATCH 0/4] Fix multifd + cancel + multifd Juan Quintela
2019-12-18 5:04 ` [PATCH 1/4] qemu-file: Don't do IO after shutdown Juan Quintela
2019-12-18 12:27 ` Dr. David Alan Gilbert
2019-12-18 14:35 ` Juan Quintela
2019-12-18 15:24 ` Dr. David Alan Gilbert
2019-12-29 18:20 ` Juan Quintela
2020-01-08 9:49 ` Dr. David Alan Gilbert
2020-01-08 12:40 ` Juan Quintela
2020-01-16 10:04 ` Juan Quintela
2019-12-18 5:04 ` [PATCH 2/4] multifd: Make sure that we don't do any IO after an error Juan Quintela
2019-12-18 13:57 ` Dr. David Alan Gilbert
2019-12-18 14:15 ` Juan Quintela
2019-12-18 5:04 ` [PATCH 3/4] migration-test: Make sure that multifd and cancel works Juan Quintela
2019-12-18 16:25 ` Dr. David Alan Gilbert
2019-12-29 18:27 ` Juan Quintela
2019-12-18 5:04 ` [PATCH 4/4] migration: Make sure that we don't call write() in case of error Juan Quintela
2019-12-18 16:33 ` Dr. David Alan Gilbert [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=20191218163301.GJ3707@work-vm \
--to=dgilbert@redhat.com \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=thuth@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).