From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIZvp-0004qh-C2 for qemu-devel@nongnu.org; Tue, 03 Feb 2015 04:38:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YIZvl-0005LL-4T for qemu-devel@nongnu.org; Tue, 03 Feb 2015 04:38:05 -0500 Received: from greensocs.com ([193.104.36.180]:57821) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIZvk-0005L9-Ob for qemu-devel@nongnu.org; Tue, 03 Feb 2015 04:38:01 -0500 Message-ID: <54D096F4.9030604@greensocs.com> Date: Tue, 03 Feb 2015 10:37:56 +0100 From: Frederic Konrad MIME-Version: 1.0 References: <1421428797-23697-1-git-send-email-fred.konrad@greensocs.com> <1421428797-23697-10-git-send-email-fred.konrad@greensocs.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC 09/10] cpu: remove exit_request global. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: mttcg@listserver.greensocs.com, "J. Kiszka" , Mark Burton , QEMU Developers , Alexander Graf , Paolo Bonzini On 29/01/2015 16:52, Peter Maydell wrote: > On 16 January 2015 at 17:19, wrote: >> From: KONRAD Frederic >> >> This removes exit_request global and adds a variable in CPUState for this. >> Only the flag for the first cpu is used for the moment as we are still with one >> TCG thread. >> --- a/cpus.c >> +++ b/cpus.c >> @@ -646,10 +646,14 @@ static void cpu_handle_guest_debug(CPUState *cpu) >> >> static void cpu_signal(int sig) >> { >> + CPUState *cpu; >> if (current_cpu) { >> cpu_exit(current_cpu); >> } >> - exit_request = 1; >> + >> + CPU_FOREACH(cpu) { >> + cpu->exit_loop_request = 1; >> + } >> } > You can't do this -- this code is a signal handler so it could > get run at any time including while the list of CPUs is being > updated. (This is why we have the exit_request flag in the > first place rather than just setting the exit_request flag in > each CPU...) > > Possibly you want exit_request to be a per-thread variable, > but I haven't thought much about it. > >> --- a/include/qom/cpu.h >> +++ b/include/qom/cpu.h >> @@ -249,6 +249,7 @@ struct CPUState { >> bool created; >> bool stop; >> bool stopped; >> + volatile sig_atomic_t exit_loop_request; >> volatile sig_atomic_t exit_request; >> uint32_t interrupt_request; >> int singlestep_enabled; > This would duplicate the exit_request and > exit_loop_request flags in the CPU, which is kind of odd. > > -- PMM Actually, what we want to do is remove exit_requested global because when it exits the loop in tcg_exec_all it does exit_requested = 0, and other vcpu doesn't exit. This is not clear to me why we have both exit_requested global and exit_request in CPUState. Maybe we can just make exit_request thread local this might work. Also, we need to be able to exit VCPU we want from a TCG thread. eg: We want to flush all the tlb we need to exit all cpus but one.. Thanks, Fred