Received: from eggs.gnu.org ([208.118.235.92]:60202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1FtP-0006l8-Mm for qemu-devel@nongnu.org; Fri, 01 Feb 2013 07:38:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U1FtO-00028b-CT for qemu-devel@nongnu.org; Fri, 01 Feb 2013 07:38:55 -0500 Received: from cantor2.suse.de ([195.135.220.15]:56675 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1FtN-00028M-Py for qemu-devel@nongnu.org; Fri, 01 Feb 2013 07:38:54 -0500 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Fri, 1 Feb 2013 13:38:28 +0100 Message-Id: <1359722312-2391-3-git-send-email-afaerber@suse.de> In-Reply-To: <1359722312-2391-1-git-send-email-afaerber@suse.de> References: <1359722312-2391-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH qom-cpu-next 2/6] cpu: Move running field to CPUState List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Riku Voipio , =?UTF-8?q?Andreas=20F=C3=A4rber?= Pass CPUState to cpu_exec_{start,end}() functions. Signed-off-by: Andreas F=C3=A4rber --- include/exec/cpu-defs.h | 1 - include/qom/cpu.h | 2 ++ linux-user/main.c | 37 ++++++++++++++++++++++--------------- 3 Dateien ge=C3=A4ndert, 24 Zeilen hinzugef=C3=BCgt(+), 16 Zeilen entfer= nt(-) diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index ae832a9..ba814ff 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -191,7 +191,6 @@ typedef struct CPUWatchpoint { int exception_index; = \ = \ CPUArchState *next_cpu; /* next CPU sharing TB cache */ = \ - int running; /* Nonzero if cpu is currently running(usermode). */ = \ /* user data */ = \ void *opaque; = \ = \ diff --git a/include/qom/cpu.h b/include/qom/cpu.h index e371655..c465d88 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -66,6 +66,7 @@ struct kvm_run; * @nr_threads: Number of threads within this CPU. * @numa_node: NUMA node this CPU is belonging to. * @host_tid: Host thread ID. + * @running: #true if CPU is currently running (usermode). * @created: Indicates whether the CPU thread has been successfully crea= ted. * @stop: Indicates a pending stop request. * @stopped: Indicates the CPU has been artificially stopped. @@ -88,6 +89,7 @@ struct CPUState { #endif int thread_id; uint32_t host_tid; + bool running; struct QemuCond *halt_cond; struct qemu_work_item *queued_work_first, *queued_work_last; bool thread_kicked; diff --git a/linux-user/main.c b/linux-user/main.c index 3df8aa2..d97ff86 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -151,13 +151,16 @@ static inline void exclusive_idle(void) static inline void start_exclusive(void) { CPUArchState *other; + CPUState *other_cpu; + pthread_mutex_lock(&exclusive_lock); exclusive_idle(); =20 pending_cpus =3D 1; /* Make all other cpus stop executing. */ for (other =3D first_cpu; other; other =3D other->next_cpu) { - if (other->running) { + other_cpu =3D ENV_GET_CPU(other); + if (other_cpu->running) { pending_cpus++; cpu_exit(other); } @@ -176,19 +179,19 @@ static inline void end_exclusive(void) } =20 /* Wait for exclusive ops to finish, and begin cpu execution. */ -static inline void cpu_exec_start(CPUArchState *env) +static inline void cpu_exec_start(CPUState *cpu) { pthread_mutex_lock(&exclusive_lock); exclusive_idle(); - env->running =3D 1; + cpu->running =3D true; pthread_mutex_unlock(&exclusive_lock); } =20 /* Mark cpu as not executing, and release pending exclusive ops. */ -static inline void cpu_exec_end(CPUArchState *env) +static inline void cpu_exec_end(CPUState *cpu) { pthread_mutex_lock(&exclusive_lock); - env->running =3D 0; + cpu->running =3D false; if (pending_cpus > 1) { pending_cpus--; if (pending_cpus =3D=3D 1) { @@ -210,11 +213,11 @@ void cpu_list_unlock(void) } #else /* if !CONFIG_USE_NPTL */ /* These are no-ops because we are not threadsafe. */ -static inline void cpu_exec_start(CPUArchState *env) +static inline void cpu_exec_start(CPUState *cpu) { } =20 -static inline void cpu_exec_end(CPUArchState *env) +static inline void cpu_exec_end(CPUState *cpu) { } =20 @@ -697,15 +700,16 @@ done: =20 void cpu_loop(CPUARMState *env) { + CPUState *cs =3D CPU(arm_env_get_cpu(env)); int trapnr; unsigned int n, insn; target_siginfo_t info; uint32_t addr; =20 for(;;) { - cpu_exec_start(env); + cpu_exec_start(cs); trapnr =3D cpu_arm_exec(env); - cpu_exec_end(env); + cpu_exec_end(cs); switch(trapnr) { case EXCP_UDEF: { @@ -912,14 +916,15 @@ void cpu_loop(CPUARMState *env) =20 void cpu_loop(CPUUniCore32State *env) { + CPUState *cs =3D CPU(uc32_env_get_cpu(env)); int trapnr; unsigned int n, insn; target_siginfo_t info; =20 for (;;) { - cpu_exec_start(env); + cpu_exec_start(cs); trapnr =3D uc32_cpu_exec(env); - cpu_exec_end(env); + cpu_exec_end(cs); switch (trapnr) { case UC32_EXCP_PRIV: { @@ -1367,14 +1372,15 @@ static int do_store_exclusive(CPUPPCState *env) =20 void cpu_loop(CPUPPCState *env) { + CPUState *cs =3D CPU(ppc_env_get_cpu(env)); target_siginfo_t info; int trapnr; target_ulong ret; =20 for(;;) { - cpu_exec_start(env); + cpu_exec_start(cs); trapnr =3D cpu_ppc_exec(env); - cpu_exec_end(env); + cpu_exec_end(cs); switch(trapnr) { case POWERPC_EXCP_NONE: /* Just go on */ @@ -2184,14 +2190,15 @@ static int do_store_exclusive(CPUMIPSState *env) =20 void cpu_loop(CPUMIPSState *env) { + CPUState *cs =3D CPU(mips_env_get_cpu(env)); target_siginfo_t info; int trapnr, ret; unsigned int syscall_num; =20 for(;;) { - cpu_exec_start(env); + cpu_exec_start(cs); trapnr =3D cpu_mips_exec(env); - cpu_exec_end(env); + cpu_exec_end(cs); switch(trapnr) { case EXCP_SYSCALL: syscall_num =3D env->active_tc.gpr[2] - 4000; --=20 1.7.10.4