qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC][PATCH 11/12] qcow2: Convert qcow2 to use coroutin


From: Anthony Liguori
Subject: Re: [Qemu-devel] [RFC][PATCH 11/12] qcow2: Convert qcow2 to use coroutines for async I/O
Date: Wed, 26 Jan 2011 10:28:15 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.15) Gecko/20101027 Lightning/1.0b1 Thunderbird/3.0.10

On 01/26/2011 10:13 AM, Avi Kivity wrote:
Serializing against a global mutex has the advantage that it can be treated as a global lock that is decomposed into fine-grained locks.

For example, we can start the code conversion from an explict async model to a threaded sync model by converting the mutex into a shared/exclusive lock. Operations like read and write take the lock for shared access (and take a fine-grained mutex on the metadata cache entry), while operation like creating a snapshot take the lock for exclusive access. That doesn't work with freeze/thaw.

The trouble with this is that you increase the amount of re-entrance whereas freeze/thaw doesn't.

The code from the beginning of the request to where the mutex is acquired will be executed for every single request even while requests are blocked at the mutex acquisition.

With freeze/thaw, you freeze the queue and prevent any request from starting until you thaw. You only thaw and return control to allow another request to execute when you begin executing an asynchronous I/O callback.

I think my previous example was wrong, you really want to do:

qcow2_aio_writev() {
   coroutine {
       freeze();
       sync_io(); // existing qcow2 code
       thaw();
       // existing non I/O code
       bdrv_aio_writev(callback); // no explicit freeze/thaw needed
   }
}

This is equivalent to our existing code because no new re-entrance is introduced. The only re-entrancy points are in the bdrv_aio_{readv,writev} calls.

Regards,

Anthony Liguori





reply via email to

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