qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	quintela@redhat.com, chen.zhang@intel.com
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH] colo: fix return without releasing RCU
Date: Fri, 13 Dec 2019 15:03:41 +0000	[thread overview]
Message-ID: <20191213150341.GG3713@work-vm> (raw)
In-Reply-To: <1576246112-23406-2-git-send-email-pbonzini@redhat.com>

* Paolo Bonzini (pbonzini@redhat.com) wrote:
> Use WITH_RCU_READ_LOCK_GUARD to avoid exiting colo_init_ram_cache
> without releasing RCU.
> 
> Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  migration/ram.c | 33 +++++++++++++++++----------------
>  1 file changed, 17 insertions(+), 16 deletions(-)
> 
> diff --git a/migration/ram.c b/migration/ram.c
> index 7dd7f81..8d7c015 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -3891,26 +3891,27 @@ int colo_init_ram_cache(void)
>  {
>      RAMBlock *block;
>  
> -    rcu_read_lock();
> -    RAMBLOCK_FOREACH_NOT_IGNORED(block) {
> -        block->colo_cache = qemu_anon_ram_alloc(block->used_length,
> -                                                NULL,
> -                                                false);
> -        if (!block->colo_cache) {
> -            error_report("%s: Can't alloc memory for COLO cache of block %s,"
> -                         "size 0x" RAM_ADDR_FMT, __func__, block->idstr,
> -                         block->used_length);
> -            RAMBLOCK_FOREACH_NOT_IGNORED(block) {
> -                if (block->colo_cache) {
> -                    qemu_anon_ram_free(block->colo_cache, block->used_length);
> -                    block->colo_cache = NULL;
> +    WITH_RCU_READ_LOCK_GUARD() {
> +        RAMBLOCK_FOREACH_NOT_IGNORED(block) {
> +            block->colo_cache = qemu_anon_ram_alloc(block->used_length,
> +                                                    NULL,
> +                                                    false);
> +            if (!block->colo_cache) {
> +                error_report("%s: Can't alloc memory for COLO cache of block %s,"
> +                             "size 0x" RAM_ADDR_FMT, __func__, block->idstr,
> +                             block->used_length);
> +                RAMBLOCK_FOREACH_NOT_IGNORED(block) {
> +                    if (block->colo_cache) {
> +                        qemu_anon_ram_free(block->colo_cache, block->used_length);
> +                        block->colo_cache = NULL;
> +                    }
>                  }
> +                return -errno;
>              }
> -            return -errno;
> +            memcpy(block->colo_cache, block->host, block->used_length);
>          }
> -        memcpy(block->colo_cache, block->host, block->used_length);
>      }
> -    rcu_read_unlock();
> +
>      /*
>      * Record the dirty pages that sent by PVM, we use this dirty bitmap together
>      * with to decide which page in cache should be flushed into SVM's RAM. Here
> -- 
> 1.8.3.1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



  reply	other threads:[~2019-12-13 21:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-13 14:08 [PATCH] colo: fix return without releasing RCU Paolo Bonzini
2019-12-13 15:03 ` Dr. David Alan Gilbert [this message]
2019-12-14 17:47   ` Zhang, Chen

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=20191213150341.GG3713@work-vm \
    --to=dgilbert@redhat.com \
    --cc=chen.zhang@intel.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@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).