Received: from eggs.gnu.org ([140.186.70.92]:56033) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RVHjO-00014y-U2 for qemu-devel@nongnu.org; Tue, 29 Nov 2011 02:03:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RVHjN-0002TY-4Q for qemu-devel@nongnu.org; Tue, 29 Nov 2011 02:03:54 -0500 Received: from csmailer.cs.nctu.edu.tw ([140.113.235.130]:63980) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RVHjK-0002SK-7l for qemu-devel@nongnu.org; Tue, 29 Nov 2011 02:03:52 -0500 Received: from csmailer.cs.nctu.edu.tw (localhost [127.0.0.1]) by csmailer.cs.nctu.edu.tw (Postfix) with ESMTP id 221F09B2 for ; Tue, 29 Nov 2011 15:01:35 +0800 (CST) Received: from alumni.cs.nctu.edu.tw (alumni.cs.nctu.edu.tw [140.113.235.116]) by csmailer.cs.nctu.edu.tw (Postfix) with ESMTP id 044409B1 for ; Tue, 29 Nov 2011 15:01:35 +0800 (CST) Received: (from chenwj@localhost) by alumni.cs.nctu.edu.tw (8.14.4/8.14.4/Submit) id pAT73hak030309 for qemu-devel@nongnu.org; Tue, 29 Nov 2011 15:03:43 +0800 (CST) (envelope-from chenwj) Date: Tue, 29 Nov 2011 15:03:43 +0800 From: =?utf-8?B?6Zmz6Z+L5Lu7?= Message-ID: <20111129070343.GA3585@cs.nctu.edu.tw> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] Improve QEMU performance with LLVM codegen and other techniques List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Hi all, Our team are working on a project similar to llvm-qemu [1], which is al= so based on QEMU and LLVM. Current status is the process mode works fine [2]= , and we're moving forward to system mode. Let me briefly introduce our framework here and state what problem we enc= ounter. What we do is translating TCG IR into LLVM IR and let LLVM JIT do the cod= egen. In our framework, we have both TCG and LLVM codegen capacity. For short-r= unning application, TCG's code quality is good enough; LLVM codegen is for long-= running application on the other hand. We have two code cache in our framework, o= ne is the original QEMU code cache (for basic block) and the other is LLVM code= cache (for trace). The concept of trace is the same as the "super-blocks" as me= ntioned in the discussion thread [3], which is composed of a set of basic blocks.= The goal is to enlarge the optimization scope and hope the code quality of tr= ace is=20 better than the basic block's. Here is the overview of our framework. QEMU code cache LLVM code cache (block) (trace) bb1 ------------> trace1 =20 In our framework, if we find a basic block (bb1) is hot enough (i.e., bei= ng executed many times), we start building a trace (beginning with bb1) and = let LLVM do the codegen. We place the optimized code in the LLVM code cache, = and patch the head of bb1 so that anyone executing bb1 will jump to trace1 di= rectly. Since we're moving toward system mode, we have to consider situations whe= re unlinking is needed. Block linking done by QEMU itself and we leave block unlinking to it. The problem is when/where to break the link between bloc= k and trace. I can only spot two places we should break the block -> trace link= so far [4]. I don't know if I spot them all or I miss something else. 1. cpu_unlink_tb (exec.c) 2. tb_phys_invalidate (exec.c) The big problem is debugging. We test our system by using images download= ed from the website [5]. Basically, we want to see an operating system being boot= ed successfully, then login and run some benchmark on it. As a very first st= ep, we make a very high threshold on trace building. In other words, a basic blo= ck must be executed *many* time to trigger the trace building process. Then we lo= wer the threshold a bit at a time to see how things work. When something goes wro= ng, we might get kernel panic or the system hangs at some point on the booting p= rocess. I have no idea on how to solve this kind of problem. So I'd like to seek = for help/experience/suggestion on the mailing list. I just hope I make the wh= ole situation clear to you.=20 Thanks! [1] http://code.google.com/p/llvm-qemu/ [2] I have to admit we only test our framework with SPEC2006 benchmark, not with _real_ applications. [3] http://lists.cs.uiuc.edu/pipermail/llvmdev/2008-April/013689.html [4] http://lists.gnu.org/archive/html/qemu-devel/2011-09/msg03643.html [5] http://wiki.qemu.org/Download 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