[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/5] memory: add ref/unref interface for MemroyR
liu ping fan
Re: [Qemu-devel] [PATCH 1/5] memory: add ref/unref interface for MemroyRegionOps
Fri, 12 Apr 2013 12:12:13 +0800
On Thu, Apr 11, 2013 at 5:49 PM, Stefan Hajnoczi <address@hidden> wrote:
> On Mon, Apr 01, 2013 at 04:20:30PM +0800, Liu Ping Fan wrote:
>> From: Liu Ping Fan <address@hidden>
>> This pair of interface are optinal, except for those device which is
>> used outside the biglock's protection for hot unplug.
> Not sure if this comment is true. Memory unplug safety is not about the
> big lock, it's about whether a reference to memory is held *across* a
> hot unplug operation.
What I exactly mean is DeviceX unplug is under biglock, so if
operations on DeviceX are all within the biglock, they are safe. But
that is not the trueth with RAM. So using ref/unref to manage the
reference to memory
> So even code that is under the big lock can use a guest RAM buffer
> across the event loop, and therefore be exposed to a RAM unplug!
> Therefore inc/dec must be used if guest RAM is held across event loop
The ref/unref interface wrapper the inc/dec, exposes them from MemoryRegionOps.
> handler calls. If the guest RAM access happens completely inside a
> handler function, then it is not affected by hot plug and doesn't need
> to do inc/dec.
Yes, that is truth. And that is why only calling ref/unref in
HostMemListener region_add, but not in mem_add().