protect the ramlist with a separate mutex

Add the new mutex that protects shared state between ram_save_live
and the iothread.  If the iothread mutex has to be taken together
with the ramlist mutex, the iothread shall always be _outside_.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Umesh Deshpande <udeshpan@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
This commit is contained in:
Umesh Deshpande 2011-08-17 00:01:33 -07:00 committed by Juan Quintela
parent f798b07f51
commit b2a8658ef5
3 changed files with 44 additions and 3 deletions

View file

@ -22,6 +22,7 @@
#include "qemu-common.h"
#include "qemu/tls.h"
#include "exec/cpu-common.h"
#include "qemu/thread.h"
/* some important defines:
*
@ -487,6 +488,9 @@ typedef struct RAMBlock {
ram_addr_t length;
uint32_t flags;
char idstr[256];
/* Reads can take either the iothread or the ramlist lock.
* Writes must take both locks.
*/
QTAILQ_ENTRY(RAMBlock) next;
#if defined(__linux__) && !defined(TARGET_S390X)
int fd;
@ -494,8 +498,11 @@ typedef struct RAMBlock {
} RAMBlock;
typedef struct RAMList {
QemuMutex mutex;
/* Protected by the iothread lock. */
uint8_t *phys_dirty;
RAMBlock *mru_block;
/* Protected by the ramlist lock. */
QTAILQ_HEAD(, RAMBlock) blocks;
uint32_t version;
} RAMList;
@ -516,6 +523,8 @@ extern int mem_prealloc;
void dump_exec_info(FILE *f, fprintf_function cpu_fprintf);
ram_addr_t last_ram_offset(void);
void qemu_mutex_lock_ramlist(void);
void qemu_mutex_unlock_ramlist(void);
#endif /* !CONFIG_USER_ONLY */
int cpu_memory_rw_debug(CPUArchState *env, target_ulong addr,