Received: from eggs.gnu.org ([208.118.235.92]:56447) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sf0aB-0001is-GM for qemu-devel@nongnu.org; Wed, 13 Jun 2012 23:18:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sf0a8-0006Gy-9p for qemu-devel@nongnu.org; Wed, 13 Jun 2012 23:18:51 -0400 Received: from csmailer.cs.nctu.edu.tw ([140.113.235.130]:54340) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sf0a7-0006Fr-E1 for qemu-devel@nongnu.org; Wed, 13 Jun 2012 23:18:48 -0400 Date: Thu, 14 Jun 2012 11:18:26 +0800 From: =?utf-8?B?6Zmz6Z+L5Lu7IChXZWktUmVuIENoZW4p?= Message-ID: <20120614031826.GA88265@cs.nctu.edu.tw> References: <20120613031426.GA8174@cs.nctu.edu.tw> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] How to measure guest memory access (qemu_ld/qemu_st) time? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: laurent.desnogues@gmail.com Cc: stefanha@gmail.com, qemu-devel@nongnu.org, =?utf-8?B?6Zmz6Z+L5Lu7IChXZWktUmVuIENoZW4p?= , vilanova@ac.upc.edu On Wed, Jun 13, 2012 at 12:43:28PM +0200, Laurent Desnogues wrote: > On Wed, Jun 13, 2012 at 5:14 AM, =E9=99=B3=E9=9F=8B=E4=BB=BB (Wei-Ren C= hen) > wrote: > > Hi all, > > > > =C2=A0I suspect that guest memory access (qemu_ld/qemu_st) account fo= r the major of > > time spent in system mode. I would like to know precisely how much (i= f possible). > > We use tools like perf [1] before, but since the logic of guest memor= y access aslo > > embedded in the host binary not only helper functions, the result can= not be > > relied. The current idea is adding helper functions before/after gues= t memory > > access logic. Take ARM guest on x86_64 host for example, should I add= the helper > > functions before/after tcg_gen_qemu_{ld,st} in target-arm/translate.c= or > > tcg_out_qemu_{ld,st} in tcg/i386/tcg-target.c? Or there is a better w= ay to know > > how much time QEMU spend on handling guest memory access? >=20 > I'm afraid there's no easy way to measure that: any change you make > to generated code will completely change the timing given that the ld/s= t > fast path is only a few instructions long. Lluis, how's your opinion on that? Does your tracepoints have the same = timing issue, too? > Another approach might be to run the program in user mode and then > in system mode (provided the guest OS is very light). We ran SPEC2006 test input both in user and system mode (arm guest os).= The result is that system mode is roughly 2x slower than user mode. Not sure = if the result is reasonable.=20 =20 > As a side note, it might be interesting to gather statistics about the = hit > rate of the QEMU TLB. Another thing to consider is speeding up the > fast path; see YeongKyoon Lee RFC patch: >=20 > http://www.mail-archive.com/qemu-devel@nongnu.org/msg91294.html We have some result on TLB hit rate on the link below, https://docs.google.com/spreadsheet/ccc?key=3D0Aq_07U3IjpY8dFN6dTczMldt= QVRUSk9Qa2ZKZTZEZGc&pli=3D1#gid=3D0 Here is how we get the TLB hit rate. We use tcg_out_xxx to insert countin= g code in the tcg_out_tlb_load (tcg/i386/tcg-target.c). At the beginning of tcg_= out_tlb_load, we count the total guest memory access, and count the tlb hit number at t= he TLB hit flow. You can see the code at https://github.com/ZackClown/QEMU_1.0.1/commit/013a9f8e2611e25344bc095a= 9f72fdfbb0c64d06#diff-3 =20 The reason why we want to do the measuring is we want to use KVM (sound= s crazy idea) MMU virtualization to speedup the guest -> host memory address tran= slation. I talked to some people on LinuxCon Japan, included Paolo, about this ide= a. The feedback I got is we can only use shadow page table rather than EPT/NPT t= o do the address translation (if possible!) since different ISA (ARM and x86, = for example) have different page table format. Besides, QEMU has to use ioctl= to ask KVM to get the translation result, but it's an overkill as the ARM page t= able is quite simple, which can be done in user mode very fast. Any comment is welcomed. Regards, chenwj --=20 Wei-Ren Chen (=E9=99=B3=E9=9F=8B=E4=BB=BB) Computer Systems Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667 Homepage: http://people.cs.nctu.edu.tw/~chenwj