qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] colo: fix return without releasing RCU


From: Dr. David Alan Gilbert
Subject: Re: [PATCH] colo: fix return without releasing RCU
Date: Fri, 13 Dec 2019 15:03:41 +0000
User-agent: Mutt/1.13.0 (2019-11-30)

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

Reviewed-by: Dr. David Alan Gilbert <address@hidden>

> ---
>  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 / address@hidden / Manchester, UK




reply via email to

[Prev in Thread] Current Thread [Next in Thread]