remove mutex code

This commit is contained in:
Nguyen Anh Quynh 2017-01-20 15:44:03 +08:00
parent 42771848d6
commit c6de7930c9
23 changed files with 0 additions and 170 deletions

View File

@ -41,11 +41,9 @@ typedef struct {
} BounceBuffer;
typedef struct RAMList {
QemuMutex mutex;
/* Protected by the iothread lock. */
unsigned long *dirty_memory[DIRTY_MEMORY_NUM];
RAMBlock *mru_block;
/* Protected by the ramlist lock. */
QTAILQ_HEAD(, RAMBlock) blocks;
uint32_t version;
} RAMList;

View File

@ -188,7 +188,6 @@ struct uc_struct {
unsigned memory_region_transaction_depth;
bool memory_region_update_pending;
bool ioeventfd_update_pending;
QemuMutex flat_view_mutex;
QTAILQ_HEAD(memory_listeners, MemoryListener) memory_listeners;
QTAILQ_HEAD(, AddressSpace) address_spaces;
MachineState *machine_state;

View File

@ -2381,7 +2381,6 @@
#define qemu_clock_get_us qemu_clock_get_us_aarch64
#define qemu_clock_ptr qemu_clock_ptr_aarch64
#define qemu_clocks qemu_clocks_aarch64
#define qemu_flush_coalesced_mmio_buffer qemu_flush_coalesced_mmio_buffer_aarch64
#define qemu_get_cpu qemu_get_cpu_aarch64
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_aarch64
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_aarch64

View File

@ -2381,7 +2381,6 @@
#define qemu_clock_get_us qemu_clock_get_us_arm
#define qemu_clock_ptr qemu_clock_ptr_arm
#define qemu_clocks qemu_clocks_arm
#define qemu_flush_coalesced_mmio_buffer qemu_flush_coalesced_mmio_buffer_arm
#define qemu_get_cpu qemu_get_cpu_arm
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_arm
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_arm

View File

@ -906,20 +906,6 @@ static void mem_add(MemoryListener *listener, MemoryRegionSection *section)
}
}
void qemu_flush_coalesced_mmio_buffer(void)
{
}
void qemu_mutex_lock_ramlist(struct uc_struct *uc)
{
qemu_mutex_lock(&uc->ram_list.mutex);
}
void qemu_mutex_unlock_ramlist(struct uc_struct *uc)
{
qemu_mutex_unlock(&uc->ram_list.mutex);
}
#ifdef __linux__
#include <sys/vfs.h>
@ -1012,8 +998,6 @@ static ram_addr_t ram_block_add(struct uc_struct *uc, RAMBlock *new_block, Error
old_ram_size = last_ram_offset(uc) >> TARGET_PAGE_BITS;
/* This assumes the iothread lock is taken here too. */
qemu_mutex_lock_ramlist(uc);
new_block->offset = find_ram_offset(uc, new_block->length);
if (!new_block->host) {
@ -1023,7 +1007,6 @@ static ram_addr_t ram_block_add(struct uc_struct *uc, RAMBlock *new_block, Error
error_setg_errno(errp, errno,
"cannot set up guest memory '%s'",
memory_region_name(new_block->mr));
qemu_mutex_unlock_ramlist(uc);
return -1;
}
memory_try_enable_merging(new_block->host, new_block->length);
@ -1043,7 +1026,6 @@ static ram_addr_t ram_block_add(struct uc_struct *uc, RAMBlock *new_block, Error
uc->ram_list.mru_block = NULL;
uc->ram_list.version++;
qemu_mutex_unlock_ramlist(uc);
new_ram_size = last_ram_offset(uc) >> TARGET_PAGE_BITS;
@ -1102,8 +1084,6 @@ void qemu_ram_free_from_ptr(struct uc_struct *uc, ram_addr_t addr)
{
RAMBlock *block;
/* This assumes the iothread lock is taken here too. */
qemu_mutex_lock_ramlist(uc);
QTAILQ_FOREACH(block, &uc->ram_list.blocks, next) {
if (addr == block->offset) {
QTAILQ_REMOVE(&uc->ram_list.blocks, block, next);
@ -1113,15 +1093,12 @@ void qemu_ram_free_from_ptr(struct uc_struct *uc, ram_addr_t addr)
break;
}
}
qemu_mutex_unlock_ramlist(uc);
}
void qemu_ram_free(struct uc_struct *uc, ram_addr_t addr)
{
RAMBlock *block;
/* This assumes the iothread lock is taken here too. */
qemu_mutex_lock_ramlist(uc);
QTAILQ_FOREACH(block, &uc->ram_list.blocks, next) {
if (addr == block->offset) {
QTAILQ_REMOVE(&uc->ram_list.blocks, block, next);
@ -1141,8 +1118,6 @@ void qemu_ram_free(struct uc_struct *uc, ram_addr_t addr)
break;
}
}
qemu_mutex_unlock_ramlist(uc);
}
#ifndef _WIN32
@ -1555,7 +1530,6 @@ static void memory_map_init(struct uc_struct *uc)
void cpu_exec_init_all(struct uc_struct *uc)
{
#if !defined(CONFIG_USER_ONLY)
qemu_mutex_init(&uc->ram_list.mutex);
memory_map_init(uc);
#endif
io_mem_init(uc);

View File

@ -2387,7 +2387,6 @@ symbols = (
'qemu_clock_get_us',
'qemu_clock_ptr',
'qemu_clocks',
'qemu_flush_coalesced_mmio_buffer',
'qemu_get_cpu',
'qemu_get_guest_memory_mapping',
'qemu_get_guest_simple_memory_mapping',

View File

@ -3,10 +3,6 @@
#include "pthread.h"
#include <semaphore.h>
struct QemuMutex {
pthread_mutex_t lock;
};
struct QemuThread {
pthread_t thread;
};

View File

@ -2,11 +2,6 @@
#define __QEMU_THREAD_WIN32_H 1
#include "windows.h"
struct QemuMutex {
CRITICAL_SECTION lock;
LONG owner;
};
typedef struct QemuThreadData QemuThreadData;
struct QemuThread {
QemuThreadData *data;

View File

@ -4,7 +4,6 @@
#include <inttypes.h>
#include <stdbool.h>
typedef struct QemuMutex QemuMutex;
typedef struct QemuThread QemuThread;
#ifdef _WIN32
@ -16,11 +15,6 @@ typedef struct QemuThread QemuThread;
#define QEMU_THREAD_JOINABLE 0
#define QEMU_THREAD_DETACHED 1
void qemu_mutex_init(QemuMutex *mutex);
void qemu_mutex_destroy(QemuMutex *mutex);
void qemu_mutex_lock(QemuMutex *mutex);
void qemu_mutex_unlock(QemuMutex *mutex);
struct uc_struct;
// return -1 on error, 0 on success
int qemu_thread_create(struct uc_struct *uc, QemuThread *thread, const char *name,

View File

@ -123,14 +123,6 @@ static inline int64_t qemu_clock_get_us(QEMUClockType type)
QEMUTimerList *timerlist_new(QEMUClockType type,
QEMUTimerListNotifyCB *cb, void *opaque);
/**
* timerlist_free:
* @timer_list: the timer list to free
*
* Frees a timer_list. It must have no active timers.
*/
void timerlist_free(QEMUTimerList *timer_list);
/**
* timerlist_has_timers:
* @timer_list: the timer list to operate on

View File

@ -2381,7 +2381,6 @@
#define qemu_clock_get_us qemu_clock_get_us_m68k
#define qemu_clock_ptr qemu_clock_ptr_m68k
#define qemu_clocks qemu_clocks_m68k
#define qemu_flush_coalesced_mmio_buffer qemu_flush_coalesced_mmio_buffer_m68k
#define qemu_get_cpu qemu_get_cpu_m68k
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_m68k
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_m68k

View File

@ -122,16 +122,8 @@ int memory_free(struct uc_struct *uc)
return 0;
}
/* flat_view_mutex is taken around reading as->current_map; the critical
* section is extremely short, so I'm using a single mutex for every AS.
* We could also RCU for the read-side.
*
* The BQL is taken around transaction commits, hence both locks are taken
* while writing to as->current_map (with the BQL taken outside).
*/
static void memory_init(struct uc_struct *uc)
{
qemu_mutex_init(&uc->flat_view_mutex);
}
typedef struct AddrRange AddrRange;
@ -484,9 +476,6 @@ static void memory_region_read_accessor(MemoryRegion *mr,
{
uint64_t tmp;
if (mr->flush_coalesced_mmio) {
qemu_flush_coalesced_mmio_buffer();
}
tmp = mr->ops->read(mr->uc, mr->opaque, addr, size);
*value |= (tmp & mask) << shift;
}
@ -513,9 +502,6 @@ static void memory_region_write_accessor(MemoryRegion *mr,
{
uint64_t tmp;
if (mr->flush_coalesced_mmio) {
qemu_flush_coalesced_mmio_buffer();
}
tmp = (*value >> shift) & mask;
mr->ops->write(mr->uc, mr->opaque, addr, tmp, size);
}
@ -732,10 +718,8 @@ static FlatView *address_space_get_flatview(AddressSpace *as)
{
FlatView *view;
qemu_mutex_lock(&as->uc->flat_view_mutex);
view = as->current_map;
flatview_ref(view);
qemu_mutex_unlock(&as->uc->flat_view_mutex);
return view;
}
@ -845,10 +829,8 @@ static void address_space_update_topology(AddressSpace *as)
address_space_update_topology_pass(as, old_view, new_view, false);
address_space_update_topology_pass(as, old_view, new_view, true);
qemu_mutex_lock(&as->uc->flat_view_mutex);
flatview_unref(as->current_map);
as->current_map = new_view;
qemu_mutex_unlock(&as->uc->flat_view_mutex);
/* Note that all the old MemoryRegions are still alive up to this
* point. This relieves most MemoryListeners from the need to
@ -863,7 +845,6 @@ static void address_space_update_topology(AddressSpace *as)
void memory_region_transaction_begin(struct uc_struct *uc)
{
qemu_flush_coalesced_mmio_buffer();
++uc->memory_region_transaction_depth;
}
@ -1459,7 +1440,6 @@ void memory_region_clear_coalescing(MemoryRegion *mr)
CoalescedMemoryRange *cmr;
bool updated = false;
qemu_flush_coalesced_mmio_buffer();
mr->flush_coalesced_mmio = false;
while (!QTAILQ_EMPTY(&mr->coalesced)) {

View File

@ -2381,7 +2381,6 @@
#define qemu_clock_get_us qemu_clock_get_us_mips
#define qemu_clock_ptr qemu_clock_ptr_mips
#define qemu_clocks qemu_clocks_mips
#define qemu_flush_coalesced_mmio_buffer qemu_flush_coalesced_mmio_buffer_mips
#define qemu_get_cpu qemu_get_cpu_mips
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_mips
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_mips

View File

@ -2381,7 +2381,6 @@
#define qemu_clock_get_us qemu_clock_get_us_mips64
#define qemu_clock_ptr qemu_clock_ptr_mips64
#define qemu_clocks qemu_clocks_mips64
#define qemu_flush_coalesced_mmio_buffer qemu_flush_coalesced_mmio_buffer_mips64
#define qemu_get_cpu qemu_get_cpu_mips64
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_mips64
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_mips64

View File

@ -2381,7 +2381,6 @@
#define qemu_clock_get_us qemu_clock_get_us_mips64el
#define qemu_clock_ptr qemu_clock_ptr_mips64el
#define qemu_clocks qemu_clocks_mips64el
#define qemu_flush_coalesced_mmio_buffer qemu_flush_coalesced_mmio_buffer_mips64el
#define qemu_get_cpu qemu_get_cpu_mips64el
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_mips64el
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_mips64el

View File

@ -2381,7 +2381,6 @@
#define qemu_clock_get_us qemu_clock_get_us_mipsel
#define qemu_clock_ptr qemu_clock_ptr_mipsel
#define qemu_clocks qemu_clocks_mipsel
#define qemu_flush_coalesced_mmio_buffer qemu_flush_coalesced_mmio_buffer_mipsel
#define qemu_get_cpu qemu_get_cpu_mipsel
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_mipsel
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_mipsel

View File

@ -2381,7 +2381,6 @@
#define qemu_clock_get_us qemu_clock_get_us_powerpc
#define qemu_clock_ptr qemu_clock_ptr_powerpc
#define qemu_clocks qemu_clocks_powerpc
#define qemu_flush_coalesced_mmio_buffer qemu_flush_coalesced_mmio_buffer_powerpc
#define qemu_get_cpu qemu_get_cpu_powerpc
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_powerpc
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_powerpc

View File

@ -64,7 +64,6 @@ static QEMUClock qemu_clocks[QEMU_CLOCK_MAX];
struct QEMUTimerList {
QEMUClock *clock;
QemuMutex active_timers_lock;
QEMUTimer *active_timers;
QLIST_ENTRY(QEMUTimerList) list;
QEMUTimerListNotifyCB *notify_cb;
@ -89,16 +88,6 @@ static bool timer_expired_ns(QEMUTimer *timer_head, int64_t current_time)
return timer_head && (timer_head->expire_time <= current_time);
}
void timerlist_free(QEMUTimerList *timer_list)
{
assert(!timerlist_has_timers(timer_list));
if (timer_list->clock) {
QLIST_REMOVE(timer_list, list);
}
qemu_mutex_destroy(&timer_list->active_timers_lock);
g_free(timer_list);
}
bool timerlist_has_timers(QEMUTimerList *timer_list)
{
return !!timer_list->active_timers;
@ -172,9 +161,7 @@ void timer_del(QEMUTimer *ts)
{
QEMUTimerList *timer_list = ts->timer_list;
qemu_mutex_lock(&timer_list->active_timers_lock);
timer_del_locked(timer_list, ts);
qemu_mutex_unlock(&timer_list->active_timers_lock);
}
/* modify the current timer so that it will be fired when current_time
@ -184,10 +171,8 @@ void timer_mod_ns(QEMUTimer *ts, int64_t expire_time)
QEMUTimerList *timer_list = ts->timer_list;
bool rearm;
qemu_mutex_lock(&timer_list->active_timers_lock);
timer_del_locked(timer_list, ts);
rearm = timer_mod_ns_locked(timer_list, ts, expire_time);
qemu_mutex_unlock(&timer_list->active_timers_lock);
if (rearm) {
timerlist_rearm(timer_list);

View File

@ -2381,7 +2381,6 @@
#define qemu_clock_get_us qemu_clock_get_us_sparc
#define qemu_clock_ptr qemu_clock_ptr_sparc
#define qemu_clocks qemu_clocks_sparc
#define qemu_flush_coalesced_mmio_buffer qemu_flush_coalesced_mmio_buffer_sparc
#define qemu_get_cpu qemu_get_cpu_sparc
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_sparc
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_sparc

View File

@ -2381,7 +2381,6 @@
#define qemu_clock_get_us qemu_clock_get_us_sparc64
#define qemu_clock_ptr qemu_clock_ptr_sparc64
#define qemu_clocks qemu_clocks_sparc64
#define qemu_flush_coalesced_mmio_buffer qemu_flush_coalesced_mmio_buffer_sparc64
#define qemu_get_cpu qemu_get_cpu_sparc64
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_sparc64
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_sparc64

View File

@ -33,47 +33,6 @@ static void error_exit(int err, const char *msg)
abort();
}
void qemu_mutex_init(QemuMutex *mutex)
{
int err;
pthread_mutexattr_t mutexattr;
pthread_mutexattr_init(&mutexattr);
pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_ERRORCHECK);
err = pthread_mutex_init(&mutex->lock, &mutexattr);
pthread_mutexattr_destroy(&mutexattr);
if (err)
error_exit(err, __func__);
}
void qemu_mutex_destroy(QemuMutex *mutex)
{
int err;
err = pthread_mutex_destroy(&mutex->lock);
if (err)
error_exit(err, __func__);
}
void qemu_mutex_lock(QemuMutex *mutex)
{
int err;
err = pthread_mutex_lock(&mutex->lock);
if (err)
error_exit(err, __func__);
}
void qemu_mutex_unlock(QemuMutex *mutex)
{
int err;
err = pthread_mutex_unlock(&mutex->lock);
if (err)
error_exit(err, __func__);
}
int qemu_thread_create(struct uc_struct *uc, QemuThread *thread, const char *name,
void *(*start_routine)(void*),
void *arg, int mode)

View File

@ -30,36 +30,6 @@ static void error_exit(int err, const char *msg)
//abort();
}
void qemu_mutex_init(QemuMutex *mutex)
{
mutex->owner = 0;
InitializeCriticalSection(&mutex->lock);
}
void qemu_mutex_destroy(QemuMutex *mutex)
{
assert(mutex->owner == 0);
DeleteCriticalSection(&mutex->lock);
}
void qemu_mutex_lock(QemuMutex *mutex)
{
EnterCriticalSection(&mutex->lock);
/* Win32 CRITICAL_SECTIONs are recursive. Assert that we're not
* using them as such.
*/
assert(mutex->owner == 0);
mutex->owner = GetCurrentThreadId();
}
void qemu_mutex_unlock(QemuMutex *mutex)
{
assert(mutex->owner == GetCurrentThreadId());
mutex->owner = 0;
LeaveCriticalSection(&mutex->lock);
}
struct QemuThreadData {
/* Passed to win32_start_routine. */
void *(*start_routine)(void *);

View File

@ -2381,7 +2381,6 @@
#define qemu_clock_get_us qemu_clock_get_us_x86_64
#define qemu_clock_ptr qemu_clock_ptr_x86_64
#define qemu_clocks qemu_clocks_x86_64
#define qemu_flush_coalesced_mmio_buffer qemu_flush_coalesced_mmio_buffer_x86_64
#define qemu_get_cpu qemu_get_cpu_x86_64
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_x86_64
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_x86_64