From 4196d2f0308cb1ae13ed450424ab7dfe154acda9 Mon Sep 17 00:00:00 2001 From: "Denis V. Lunev" Date: Tue, 12 May 2015 17:30:55 +0300 Subject: block: minimal bounce buffer alignment The patch introduces new concept: minimal memory alignment for bounce buffers. Original so called "optimal" value is actually minimal required value for aligment. It should be used for validation that the IOVec is properly aligned and bounce buffer is not required. Though, from the performance point of view, it would be better if bounce buffer or IOVec allocated by QEMU will be aligned stricter. The patch does not change any alignment value yet. Signed-off-by: Denis V. Lunev Reviewed-by: Kevin Wolf Message-id: 1431441056-26198-2-git-send-email-den@openvz.org CC: Paolo Bonzini Reviewed-by: Kevin Wolf CC: Stefan Hajnoczi Signed-off-by: Stefan Hajnoczi --- block/io.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'block/io.c') diff --git a/block/io.c b/block/io.c index a05ad67..e6c3639 100644 --- a/block/io.c +++ b/block/io.c @@ -201,8 +201,10 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp) } bs->bl.opt_transfer_length = bs->file->bl.opt_transfer_length; bs->bl.max_transfer_length = bs->file->bl.max_transfer_length; + bs->bl.min_mem_alignment = bs->file->bl.min_mem_alignment; bs->bl.opt_mem_alignment = bs->file->bl.opt_mem_alignment; } else { + bs->bl.min_mem_alignment = 512; bs->bl.opt_mem_alignment = 512; } @@ -221,6 +223,9 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp) bs->bl.opt_mem_alignment = MAX(bs->bl.opt_mem_alignment, bs->backing_hd->bl.opt_mem_alignment); + bs->bl.min_mem_alignment = + MAX(bs->bl.min_mem_alignment, + bs->backing_hd->bl.min_mem_alignment); } /* Then let the driver override it */ @@ -2489,7 +2494,7 @@ void *qemu_try_blockalign0(BlockDriverState *bs, size_t size) bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov) { int i; - size_t alignment = bdrv_opt_mem_align(bs); + size_t alignment = bdrv_min_mem_align(bs); for (i = 0; i < qiov->niov; i++) { if ((uintptr_t) qiov->iov[i].iov_base % alignment) { -- cgit v1.1