kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: "charlie.song" <charlie.song@ucloud.cn>
Cc: kvm <kvm@vger.kernel.org>
Subject: Re: AIO requests may be disordered by Qemu-kvm iothread with disk cache=writethrough, Bug or Feature?
Date: Thu, 8 Oct 2015 23:37:02 +0800	[thread overview]
Message-ID: <20151008153702.GC10388@ad.nay.redhat.com> (raw)
In-Reply-To: <dae53c1.1a208.15047527458.Coremail.charlie.song@ucloud.cn>

On Thu, 10/08 19:59, charlie.song wrote:
> Dear KVM Developers: 
>     I am Xiang Song from UCloud company. We currently encounter a weird phenomenon about Qemu-KVM IOthread. 
>     We recently try to use Linux AIO from guest OS and find that the IOthread mechanism of Qemu-KVM will reorder I/O requests from guest OS 
> even when the AIO write requests are issued from a single thread in order. This does not happen on the host OS however.
>     We are not sure whether this is a feature of Qemu-KVM IOthread mechanism or a Bug.
>  
> The testbd is as following: (the guest disk device cache is configured to writethrough.)
> CPU: Intel(R) Xeon(R) CPU E5-2650
> QEMU version: 1.5.3
> Host/Guest Kernel:  Both Linux 4.1.8 & Linux 2.6.32, OS type CentOS 6.5
> Simplified Guest OS qemu cmd:  
> /usr/libexec/qemu-kvm -machine rhel6.3.0,accel=kvm,usb=off -cpu kvm64 -smp 8,sockets=8,cores=1,threads=1 
> -drive file=/var/lib/libvirt/images/song-disk.img,if=none,id=drive-virtio-disk0,format=qcow2,serial=UCLOUD_DISK_VDA,cache=writethrough 
> -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:22:d5:52,bus=pci.0,addr=0x4

You mentioned iothread above but it's not in your command line?

> 
> The test code triggerring this phenomenon work as following: it use linux aio API to issue concurrent async write requests to a file. During exection it will 
> continuously write data into target test file. There are total 'X' jobs, and each job is assigned a job id JOB_ID which starts from 0. Each job will write 16 * 512
> Byte data into the target file at offset =  JOB_ID * 512. (the data is repeated uint64_t  JOB_ID). 
>     There is only one thread handling 'X' jobs one by one through Linux AIO (io_submit) cmd. When handling jobs, it will continuously 
> issuing AIO requests without waiting for AIO Callbacks. When it finishes, the file should look like:
>          [0....0][1...1][2...2][3...3]...[X-1...X-1]
>     Then we use a check program to test the resulting file, it can continuously read the first 8 byte (uint64_t) of each sector and print it out. In normal cases,
>  it's output is like:
>           0 1 2 3 .... X-1
> 
> Exec  output: (Set X=32)
> In our guest OS, the output is abnormal: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 18 18 18 18 18 24 25 26 27 28 29 30 31. 
>     It can be seen that job20~job24 are overwrited by job19.
> In our host OS, the output is as expected, 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31.

I'm not 100% sure but I don't think the returning of io_submit guarantees any
ordering, usually you need to wait for the callback to ensure that.

Fam

> 
> 
> I can provide the example code if needed.
> 
> Best regards, song
> 
> 2015-10-08
> 
> 
> charlie.song 
>   
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2015-10-08 15:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-08 11:59 AIO requests may be disordered by Qemu-kvm iothread with disk cache=writethrough, Bug or Feature? charlie.song
2015-10-08 15:37 ` Fam Zheng [this message]
2015-10-09  3:25   ` charlie.song
2015-10-09  4:16     ` Fam Zheng
2015-10-09  4:33       ` charlie.song
     [not found]       ` <56174390.80804@ucloud.cn>
2015-10-09  4:44         ` charlie.song
2015-10-14  9:32 ` Stefan Hajnoczi

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=20151008153702.GC10388@ad.nay.redhat.com \
    --to=famz@redhat.com \
    --cc=charlie.song@ucloud.cn \
    --cc=kvm@vger.kernel.org \
    /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).