qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 07/15] memory: avoid ref/unref in memory_region_


From: Fam Zheng
Subject: Re: [Qemu-devel] [PATCH 07/15] memory: avoid ref/unref in memory_region_find
Date: Mon, 26 Jan 2015 14:24:48 +0800
User-agent: Mutt/1.5.23 (2014-03-12)

On Thu, 01/22 15:47, Paolo Bonzini wrote:
> Do the entire lookup under RCU, which avoids atomic operations.

address_space_get_flatview() already is RCU protected, I don't see why this
patch is necessary. Could you explain?

And there is one question below:

> 
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
>  memory.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/memory.c b/memory.c
> index a844ced..577e87c 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -1828,7 +1828,8 @@ MemoryRegionSection memory_region_find(MemoryRegion *mr,
>      }
>      range = addrrange_make(int128_make64(addr), int128_make64(size));
>  
> -    view = address_space_get_flatview(as);
> +    rcu_read_lock();
> +    view = atomic_rcu_read(&as->current_map);
>      fr = flatview_lookup(view, range);
>      if (!fr) {
>          flatview_unref(view);

Following lines are:

           return ret;
       }

Which requires a rcu_read_unlock.

Fam

> @@ -1850,7 +1851,7 @@ MemoryRegionSection memory_region_find(MemoryRegion *mr,
>      ret.readonly = fr->readonly;
>      memory_region_ref(ret.mr);
>  
> -    flatview_unref(view);
> +    rcu_read_unlock();
>      return ret;
>  }
>  
> -- 
> 1.8.3.1
> 
> 



reply via email to

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