From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URkdT-0005ux-Sz for qemu-devel@nongnu.org; Mon, 15 Apr 2013 10:44:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URkdQ-0001hS-Pg for qemu-devel@nongnu.org; Mon, 15 Apr 2013 10:43:59 -0400 Received: from smtp23.cstnet.cn ([2001:cc0:2fff:7::23]:60038 helo=cstnet.cn) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URkdP-0001eS-JA for qemu-devel@nongnu.org; Mon, 15 Apr 2013 10:43:56 -0400 Message-ID: <516C121D.40703@ict.ac.cn> Date: Mon, 15 Apr 2013 22:43:41 +0800 From: =?GB2312?B?veKx2s6w?= MIME-Version: 1.0 References: <513EF6A0.4000601@ict.ac.cn> In-Reply-To: <513EF6A0.4000601@ict.ac.cn> Content-Type: multipart/alternative; boundary="------------070401050607030702060003" Subject: [Qemu-devel] Round robin of multi-vcpu in qemu List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------070401050607030702060003 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit Hi there: I'm studying the execution details of multi-vcpu in TCG mode. The vcpus in TCG mode are executed one by one in a sequencial way. I read the function [tcg_exec_all] in Qemu 1.3.0 as bellow, but the implementation is not as I expected. [tcg_exec_all] will finally call [cpu_exec] to excute a loop to excute the TBs in code cache So,how does these functions control the running time of each VCPU? That is,when will the execution of one VCPU return, in order to execute the next_cpu in the loop of [tcg_exec_all]. I've examined the alarm timmer, this timer is used to interrupt the execution of VCPUs to handle interruptions. Does Qemu use a similar way (timer) to control the round robin of these VCPUs? Or, does Qemu use the iCount to prevent a VCPU from running too long? staticvoidtcg_exec_all(void) { intr; /* Account partial waits to the vm_clock. */ qemu_clock_warp(vm_clock); if(next_cpu==NULL){ next_cpu=first_cpu; } for(;next_cpu!=NULL&&!exit_request;next_cpu=next_cpu->next_cpu){ CPUArchState*env=next_cpu; CPUState*cpu=ENV_GET_CPU(env); qemu_clock_enable(vm_clock, (env->singlestep_enabled&SSTEP_NOTIMER)==0); if(cpu_can_run(cpu)){ r=tcg_cpu_exec(env); if(r==EXCP_DEBUG){ cpu_handle_guest_debug(env); break; } }elseif(cpu->stop||cpu->stopped){ break; } } exit_request=0; } Yours Biwei --------------070401050607030702060003 Content-Type: text/html; charset=GB2312 Content-Transfer-Encoding: 7bit Hi there:

    I'm studying the execution details of multi-vcpu in TCG mode.

    The vcpus in TCG mode are executed one by one in a sequencial way.

    I read the function [tcg_exec_all] in Qemu 1.3.0 as bellow, but the implementation is not as I expected.

    [tcg_exec_all] will finally call [cpu_exec] to excute a loop to excute the TBs in code cache

    So,how does these functions control the running time of each VCPU?
   
    That is,when will the execution of one VCPU return, in order to execute the next_cpu in the loop of [tcg_exec_all].

    I've examined the alarm timmer, this timer is used to interrupt the execution of VCPUs to handle interruptions.

    Does Qemu use a similar way (timer) to control the round robin of these VCPUs?

    Or, does Qemu use the iCount to prevent a VCPU from running too long?

static void tcg_exec_all(void)
{
    
int r;

    
/* Account partial waits to the vm_clock.  */
    
qemu_clock_warp(vm_clock);

    
if (next_cpu == NULL) {
        
next_cpu = first_cpu;
    
}
    
for (; next_cpu != NULL && !exit_request; next_cpu = next_cpu->next_cpu) {
        
CPUArchState *env = next_cpu;
        
CPUState *cpu = ENV_GET_CPU(env);

        
qemu_clock_enable(vm_clock,
                          
(env->singlestep_enabled & SSTEP_NOTIMER) == 0);

        
if (cpu_can_run(cpu)) {
            
r = tcg_cpu_exec(env);
            
if (r == EXCP_DEBUG) {
                
cpu_handle_guest_debug(env);
                
break;
            
}
        
} else if (cpu->stop || cpu->stopped) {
            
break;
        
}
    
}
    
exit_request = 0;
}

Yours
Biwei
--------------070401050607030702060003--