Received: from eggs.gnu.org ([140.186.70.92]:36933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9BSv-0004r9-OR for qemu-devel@nongnu.org; Thu, 29 Sep 2011 03:55:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R9BSt-0008S1-Ki for qemu-devel@nongnu.org; Thu, 29 Sep 2011 03:55:33 -0400 Received: from csmailer.cs.nctu.edu.tw ([140.113.235.130]:42434) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9BSs-0008RM-Gk for qemu-devel@nongnu.org; Thu, 29 Sep 2011 03:55:31 -0400 Received: from csmailer.cs.nctu.edu.tw (localhost [127.0.0.1]) by csmailer.cs.nctu.edu.tw (Postfix) with ESMTP id 4BE1D8C5 for ; Thu, 29 Sep 2011 15:54:14 +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 45A278C4 for ; Thu, 29 Sep 2011 15:54:14 +0800 (CST) Received: (from chenwj@localhost) by alumni.cs.nctu.edu.tw (8.14.4/8.14.4/Submit) id p8T7tPDx024717 for qemu-devel@nongnu.org; Thu, 29 Sep 2011 15:55:25 +0800 (CST) (envelope-from chenwj) Date: Thu, 29 Sep 2011 15:55:25 +0800 From: =?utf-8?B?6Zmz6Z+L5Lu7?= Message-ID: <20110929075525.GA23956@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] When do we need to do TB unchaining? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Hi, all I am looking for when TB unchaining is needed. Currently, I can only see there are three spots (take i386-softmmu as an example): 1. cpu_interrupt: When virtual devices raise interrupts, eventually apic_local_deliver (apic.c) will call cpu_interrupt. cpu_interrupt will set up env->interrupt_request, then call cpu_unlink_tb to unlink env's TBs. Here I have a question. I though cpu_interrupt is only used in system mode to deliever virtual devices' interrupt. But it seems process mode also has cpu_interrupt. I have ran some small programs in process mode under GDB, but I never see cpu_interrupt is called. Do I have to run something bigger to see when cpu_interrupt is called in process mode? Or cpu_interrupt in process mode is only used in some rare cases? 2. cpu_exit: QEMU will register a host SIGALRM handler, host_alarm_handler (qemu-timer.c), when initialize the enviroment in system mode. Then when host OS delivers SIGALRM to QEMU, host_alarm_handler calls qemu_notify_event -> cpu_exit. cpu_exit raise env->exit_request , then call cpu_unlink_tb to unlink env's TBs. There are other places where cpu_exit is called, like - cpu_signal: I think this is used when IOTHREAD is enabled. - DMA_init: I guess cpu_exit is called when DMA is done so that control is gave back to QEMU from the code cache. =20 - gdb_do_syscall: Don't know when it get called. - vm_stop -> cpu_stop_current: Don't know when it get called. 3. tb_phys_invalidate: QEMU will invalidate TBs related to a guest page which is done by tb_invalidate_phys_page_range (exec.c), then=20 tb_invalidate_phys_page_range calls tb_phys_invalidate to invalidate a TB and unlink links to the TB. Please correct me if I am wrong or something miss. Thanks!=20 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