From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42573) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YCAZh-0002U6-BG for qemu-devel@nongnu.org; Fri, 16 Jan 2015 12:20:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YCAZb-0003nB-Sw for qemu-devel@nongnu.org; Fri, 16 Jan 2015 12:20:45 -0500 Received: from [2001:41d0:8:2b42::1] (port=56928 helo=greensocs.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YCAZb-0003mv-9X for qemu-devel@nongnu.org; Fri, 16 Jan 2015 12:20:39 -0500 From: fred.konrad@greensocs.com Date: Fri, 16 Jan 2015 18:19:56 +0100 Message-Id: <1421428797-23697-10-git-send-email-fred.konrad@greensocs.com> In-Reply-To: <1421428797-23697-1-git-send-email-fred.konrad@greensocs.com> References: <1421428797-23697-1-git-send-email-fred.konrad@greensocs.com> Subject: [Qemu-devel] [RFC 09/10] cpu: remove exit_request global. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, mttcg@listserver.greensocs.com Cc: peter.maydell@linaro.org, jan.kiszka@siemens.com, mark.burton@greensocs.com, agraf@suse.de, pbonzini@redhat.com, fred.konrad@greensocs.com 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. Signed-off-by: KONRAD Frederic --- cpu-exec.c | 4 +--- cpus.c | 12 +++++++++--- include/qom/cpu.h | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index 68654e3..3ba2a7a 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -327,8 +327,6 @@ static void cpu_handle_debug_exception(CPUArchState *env) /* main execution loop */ -volatile sig_atomic_t exit_request; - int cpu_exec(CPUArchState *env) { CPUState *cpu = ENV_GET_CPU(env); @@ -365,7 +363,7 @@ int cpu_exec(CPUArchState *env) * an instruction scheduling constraint on modern architectures. */ smp_mb(); - if (unlikely(exit_request)) { + if (unlikely(cpu->exit_loop_request)) { cpu->exit_request = 1; } diff --git a/cpus.c b/cpus.c index f10c94d..8ae70c2 100644 --- 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; + } } #ifdef CONFIG_LINUX @@ -1376,7 +1380,8 @@ static void tcg_exec_all(void) if (next_cpu == NULL) { next_cpu = first_cpu; } - for (; next_cpu != NULL && !exit_request; next_cpu = CPU_NEXT(next_cpu)) { + for (; next_cpu != NULL && !first_cpu->exit_loop_request; + next_cpu = CPU_NEXT(next_cpu)) { CPUState *cpu = next_cpu; CPUArchState *env = cpu->env_ptr; @@ -1393,7 +1398,8 @@ static void tcg_exec_all(void) break; } } - exit_request = 0; + + first_cpu->exit_loop_request = 0; } void list_cpus(FILE *f, fprintf_function cpu_fprintf, const char *optarg) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 2098f1c..a2e3208 100644 --- 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; -- 1.9.0