[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH] convert ram_list to RCU DQ
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [RFC PATCH] convert ram_list to RCU DQ |
Date: |
Wed, 28 Aug 2013 18:37:11 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8 |
Il 28/08/2013 18:02, Mike Day ha scritto:
> @@ -1102,15 +1110,15 @@ void qemu_ram_set_idstr(ram_addr_t addr, const char
> *name, DeviceState *dev)
> pstrcat(new_block->idstr, sizeof(new_block->idstr), name);
>
> /* This assumes the iothread lock is taken here too. */
> - qemu_mutex_lock_ramlist();
> - QTAILQ_FOREACH(block, &ram_list.blocks, next) {
> + rcu_read_lock();
> + QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
> if (block != new_block && !strcmp(block->idstr, new_block->idstr)) {
> fprintf(stderr, "RAMBlock \"%s\" already registered, abort!\n",
> new_block->idstr);
> abort();
> }
> }
> - qemu_mutex_unlock_ramlist();
> + rcu_read_unlock();
Forgot about this. Every time you see "This assumes the iothread lock
is taken here too", you're in the write side so you do not need
lock/unlock and you do not need...
> /* This assumes the iothread lock is taken here too. */
> qemu_mutex_lock_ramlist();
> - QTAILQ_FOREACH(block, &ram_list.blocks, next) {
> + QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
> if (addr == block->offset) {
> - QTAILQ_REMOVE(&ram_list.blocks, block, next);
> + QLIST_REMOVE_RCU(block, next);
> ram_list.mru_block = NULL;
> ram_list.version++;
> g_free(block);
qemu_mutex_lock_ramlist/qemu_mutex_unlock_ramlist either.
Otherwise, the patch is pretty solid! Thanks,
Paolo