qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Denis V. Lunev" <den@odin.com>, Stefan Hajnoczi <stefanha@gmail.com>
Cc: Dmitry Monakhov <dmonakhov@odin.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	qemu-block@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v5 0/2] block: enforce minimal 4096 alignment in qemu_blockalign
Date: Fri, 29 May 2015 18:43:56 +0200	[thread overview]
Message-ID: <5568974C.6080502@redhat.com> (raw)
In-Reply-To: <55538001.90207@odin.com>



On 13/05/2015 18:46, Denis V. Lunev wrote:
> I agree with this. Kernel guys are aware and may be we will have
> the fix after a while... I have heard (not tested) that performance
> loss over multi-queue SSD is around 30%.

I came up with this patch... can you test it with your test case
(and old QEMU) to see if it works for you?  I don't see much
improvement, but neither do I see it with new QEMU.

Paolo

diff --git a/block/bio.c b/block/bio.c
index f66a4eae16ee..df5bde7ebded 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -705,6 +705,7 @@ static int __bio_add_page(struct request_queue *q, struct bio *bio, struct page
 {
 	int retried_segments = 0;
 	struct bio_vec *bvec;
+	int speculative_len;
 
 	/*
 	 * cloned bio must not modify vec list
@@ -712,7 +713,16 @@ static int __bio_add_page(struct request_queue *q, struct bio *bio, struct page
 	if (unlikely(bio_flagged(bio, BIO_CLONED)))
 		return 0;
 
-	if (((bio->bi_iter.bi_size + len) >> 9) > max_sectors)
+	/*
+	 * If the bio is not page-aligned, stop if we cannot fit this entire
+	 * page in the vector.  This is a very large write, so we'd like
+	 * to split it so as to keep the remaining bios aligned.
+	 */
+	speculative_len = len;
+	if (bio->bi_iter.bi_size & (PAGE_SIZE - 1) && offset == 0)
+		speculative_len = PAGE_SIZE;
+
+	if (((bio->bi_iter.bi_size + speculative_len) >> 9) > max_sectors)
 		return 0;
 
 	/*

  reply	other threads:[~2015-05-29 16:44 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-04 13:42 [Qemu-devel] [PATCH v5 0/2] block: enforce minimal 4096 alignment in qemu_blockalign Denis V. Lunev
2015-05-04 13:42 ` [Qemu-devel] [PATCH 1/2] block: minimal bounce buffer alignment Denis V. Lunev
2015-05-04 13:42 ` [Qemu-devel] [PATCH 2/2] block: align bounce buffers to page Denis V. Lunev
2015-05-11 14:54   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-05-11 15:32     ` Eric Blake
2015-05-11 15:40       ` Denis V. Lunev
2015-05-11 15:08 ` [Qemu-devel] [Qemu-block] [PATCH v5 0/2] block: enforce minimal 4096 alignment in qemu_blockalign Stefan Hajnoczi
2015-05-11 16:07   ` Denis V. Lunev
2015-05-11 16:38     ` Denis V. Lunev
2015-05-11 16:47     ` Denis V. Lunev
2015-05-12 10:01       ` Stefan Hajnoczi
2015-05-12 10:19         ` Denis V. Lunev
2015-05-12 10:46           ` Paolo Bonzini
2015-05-13 15:43             ` Stefan Hajnoczi
2015-05-13 16:46               ` Denis V. Lunev
2015-05-29 16:43                 ` Paolo Bonzini [this message]
2015-06-01 10:34                   ` [Qemu-devel] " Dmitry Monakhov
2015-06-01 10:41                     ` Paolo Bonzini
2015-06-01 11:16                       ` Dmitry Monakhov
2015-06-01 11:26                         ` Paolo Bonzini
2015-06-01 11:57                           ` Dmitry Monakhov
2015-05-14  9:13               ` [Qemu-devel] [Qemu-block] " Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5568974C.6080502@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=den@odin.com \
    --cc=dmonakhov@odin.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).