Received: from eggs.gnu.org ([2001:4830:134:3::10]:60514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsmOR-0000X3-8y for qemu-devel@nongnu.org; Sat, 08 Oct 2016 03:50:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bsmOM-0006cZ-UA for qemu-devel@nongnu.org; Sat, 08 Oct 2016 03:50:02 -0400 Received: from [202.114.0.240] (port=24626 helo=mail.hust.edu.cn) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsmOL-0006Ru-Fz for qemu-devel@nongnu.org; Sat, 08 Oct 2016 03:49:58 -0400 Date: Sat, 8 Oct 2016 15:55:58 +0800 (GMT+08:00) From: "Chunguang Li" Message-ID: <1401177.991b.157a34a9dea.Coremail.lichunguang@hust.edu.cn> In-Reply-To: <20160930054610.GA1429@amit-lp.rh> References: <5feb15.7e53.1576070ae2d.Coremail.lichunguang@hust.edu.cn> <20160926112349.GF2029@work-vm> <13289d.86da.15766fdf27c.Coremail.lichunguang@hust.edu.cn> <20160930054610.GA1429@amit-lp.rh> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] Migration dirty bitmap: should only mark pages as dirty after they have been sent List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amit Shah Cc: "Dr. David Alan Gilbert" , qemu-devel@nongnu.org, pbonzini@redhat.com, stefanha@redhat.com, quintela@redhat.com > -----=E5=8E=9F=E5=A7=8B=E9=82=AE=E4=BB=B6----- > =E5=8F=91=E4=BB=B6=E4=BA=BA: "Amit Shah" > =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2016=E5=B9=B49=E6=9C=8830=E6=97=A5 = =E6=98=9F=E6=9C=9F=E4=BA=94 > =E6=94=B6=E4=BB=B6=E4=BA=BA: "Chunguang Li" > =E6=8A=84=E9=80=81: "Dr. David Alan Gilbert" , qemu-= devel@nongnu.org, pbonzini@redhat.com, stefanha@redhat.com, quintela@redhat= .com > =E4=B8=BB=E9=A2=98: Re: Re: [Qemu-devel] Migration dirty bitmap: should o= nly mark pages as dirty after they have been sent >=20 > On (Mon) 26 Sep 2016 [22:55:01], Chunguang Li wrote: > >=20 > >=20 > >=20 > > > -----=E5=8E=9F=E5=A7=8B=E9=82=AE=E4=BB=B6----- > > > =E5=8F=91=E4=BB=B6=E4=BA=BA: "Dr. David Alan Gilbert" > > > =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2016=E5=B9=B49=E6=9C=8826=E6=97= =A5 =E6=98=9F=E6=9C=9F=E4=B8=80 > > > =E6=94=B6=E4=BB=B6=E4=BA=BA: "Chunguang Li" > > > =E6=8A=84=E9=80=81: qemu-devel@nongnu.org, amit.shah@redhat.com, pbon= zini@redhat.com, stefanha@redhat.com, quintela@redhat.com > > > =E4=B8=BB=E9=A2=98: Re: [Qemu-devel] Migration dirty bitmap: should o= nly mark pages as dirty after they have been sent > > >=20 > > > * Chunguang Li (lichunguang@hust.edu.cn) wrote: > > > > Hi all! > > > > I have some confusion about the dirty bitmap during migration. I ha= ve digged into the code. I figure out that every now and then during migrat= ion, the dirty bitmap will be grabbed from the kernel space through ioctl(K= VM_GET_DIRTY_LOG), and then be used to update qemu's dirty bitmap. However = I think this mechanism leads to resendness of some NON-dirty pages. > > > >=20 > > > > Take the first iteration of precopy for instance, during which all = the pages will be sent. Before that during the migration setup, the ioctl(K= VM_GET_DIRTY_LOG) is called once, so the kernel begins to produce the dirty= bitmap from this moment. When the pages "that haven't been sent" are writt= en, the kernel space marks them as dirty. However I don't think this is cor= rect, because these pages will be sent during this and the next iterations = with the same content (if they are not written again after they are sent). = It only makes sense to mark the pages which have already been sent during o= ne iteration as dirty when they are written. > > > >=20 > > > >=20 > > > > Am I right about this consideration? If I am right, is there some a= dvice to improve this? > > >=20 > > > I think you're right that this can happen; to clarify I think the > > > case you're talking about is: > > >=20 > > > Iteration 1 > > > sync bitmap > > > start sending pages > > > page 'n' is modified - but hasn't been sent yet > > > page 'n' gets sent > > > Iteration 2 > > > sync bitmap > > > 'page n is shown as modified' > > > send page 'n' again > > > > >=20 > > Yes=EF=BC=8Cthis is right the case I am talking about. > > =20 > > > So you're right that is wasteful; I guess it's more wasteful > > > on big VMs with slow networks where the length of each iteration > > > is large. > >=20 > > I think this is "very" wasteful. Assume the workload writes the pages d= irty randomly within the guest address space, and the transfer speed is con= stant. Intuitively, I think nearly half of the dirty pages produced in Iter= ation 1 is not really dirty. This means the time of Iteration 2 is double o= f that to send only really dirty pages. >=20 > It makes sense, can you get some perf numbers to show what kinds of > workloads get impacted the most? That would also help us to figure > out what kinds of speed improvements we can expect. >=20 >=20 > =09=09Amit I have picked up 6 workloads and got the following statistics numbers=20 of every iteration (except the last stop-copy one) during precopy. These numbers are obtained with the basic precopy migration, without=20 the capabilities like xbzrle or compression, etc. The network for the=20 migration is exclusive, with a separate network for the workloads.=20 They are both gigabit ethernet. I use qemu-2.5.1. Three (booting, idle, web server) of them converged to the stop-copy phase,= =20 with the given bandwidth and default downtime (300ms), while the other three (kernel compilation, zeusmp, memcached) did not. One page is "not-really-dirty", if it is written first and is sent later (and not written again after that) during one iteration. I guess this=20 would not happen so often during the other iterations as during the 1st=20 iteration. Because all the pages of the VM are sent to the dest node during= =20 the 1st iteration, while during the others, only part of the pages are sent= .=20 So I think the "not-really-dirty" pages should be produced mainly during=20 the 1st iteration , and maybe very little during the other iterations. If we could avoid resending the "not-really-dirty" pages, intuitively, I think the time spent on Iteration 2 would be halved. This is a chain reacti= on, because the dirty pages produced during Iteration 2 is halved, which incurs that the time spent on Iteration 3 is halved, then Iteration 4, 5... So I think "booting" and "kernel compilation" should benefit a lot from th= is improvement. The reason of "kernel compilation" would benefit is that some= =20 iterations take around 600ms, and if they are halved into 300ms, then the p= recopy may have the chance to step into stop and copy phase. On the other hand, "idle" and "web server" would not benefit a lot, because most of the time are spent on the 1st iteration and little on the others. As to the "zeusmp" and "memcached", although the time spent on the other it= erations but the 1st one may be halved, they still could not converge to stop and co= py=20 with the 300ms downtime. --------------------1 vcpu, 1 GB ram, default bandwidth (32MB/s):----------= -------- 1. booting : begin to migrate when the VM is booting Iteration 1, duration: 6997 ms , transferred pages: 266450 (n: 572= 69, d: 209181 ) , new dirty pages: 56414 , remaining dirty pages: 5= 6414 Iteration 2, duration: 6497 ms , transferred pages: 54008 (n: 527= 01, d: 1307 ) , new dirty pages: 48053 , remaining dirty pages: 5= 0459 Iteration 3, duration: 5800 ms , transferred pages: 48232 (n: 474= 44, d: 788 ) , new dirty pages: 9129 , remaining dirty pages: 1= 1356 Iteration 4, duration: 1100 ms , transferred pages: 9091 (n: 89= 98, d: 93 ) , new dirty pages: 165 , remaining dirty pages: = 2430 Iteration 5, duration: 1 ms , transferred pages: 0 (n: = 0, d: 0 ) , new dirty pages: 0 , remaining dirty pages: = 2430 (note: When the workload does converge, the output of the last iteration is= "fake". It just indicates that the precopy steps into stop-copy phase now. "n" means "normal pages" and "d" means "duplicate (zero) pages".) 2. idle Iteration 1, duration: 14496 ms , transferred pages: 266450 (n: 1189= 80, d: 147470 ) , new dirty pages: 17398 , remaining dirty pages: 1= 7398 Iteration 2, duration: 1896 ms , transferred pages: 14953 (n: 148= 54, d: 99 ) , new dirty pages: 1849 , remaining dirty pages: = 4294 Iteration 3, duration: 300 ms , transferred pages: 2454 (n: 24= 54, d: 0 ) , new dirty pages: 9 , remaining dirty pages: = 1849 Iteration 4, duration: 1 ms , transferred pages: 0 (n: = 0, d: 0 ) , new dirty pages: 0 , remaining dirty pages: = 1849 3. kernel compilation (can not converge) Iteration 1, duration: 20700 ms , transferred pages: 266450 (n: 1697= 78, d: 96672 ) , new dirty pages: 40067 , remaining dirty pages: 4= 0067 Iteration 2, duration: 4696 ms , transferred pages: 38401 (n: 377= 87, d: 614 ) , new dirty pages: 8852 , remaining dirty pages: 1= 0518 Iteration 3, duration: 1000 ms , transferred pages: 8642 (n: 81= 80, d: 462 ) , new dirty pages: 6331 , remaining dirty pages: = 8207 Iteration 4, duration: 700 ms , transferred pages: 6110 (n: 57= 26, d: 384 ) , new dirty pages: 5242 , remaining dirty pages: = 7339 Iteration 5, duration: 600 ms , transferred pages: 5007 (n: 49= 08, d: 99 ) , new dirty pages: 4868 , remaining dirty pages: = 7200 Iteration 6, duration: 600 ms , transferred pages: 5226 (n: 49= 08, d: 318 ) , new dirty pages: 6142 , remaining dirty pages: = 8116 Iteration 7, duration: 700 ms , transferred pages: 5985 (n: 57= 26, d: 259 ) , new dirty pages: 5902 , remaining dirty pages: = 8033 Iteration 8, duration: 701 ms , transferred pages: 5893 (n: 57= 26, d: 167 ) , new dirty pages: 7502 , remaining dirty pages: = 9642 Iteration 9, duration: 900 ms , transferred pages: 7623 (n: 73= 62, d: 261 ) , new dirty pages: 6408 , remaining dirty pages: = 8427 Iteration 10, duration: 700 ms , transferred pages: 6008 (n: 57= 26, d: 282 ) , new dirty pages: 8312 , remaining dirty pages: 1= 0731 Iteration 11, duration: 1000 ms , transferred pages: 8353 (n: 81= 80, d: 173 ) , new dirty pages: 6874 , remaining dirty pages: = 9252 Iteration 12, duration: 899 ms , transferred pages: 7477 (n: 73= 62, d: 115 ) , new dirty pages: 5573 , remaining dirty pages: = 7348 Iteration 13, duration: 601 ms , transferred pages: 5099 (n: 49= 08, d: 191 ) , new dirty pages: 7671 , remaining dirty pages: = 9920 Iteration 14, duration: 900 ms , transferred pages: 7586 (n: 73= 62, d: 224 ) , new dirty pages: 7359 , remaining dirty pages: = 9693 Iteration 15, duration: 900 ms , transferred pages: 7682 (n: 73= 62, d: 320 ) , new dirty pages: 7371 , remaining dirty pages: = 9382 4. cpu2006.zeusmp (can not converge) Iteration 1, duration: 21603 ms , transferred pages: 266450 (n: 1766= 60, d: 89790 ) , new dirty pages: 145625 , remaining dirty pages: 14= 5625 Iteration 2, duration: 8696 ms , transferred pages: 144389 (n: 708= 62, d: 73527 ) , new dirty pages: 125124 , remaining dirty pages: 12= 6360 Iteration 3, duration: 6301 ms , transferred pages: 124057 (n: 513= 79, d: 72678 ) , new dirty pages: 122528 , remaining dirty pages: 12= 4831 Iteration 4, duration: 6400 ms , transferred pages: 124330 (n: 521= 96, d: 72134 ) , new dirty pages: 124267 , remaining dirty pages: 12= 4768 Iteration 5, duration: 6703 ms , transferred pages: 124034 (n: 546= 56, d: 69378 ) , new dirty pages: 124151 , remaining dirty pages: 12= 4885 Iteration 6, duration: 6703 ms , transferred pages: 124357 (n: 546= 58, d: 69699 ) , new dirty pages: 124106 , remaining dirty pages: 12= 4634 Iteration 7, duration: 6602 ms , transferred pages: 124568 (n: 538= 38, d: 70730 ) , new dirty pages: 133828 , remaining dirty pages: 13= 3894 Iteration 8, duration: 7600 ms , transferred pages: 133030 (n: 620= 21, d: 71009 ) , new dirty pages: 126612 , remaining dirty pages: 12= 7476 Iteration 9, duration: 7299 ms , transferred pages: 126511 (n: 595= 69, d: 66942 ) , new dirty pages: 122727 , remaining dirty pages: 12= 3692 Iteration 10, duration: 6609 ms , transferred pages: 123692 (n: 545= 39, d: 69153 ) , new dirty pages: 122727 , remaining dirty pages: 12= 2727 Iteration 11, duration: 6995 ms , transferred pages: 120347 (n: 564= 23, d: 63924 ) , new dirty pages: 121430 , remaining dirty pages: 12= 3810 Iteration 12, duration: 6703 ms , transferred pages: 123040 (n: 546= 57, d: 68383 ) , new dirty pages: 122043 , remaining dirty pages: 12= 2813 Iteration 13, duration: 7006 ms , transferred pages: 122353 (n: 571= 21, d: 65232 ) , new dirty pages: 133869 , remaining dirty pages: 13= 4329 Iteration 14, duration: 8209 ms , transferred pages: 132325 (n: 669= 32, d: 65393 ) , new dirty pages: 126914 , remaining dirty pages: 12= 8918 Iteration 15, duration: 7802 ms , transferred pages: 126931 (n: 636= 71, d: 63260 ) , new dirty pages: 122351 , remaining dirty pages: 12= 4338 5. web server : An apache web server. The client is configured with 50 conc= urrent connections. Iteration 1, duration: 30697 ms , transferred pages: 266450 (n: 2512= 15, d: 15235 ) , new dirty pages: 30628 , remaining dirty pages: 3= 0628 Iteration 2, duration: 3496 ms , transferred pages: 28859 (n: 285= 13, d: 346 ) , new dirty pages: 5805 , remaining dirty pages: = 7574 Iteration 3, duration: 701 ms , transferred pages: 5746 (n: 57= 26, d: 20 ) , new dirty pages: 3433 , remaining dirty pages: = 5261 Iteration 4, duration: 400 ms , transferred pages: 3281 (n: 32= 72, d: 9 ) , new dirty pages: 1539 , remaining dirty pages: = 3519 Iteration 5, duration: 199 ms , transferred pages: 1653 (n: 16= 36, d: 17 ) , new dirty pages: 301 , remaining dirty pages: = 2167 Iteration 6, duration: 1 ms , transferred pages: 0 (n: = 0, d: 0 ) , new dirty pages: 0 , remaining dirty pages: = 2167 --------------------6 vcpu, 6 GB ram, max bandwidth (941.08 mbps):---------= --------- 6. memcached : 4 GB cache, memaslap: all write, concurrency =3D 5 (can not= converge) Iteration 1, duration: 42486 ms , transferred pages: 1568087 (n: 12160= 79, d: 352008 ) , new dirty pages: 571940 , remaining dirty pages: 58= 1023 Iteration 2, duration: 19774 ms , transferred pages: 571700 (n: 5674= 16, d: 4284 ) , new dirty pages: 331690 , remaining dirty pages: 34= 1013 Iteration 3, duration: 11589 ms , transferred pages: 332187 (n: 3320= 95, d: 92 ) , new dirty pages: 222725 , remaining dirty pages: 23= 1551 Iteration 4, duration: 7790 ms , transferred pages: 223571 (n: 2234= 99, d: 72 ) , new dirty pages: 157658 , remaining dirty pages: 16= 5638 Iteration 5, duration: 5518 ms , transferred pages: 158056 (n: 1579= 98, d: 58 ) , new dirty pages: 128130 , remaining dirty pages: 13= 5712 Iteration 6, duration: 4442 ms , transferred pages: 127764 (n: 1277= 01, d: 63 ) , new dirty pages: 104839 , remaining dirty pages: 11= 2787 Iteration 7, duration: 3649 ms , transferred pages: 104581 (n: 1045= 23, d: 58 ) , new dirty pages: 100736 , remaining dirty pages: 10= 8942 Iteration 8, duration: 3532 ms , transferred pages: 101379 (n: 1013= 15, d: 64 ) , new dirty pages: 87869 , remaining dirty pages: 9= 5432 Iteration 9, duration: 3030 ms , transferred pages: 86841 (n: 867= 86, d: 55 ) , new dirty pages: 77505 , remaining dirty pages: 8= 6096 Iteration 10, duration: 2709 ms , transferred pages: 77875 (n: 778= 14, d: 61 ) , new dirty pages: 77197 , remaining dirty pages: 8= 5418 Iteration 11, duration: 2696 ms , transferred pages: 77107 (n: 770= 44, d: 63 ) , new dirty pages: 65010 , remaining dirty pages: 7= 3321 Iteration 12, duration: 2308 ms , transferred pages: 66540 (n: 664= 84, d: 56 ) , new dirty pages: 64388 , remaining dirty pages: 7= 1169 Iteration 13, duration: 2198 ms , transferred pages: 62953 (n: 628= 97, d: 56 ) , new dirty pages: 62773 , remaining dirty pages: 7= 0989 Iteration 14, duration: 2214 ms , transferred pages: 63466 (n: 634= 11, d: 55 ) , new dirty pages: 67538 , remaining dirty pages: 7= 5061 Iteration 15, duration: 2329 ms , transferred pages: 66924 (n: 668= 75, d: 49 ) , new dirty pages: 63580 , remaining dirty pages: 7= 1717 Iteration 16, duration: 2252 ms , transferred pages: 64554 (n: 645= 39, d: 15 ) , new dirty pages: 63094 , remaining dirty pages: 7= 0257 Iteration 17, duration: 2188 ms , transferred pages: 62697 (n: 626= 41, d: 56 ) , new dirty pages: 63016 , remaining dirty pages: 7= 0576 Iteration 18, duration: 2171 ms , transferred pages: 62377 (n: 623= 22, d: 55 ) , new dirty pages: 56764 , remaining dirty pages: 6= 4963 Iteration 19, duration: 2003 ms , transferred pages: 57382 (n: 573= 24, d: 58 ) , new dirty pages: 65307 , remaining dirty pages: 7= 2888 Iteration 20, duration: 2240 ms , transferred pages: 64426 (n: 643= 64, d: 62 ) , new dirty pages: 61585 , remaining dirty pages: 7= 0047 -- Chunguang Li, Ph.D. Candidate Wuhan National Laboratory for Optoelectronics (WNLO) Huazhong University of Science & Technology (HUST) Wuhan, Hubei Prov., China