[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 36/47] cpu: Move running field to CPUState
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PATCH 36/47] cpu: Move running field to CPUState |
Date: |
Sat, 16 Feb 2013 16:45:31 +0100 |
Pass CPUState to cpu_exec_{start,end}() functions.
Signed-off-by: Andreas Färber <address@hidden>
---
include/exec/cpu-defs.h | 1 -
include/qom/cpu.h | 2 ++
linux-user/main.c | 37 ++++++++++++++++++++++---------------
3 Dateien geändert, 24 Zeilen hinzugefügt(+), 16 Zeilen entfernt(-)
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 created.
* @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 146a468..e515684 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();
pending_cpus = 1;
/* Make all other cpus stop executing. */
for (other = first_cpu; other; other = other->next_cpu) {
- if (other->running) {
+ other_cpu = ENV_GET_CPU(other);
+ if (other_cpu->running) {
pending_cpus++;
cpu_exit(other);
}
@@ -176,19 +179,19 @@ static inline void end_exclusive(void)
}
/* 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 = 1;
+ cpu->running = true;
pthread_mutex_unlock(&exclusive_lock);
}
/* 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 = 0;
+ cpu->running = false;
if (pending_cpus > 1) {
pending_cpus--;
if (pending_cpus == 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)
{
}
-static inline void cpu_exec_end(CPUArchState *env)
+static inline void cpu_exec_end(CPUState *cpu)
{
}
@@ -697,15 +700,16 @@ done:
void cpu_loop(CPUARMState *env)
{
+ CPUState *cs = CPU(arm_env_get_cpu(env));
int trapnr;
unsigned int n, insn;
target_siginfo_t info;
uint32_t addr;
for(;;) {
- cpu_exec_start(env);
+ cpu_exec_start(cs);
trapnr = 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)
void cpu_loop(CPUUniCore32State *env)
{
+ CPUState *cs = CPU(uc32_env_get_cpu(env));
int trapnr;
unsigned int n, insn;
target_siginfo_t info;
for (;;) {
- cpu_exec_start(env);
+ cpu_exec_start(cs);
trapnr = 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)
void cpu_loop(CPUPPCState *env)
{
+ CPUState *cs = CPU(ppc_env_get_cpu(env));
target_siginfo_t info;
int trapnr;
target_ulong ret;
for(;;) {
- cpu_exec_start(env);
+ cpu_exec_start(cs);
trapnr = 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)
void cpu_loop(CPUMIPSState *env)
{
+ CPUState *cs = CPU(mips_env_get_cpu(env));
target_siginfo_t info;
int trapnr, ret;
unsigned int syscall_num;
for(;;) {
- cpu_exec_start(env);
+ cpu_exec_start(cs);
trapnr = cpu_mips_exec(env);
- cpu_exec_end(env);
+ cpu_exec_end(cs);
switch(trapnr) {
case EXCP_SYSCALL:
syscall_num = env->active_tc.gpr[2] - 4000;
--
1.7.10.4
- [Qemu-devel] [PATCH 17/47] target-arm: Move TCG initialization to ARMCPU initfn, (continued)
- [Qemu-devel] [PATCH 17/47] target-arm: Move TCG initialization to ARMCPU initfn, Andreas Färber, 2013/02/16
- [Qemu-devel] [PATCH 20/47] target-m68k: Move TCG initialization to M68kCPU initfn, Andreas Färber, 2013/02/16
- [Qemu-devel] [PATCH 21/47] target-microblaze: Move TCG initialization to MicroBlazeCPU initfn, Andreas Färber, 2013/02/16
- [Qemu-devel] [PATCH 16/47] target-xtensa: Introduce QOM realizefn for XtensaCPU, Andreas Färber, 2013/02/16
- [Qemu-devel] [PATCH 24/47] target-s390x: Move TCG initialization to S390CPU initfn, Andreas Färber, 2013/02/16
- [Qemu-devel] [PATCH 22/47] target-mips: Move TCG initialization to MIPSCPU initfn, Andreas Färber, 2013/02/16
- [Qemu-devel] [PATCH 25/47] target-sh4: Move TCG initialization to SuperHCPU initfn, Andreas Färber, 2013/02/16
- [Qemu-devel] [PATCH 23/47] target-ppc: Move TCG initialization to PowerPCCPU initfn, Andreas Färber, 2013/02/16
- [Qemu-devel] [PATCH 26/47] target-sparc: Move TCG initialization to SPARCCPU initfn, Andreas Färber, 2013/02/16
- [Qemu-devel] [PATCH 43/47] spapr_hcall: Replace open-coded CPU loop with qemu_get_cpu(), Andreas Färber, 2013/02/16
- [Qemu-devel] [PATCH 36/47] cpu: Move running field to CPUState,
Andreas Färber <=
- [Qemu-devel] [PATCH 29/47] ppc405_uc: Pass PowerPCCPU to ppc40x_{core, chip, system}_reset(), Andreas Färber, 2013/02/16
- [Qemu-devel] [PATCH 27/47] target-unicore32: Move TCG initialization to UniCore32CPU initfn, Andreas Färber, 2013/02/16
- [Qemu-devel] [PATCH 45/47] target-lm32: Drop unused cpu_lm32_close() prototype, Andreas Färber, 2013/02/16
- [Qemu-devel] [PATCH 30/47] target-m68k: Return M68kCPU from cpu_m68k_init(), Andreas Färber, 2013/02/16
- [Qemu-devel] [PATCH 47/47] target-i386: Split command line parsing out of cpu_x86_register(), Andreas Färber, 2013/02/16
- [Qemu-devel] [PATCH 31/47] mcf5206: Pass M68kCPU to mcf5206_init(), Andreas Färber, 2013/02/16
- [Qemu-devel] [PATCH 46/47] target-i386: Move cpu_x86_init(), Andreas Färber, 2013/02/16
- [Qemu-devel] [PATCH 33/47] target-m68k: Pass M68kCPU to m68k_set_irq_level(), Andreas Färber, 2013/02/16
- [Qemu-devel] [PATCH 41/47] e500: Replace open-coded loop with qemu_get_cpu(), Andreas Färber, 2013/02/16
- [Qemu-devel] [PATCH 35/47] cpu: Move host_tid field to CPUState, Andreas Färber, 2013/02/16