qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org
Cc: amit.shah@redhat.com, arei.gonglei@huawei.com,
	mrhines@us.ibm.com, quintela@redhat.com
Subject: [Qemu-devel] [PATCH 07/10] Simplify rdma_delete_block and remove it's dependence on the hash
Date: Mon, 20 Apr 2015 16:57:22 +0100	[thread overview]
Message-ID: <1429545445-28216-8-git-send-email-dgilbert@redhat.com> (raw)
In-Reply-To: <1429545445-28216-1-git-send-email-dgilbert@redhat.com>

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

rdma_delete_block is currently very general, but it's only used
in cleanup at the end.   Simplify it and remove it's dependence
on the hash table and remove all of the hash-table regeneration
designed to handle the (unused) case of deleting an arbitrary block.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 migration/rdma.c | 57 +++++++++-----------------------------------------------
 trace-events     |  2 +-
 2 files changed, 10 insertions(+), 49 deletions(-)

diff --git a/migration/rdma.c b/migration/rdma.c
index 4f7dd0d..fe3b76e 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -617,16 +617,11 @@ static int qemu_rdma_init_ram_blocks(RDMAContext *rdma)
     return 0;
 }
 
-static int rdma_delete_block(RDMAContext *rdma, ram_addr_t block_offset)
+static int rdma_delete_block(RDMAContext *rdma, RDMALocalBlock *block)
 {
-    RDMALocalBlocks *local = &rdma->local_ram_blocks;
-    RDMALocalBlock *block = g_hash_table_lookup(rdma->blockmap,
-        (void *) block_offset);
-    RDMALocalBlock *old = local->block;
-    int x;
-
-    assert(block);
-
+    if (rdma->blockmap) {
+        g_hash_table_remove(rdma->blockmap, (void *)(uintptr_t)block->offset);
+    }
     if (block->pmr) {
         int j;
 
@@ -656,51 +651,15 @@ static int rdma_delete_block(RDMAContext *rdma, ram_addr_t block_offset)
     g_free(block->remote_keys);
     block->remote_keys = NULL;
 
-    for (x = 0; x < local->nb_blocks; x++) {
-        g_hash_table_remove(rdma->blockmap, (void *)(uintptr_t)old[x].offset);
-    }
-
     g_free(block->block_name);
     block->block_name = NULL;
 
-    if (local->nb_blocks > 1) {
-
-        local->block = g_malloc0(sizeof(RDMALocalBlock) *
-                                    (local->nb_blocks - 1));
-
-        if (block->index) {
-            memcpy(local->block, old, sizeof(RDMALocalBlock) * block->index);
-        }
-
-        if (block->index < (local->nb_blocks - 1)) {
-            memcpy(local->block + block->index, old + (block->index + 1),
-                sizeof(RDMALocalBlock) *
-                    (local->nb_blocks - (block->index + 1)));
-        }
-    } else {
-        assert(block == local->block);
-        local->block = NULL;
-    }
-
-    trace_rdma_delete_block(local->nb_blocks,
-                           (uintptr_t)block->local_host_addr,
+    trace_rdma_delete_block(block, (uintptr_t)block->local_host_addr,
                            block->offset, block->length,
                             (uintptr_t)(block->local_host_addr + block->length),
                            BITS_TO_LONGS(block->nb_chunks) *
                                sizeof(unsigned long) * 8, block->nb_chunks);
 
-    g_free(old);
-
-    local->nb_blocks--;
-
-    if (local->nb_blocks) {
-        for (x = 0; x < local->nb_blocks; x++) {
-            g_hash_table_insert(rdma->blockmap,
-                                (void *)(uintptr_t)local->block[x].offset,
-                                &local->block[x]);
-        }
-    }
-
     return 0;
 }
 
@@ -2213,9 +2172,11 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
     }
 
     if (rdma->local_ram_blocks.block) {
-        while (rdma->local_ram_blocks.nb_blocks) {
-            rdma_delete_block(rdma, rdma->local_ram_blocks.block->offset);
+        for (idx = 0; idx < rdma->local_ram_blocks.nb_blocks; idx++) {
+            rdma_delete_block(rdma, &rdma->local_ram_blocks.block[idx]);
         }
+        g_free(rdma->local_ram_blocks.block);
+        rdma->local_ram_blocks.block = NULL;
     }
 
     if (rdma->qp) {
diff --git a/trace-events b/trace-events
index baf8647..bdb0868 100644
--- a/trace-events
+++ b/trace-events
@@ -1436,7 +1436,7 @@ qemu_rdma_write_one_sendreg(uint64_t chunk, int len, int index, int64_t offset)
 qemu_rdma_write_one_top(uint64_t chunks, uint64_t size) "Writing %" PRIu64 " chunks, (%" PRIu64 " MB)"
 qemu_rdma_write_one_zero(uint64_t chunk, int len, int index, int64_t offset) "Entire chunk is zero, sending compress: %" PRIu64 " for %d bytes, index: %d, offset: %" PRId64
 rdma_add_block(const char *block_name, int block, uint64_t addr, uint64_t offset, uint64_t len, uint64_t end, uint64_t bits, int chunks) "Added Block: '%s':%d, addr: %" PRIu64 ", offset: %" PRIu64 " length: %" PRIu64 " end: %" PRIu64 " bits %" PRIu64 " chunks %d"
-rdma_delete_block(int block, uint64_t addr, uint64_t offset, uint64_t len, uint64_t end, uint64_t bits, int chunks) "Deleted Block: %d, addr: %" PRIu64 ", offset: %" PRIu64 " length: %" PRIu64 " end: %" PRIu64 " bits %" PRIu64 " chunks %d"
+rdma_delete_block(void *block, uint64_t addr, uint64_t offset, uint64_t len, uint64_t end, uint64_t bits, int chunks) "Deleted Block: %p, addr: %" PRIu64 ", offset: %" PRIu64 " length: %" PRIu64 " end: %" PRIu64 " bits %" PRIu64 " chunks %d"
 rdma_start_incoming_migration(void) ""
 rdma_start_incoming_migration_after_dest_init(void) ""
 rdma_start_incoming_migration_after_rdma_listen(void) ""
-- 
2.3.5

  parent reply	other threads:[~2015-04-20 15:57 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-20 15:57 [Qemu-devel] [PATCH 00/10] Remove RDMA migration dependence on RAMBlock offset Dr. David Alan Gilbert (git)
2015-04-20 15:57 ` [Qemu-devel] [PATCH 01/10] Rename RDMA structures to make destination clear Dr. David Alan Gilbert (git)
2015-05-19 17:52   ` Michael R. Hines
2015-04-20 15:57 ` [Qemu-devel] [PATCH 02/10] qemu_ram_foreach_block: pass up error value, and down the ramblock name Dr. David Alan Gilbert (git)
2015-05-19 17:56   ` Michael R. Hines
2015-04-20 15:57 ` [Qemu-devel] [PATCH 03/10] Store block name in local blocks structure Dr. David Alan Gilbert (git)
2015-05-19 18:00   ` Michael R. Hines
2015-05-19 18:46     ` Dr. David Alan Gilbert
2015-04-20 15:57 ` [Qemu-devel] [PATCH 04/10] Translate offsets to destination address space Dr. David Alan Gilbert (git)
2015-05-19 18:28   ` Michael R. Hines
2015-05-19 18:44     ` Dr. David Alan Gilbert
2015-05-19 18:57       ` Michael R. Hines
2015-05-19 19:02         ` Dr. David Alan Gilbert
2015-04-20 15:57 ` [Qemu-devel] [PATCH 05/10] Rework ram_control_load_hook to hook during block load Dr. David Alan Gilbert (git)
2015-05-19 18:35   ` Michael R. Hines
2015-05-19 18:49     ` Dr. David Alan Gilbert
2015-04-20 15:57 ` [Qemu-devel] [PATCH 06/10] Remove unneeded memset Dr. David Alan Gilbert (git)
2015-05-19 18:35   ` Michael R. Hines
2015-04-20 15:57 ` Dr. David Alan Gilbert (git) [this message]
2015-05-19 18:44   ` [Qemu-devel] [PATCH 07/10] Simplify rdma_delete_block and remove it's dependence on the hash Michael R. Hines
2015-04-20 15:57 ` [Qemu-devel] [PATCH 08/10] Rework ram block hash Dr. David Alan Gilbert (git)
2015-05-19 18:49   ` Michael R. Hines
2015-05-19 18:55     ` Dr. David Alan Gilbert
2015-05-19 19:02       ` Michael R. Hines
2015-05-19 19:07         ` Dr. David Alan Gilbert
2015-04-20 15:57 ` [Qemu-devel] [PATCH 09/10] Sort destination RAMBlocks to be the same as the source Dr. David Alan Gilbert (git)
2015-05-19 18:51   ` Michael R. Hines
2015-06-01 11:53     ` Dr. David Alan Gilbert
2015-04-20 15:57 ` [Qemu-devel] [PATCH 10/10] Sanity check RDMA remote data Dr. David Alan Gilbert (git)
2015-05-19 18:52   ` Michael R. Hines
2015-05-18 22:01 ` [Qemu-devel] [PATCH 00/10] Remove RDMA migration dependence on RAMBlock offset Michael R. Hines

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1429545445-28216-8-git-send-email-dgilbert@redhat.com \
    --to=dgilbert@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=mrhines@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).