|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH RESEND 3/4] qdisk, hw/block/xen_disk: Perform grant copy instead of grant map.
On Tue, May 31, 2016 at 06:44:57AM +0200, Paulina Szubarczyk wrote:
> Grant copy operation is divided into two phases different for
> 'read' and 'write' operation.
>
> For a 'read' operation the flow is as follow:
> 1. allocate local buffers for all the segments contained in
> a request.
> 2. fill the request io vectors with the buffers' addresses
> 3. invoke read operation by qemu device
> 4. in the completition call grant copy
> 5. free the buffers
>
> Function 'ioreq_read_init' implements 1. and 2. step. It is called
> instead of 'ioreq_map' in 'ioreq_runio_qemu_aio'. Then the function
> 'ioreq_runio_qemu_aio' continues withouth changes performing step 3.
> Steps 4. and 5. are called in the callback function
> 'qemu_aio_complete'. The ioreq_read' function is implemented for
> step 4 which calls the new function 'xc_gnttab_copy_grant' presented
> in the other part of the patch.
>
> For a 'write' operation steps 4. happens before step 2.. First data
> are copied from calling guest domains and then qemu operates on
> them.
> ---
> hw/block/xen_disk.c | 185
> ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 185 insertions(+)
>
> diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
> index 3b7882e..43cd9c9 100644
> --- a/hw/block/xen_disk.c
> +++ b/hw/block/xen_disk.c
> @@ -284,6 +284,154 @@ err:
> return -1;
> }
>
> +
> +static void* get_buffer(void) {
> + void *buf;
> +
> + buf = mmap(NULL, 1 << XC_PAGE_SHIFT, PROT_READ | PROT_WRITE,
> + MAP_SHARED | MAP_ANONYMOUS, -1, 0);
Please use XC_PAGE_SIZE instead of XC_PAGE_SHIFT, it's more clear.
I would also suggest using xc_memalign instead of mmap, to make sure the
resulting buffer is page aligned. mmap makes no guarantes that the resulting
address will be page-aligned.
Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |