qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH v4 2/5] ramlist mutex


From: Umesh Deshpande
Subject: Re: [Qemu-devel] [RFC PATCH v4 2/5] ramlist mutex
Date: Fri, 19 Aug 2011 02:20:33 -0400
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Thunderbird/3.1.11

On 08/17/2011 02:28 AM, Paolo Bonzini wrote:
On 08/16/2011 08:56 PM, Umesh Deshpande wrote:
@@ -3001,8 +3016,10 @@ void qemu_ram_free_from_ptr(ram_addr_t addr)

      QLIST_FOREACH(block,&ram_list.blocks, next) {
          if (addr == block->offset) {
+            qemu_mutex_lock_ramlist();
              QLIST_REMOVE(block, next);
              QLIST_REMOVE(block, next_mru);
+            qemu_mutex_unlock_ramlist();
              qemu_free(block);
              return;
          }
@@ -3015,8 +3032,10 @@ void qemu_ram_free(ram_addr_t addr)

      QLIST_FOREACH(block,&ram_list.blocks, next) {
          if (addr == block->offset) {
+            qemu_mutex_lock_ramlist();
              QLIST_REMOVE(block, next);
              QLIST_REMOVE(block, next_mru);
+            qemu_mutex_unlock_ramlist();
              if (block->flags&  RAM_PREALLOC_MASK) {
                  ;
              } else if (mem_path) {

You must protect the whole QLIST_FOREACH.  Otherwise looks good.
Or, is it okay to convert all the ramblock list traversals in exec.c (under iothread) to mru traversals, and probably it makes sense as the original list was also maintained in the mru order, whereas the sequence of blocks doesn't matter for the migration code. This way we don't have to acquire the mutex for block list traversals.

- Umesh




reply via email to

[Prev in Thread] Current Thread [Next in Thread]