Received: from eggs.gnu.org ([2001:4830:134:3::10]:38175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7Gsa-0006yn-6W for qemu-devel@nongnu.org; Mon, 30 May 2016 02:40:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b7GsW-0004jh-0c for qemu-devel@nongnu.org; Mon, 30 May 2016 02:40:47 -0400 Received: from mailpro.odiso.net ([89.248.211.110]:53279) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7GsV-0004jU-LB for qemu-devel@nongnu.org; Mon, 30 May 2016 02:40:43 -0400 Date: Mon, 30 May 2016 08:40:39 +0200 (CEST) From: Alexandre DERUMIER Message-ID: <1786478881.754331933.1464590439361.JavaMail.zimbra@oxygem.tv> In-Reply-To: <20160527222710.GS27946@stefanha-x1.localdomain> References: <1463787632-7241-1-git-send-email-stefanha@redhat.com> <1464350104-24825-1-git-send-email-roman.penyaev@profitbricks.com> <20160527222710.GS27946@stefanha-x1.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC] virtio-blk: simple multithreaded MQ implementation for bdrv_raw List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Roman Pen , qemu-devel , stefanha Hi, >>To avoid any locks in qemu backend and not to introduce thread safety >>into qemu block-layer I open same backend device several times, one >>device per one MQ. e.g. the following is the stack for a virtio-blk >>with num-queues=3D2: Could it be possible in the future to not open several times the same backe= nd ? I'm thinking about ceph/librbd, which since last version allow only to open= once a backend by default (exclusive-lock, which is a requirement for advanced features like rbd-mirr= oring, fast-diff,....) Regards, Alexandre Derumier ----- Mail original ----- De: "Stefan Hajnoczi" =C3=80: "Roman Pen" Cc: "qemu-devel" , "stefanha" Envoy=C3=A9: Samedi 28 Mai 2016 00:27:10 Objet: Re: [Qemu-devel] [RFC] virtio-blk: simple multithreaded MQ implement= ation for bdrv_raw On Fri, May 27, 2016 at 01:55:04PM +0200, Roman Pen wrote:=20 > Hello, all.=20 >=20 > This is RFC because mostly this patch is a quick attempt to get true=20 > multithreaded multiqueue support for a block device with native AIO.=20 > The goal is to squeeze everything possible on lockless IO path from=20 > MQ block on a guest to MQ block on a host.=20 >=20 > To avoid any locks in qemu backend and not to introduce thread safety=20 > into qemu block-layer I open same backend device several times, one=20 > device per one MQ. e.g. the following is the stack for a virtio-blk=20 > with num-queues=3D2:=20 >=20 > VirtIOBlock=20 > / \=20 > VirtQueue#0 VirtQueue#1=20 > IOThread#0 IOThread#1=20 > BH#0 BH#1=20 > Backend#0 Backend#1=20 > \ /=20 > /dev/null0=20 >=20 > To group all objects related to one vq new structure is introduced:=20 >=20 > typedef struct VirtQueueCtx {=20 > BlockBackend *blk;=20 > struct VirtIOBlock *s;=20 > VirtQueue *vq;=20 > void *rq;=20 > QEMUBH *bh;=20 > QEMUBH *batch_notify_bh;=20 > IOThread *iothread;=20 > Notifier insert_notifier;=20 > Notifier remove_notifier;=20 > /* Operation blocker on BDS */=20 > Error *blocker;=20 > } VirtQueueCtx;=20 >=20 > And VirtIOBlock includes an array of these contexts:=20 >=20 > typedef struct VirtIOBlock {=20 > VirtIODevice parent_obj;=20 > + VirtQueueCtx mq[VIRTIO_QUEUE_MAX];=20 > ...=20 >=20 > This patch is based on Stefan's series: "virtio-blk: multiqueue support",= =20 > with minor difference: I reverted "virtio-blk: multiqueue batch notify",= =20 > which does not make a lot sense when each VQ is handled by it's own=20 > iothread.=20 >=20 > The qemu configuration stays the same, i.e. put num-queues=3DN and N=20 > iothreads will be started on demand and N drives will be opened:=20 >=20 > qemu -device virtio-blk-pci,num-queues=3D8=20 >=20 > My configuration is the following:=20 >=20 > host:=20 > Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz,=20 > 8 CPUs,=20 > /dev/nullb0 as backend with the following parameters:=20 > $ cat /sys/module/null_blk/parameters/submit_queues=20 > 8=20 > $ cat /sys/module/null_blk/parameters/irqmode=20 > 1=20 >=20 > guest:=20 > 8 VCPUs=20 >=20 > qemu:=20 > -object iothread,id=3Dt0 \=20 > -drive if=3Dnone,id=3Dd0,file=3D/dev/nullb0,format=3Draw,snapshot=3Doff,c= ache=3Dnone,aio=3Dnative \=20 > -device virtio-blk-pci,num-queues=3D$N,iothread=3Dt0,drive=3Dd0,disable-m= odern=3Doff,disable-legacy=3Don=20 >=20 > where $N varies during the tests.=20 >=20 > fio:=20 > [global]=20 > description=3DEmulation of Storage Server Access Pattern=20 > bssplit=3D512/20:1k/16:2k/9:4k/12:8k/19:16k/10:32k/8:64k/4=20 > fadvise_hint=3D0=20 > rw=3Drandrw:2=20 > direct=3D1=20 >=20 > ioengine=3Dlibaio=20 > iodepth=3D64=20 > iodepth_batch_submit=3D64=20 > iodepth_batch_complete=3D64=20 > numjobs=3D8=20 > gtod_reduce=3D1=20 > group_reporting=3D1=20 >=20 > time_based=3D1=20 > runtime=3D30=20 >=20 > [job]=20 > filename=3D/dev/vda=20 >=20 > Results:=20 > num-queues RD bw WR bw=20 > ---------- ----- -----=20 >=20 > * with 1 iothread *=20 >=20 > 1 thr 1 mq 1225MB/s 1221MB/s=20 > 1 thr 2 mq 1559MB/s 1553MB/s=20 > 1 thr 4 mq 1729MB/s 1725MB/s=20 > 1 thr 8 mq 1660MB/s 1655MB/s=20 >=20 > * with N iothreads *=20 >=20 > 2 thr 2 mq 1845MB/s 1842MB/s=20 > 4 thr 4 mq 2187MB/s 2183MB/s=20 > 8 thr 8 mq 1383MB/s 1378MB/s=20 >=20 > Obviously, 8 iothreads + 8 vcpu threads is too much for my machine=20 > with 8 CPUs, but 4 iothreads show quite good result.=20 Cool, thanks for trying this experiment and posting results.=20 It's encouraging to see the improvement. Did you use any CPU affinity=20 settings to co-locate vcpu and iothreads onto host CPUs?=20 Stefan=20