Skip to content

Commit

Permalink
exec: Reduce CONFIG_USER_ONLY ifdeffenery
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
  • Loading branch information
Igor Mammedov authored and ehabkost committed Jul 26, 2016
1 parent f49ee63 commit 1bc7e52
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
2 changes: 0 additions & 2 deletions bsd-user/qemu.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,6 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
abi_ulong new_addr);
int target_msync(abi_ulong start, abi_ulong len, int flags);
extern unsigned long last_brk;
void cpu_list_lock(void);
void cpu_list_unlock(void);
#if defined(CONFIG_USE_NPTL)
void mmap_fork_start(void);
void mmap_fork_end(int child);
Expand Down
17 changes: 3 additions & 14 deletions exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,23 +642,17 @@ void cpu_exec_exit(CPUState *cpu)
{
CPUClass *cc = CPU_GET_CLASS(cpu);

#if defined(CONFIG_USER_ONLY)
cpu_list_lock();
#endif
if (cpu->cpu_index == -1) {
/* cpu_index was never allocated by this @cpu or was already freed. */
#if defined(CONFIG_USER_ONLY)
cpu_list_unlock();
#endif
return;
}

QTAILQ_REMOVE(&cpus, cpu, node);
cpu_release_index(cpu);
cpu->cpu_index = -1;
#if defined(CONFIG_USER_ONLY)
cpu_list_unlock();
#endif

if (cc->vmsd != NULL) {
vmstate_unregister(NULL, cc->vmsd, cpu);
Expand All @@ -670,7 +664,7 @@ void cpu_exec_exit(CPUState *cpu)

void cpu_exec_init(CPUState *cpu, Error **errp)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu);
Error *local_err = NULL;

cpu->as = NULL;
Expand All @@ -694,22 +688,17 @@ void cpu_exec_init(CPUState *cpu, Error **errp)
object_ref(OBJECT(cpu->memory));
#endif

#if defined(CONFIG_USER_ONLY)
cpu_list_lock();
#endif
cpu->cpu_index = cpu_get_free_index(&local_err);
if (local_err) {
error_propagate(errp, local_err);
#if defined(CONFIG_USER_ONLY)
cpu_list_unlock();
#endif
return;
}
QTAILQ_INSERT_TAIL(&cpus, cpu, node);
#if defined(CONFIG_USER_ONLY)
(void) cc;
cpu_list_unlock();
#else

#ifndef CONFIG_USER_ONLY
if (qdev_get_vmsd(DEVICE(cpu)) == NULL) {
vmstate_register(NULL, cpu->cpu_index, &vmstate_cpu_common, cpu);
}
Expand Down
12 changes: 12 additions & 0 deletions include/exec/exec-all.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
target_ulong pc, target_ulong cs_base,
uint32_t flags,
int cflags);
#if defined(CONFIG_USER_ONLY)
void cpu_list_lock(void);
void cpu_list_unlock(void);
#else
static inline void cpu_list_unlock(void)
{
}
static inline void cpu_list_lock(void)
{
}
#endif

void cpu_exec_init(CPUState *cpu, Error **errp);
void QEMU_NORETURN cpu_loop_exit(CPUState *cpu);
void QEMU_NORETURN cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc);
Expand Down
2 changes: 0 additions & 2 deletions linux-user/qemu.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,6 @@ int target_msync(abi_ulong start, abi_ulong len, int flags);
extern unsigned long last_brk;
extern abi_ulong mmap_next_start;
abi_ulong mmap_find_vma(abi_ulong, abi_ulong);
void cpu_list_lock(void);
void cpu_list_unlock(void);
void mmap_fork_start(void);
void mmap_fork_end(int child);

Expand Down

0 comments on commit 1bc7e52

Please sign in to comment.