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 04/10] Translate offsets to destination address space
Date: Mon, 20 Apr 2015 16:57:19 +0100	[thread overview]
Message-ID: <1429545445-28216-5-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>

The 'offset' field in RDMACompress and 'current_addr' field
in RDMARegister are commented as being offsets within a particular
RAMBlock, however they appear to actually be offsets within the
ram_addr_t space.

The code currently assumes that the offsets on the source/destination
match, this change removes the need for the assumption for these
structures by translating the addresses into the ram_addr_t space of
the destination host.

Note: An alternative would be to change the fields to actually
take the data they're commented for; this would potentially be
simpler but would break stream compatibility for those cases
that currently work.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 migration/rdma.c | 31 ++++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/migration/rdma.c b/migration/rdma.c
index c3814c5..2c0d11b 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -411,7 +411,7 @@ static void network_to_control(RDMAControlHeader *control)
  */
 typedef struct QEMU_PACKED {
     union QEMU_PACKED {
-        uint64_t current_addr;  /* offset into the ramblock of the chunk */
+        uint64_t current_addr;  /* offset into the ram_addr_t space */
         uint64_t chunk;         /* chunk to lookup if unregistering */
     } key;
     uint32_t current_index; /* which ramblock the chunk belongs to */
@@ -419,8 +419,19 @@ typedef struct QEMU_PACKED {
     uint64_t chunks;            /* how many sequential chunks to register */
 } RDMARegister;
 
-static void register_to_network(RDMARegister *reg)
+static void register_to_network(RDMAContext *rdma, RDMARegister *reg)
 {
+    RDMALocalBlock *local_block;
+    local_block  = &rdma->local_ram_blocks.block[reg->current_index];
+
+    if (local_block->is_ram_block) {
+        /*
+         * current_addr as passed in is an address in the local ram_addr_t
+         * space, we need to translate this for the destination
+         */
+        reg->key.current_addr -= local_block->offset;
+        reg->key.current_addr += rdma->dest_blocks[reg->current_index].offset;
+    }
     reg->key.current_addr = htonll(reg->key.current_addr);
     reg->current_index = htonl(reg->current_index);
     reg->chunks = htonll(reg->chunks);
@@ -436,13 +447,19 @@ static void network_to_register(RDMARegister *reg)
 typedef struct QEMU_PACKED {
     uint32_t value;     /* if zero, we will madvise() */
     uint32_t block_idx; /* which ram block index */
-    uint64_t offset;    /* where in the remote ramblock this chunk */
+    uint64_t offset;    /* Address in remote ram_addr_t space */
     uint64_t length;    /* length of the chunk */
 } RDMACompress;
 
-static void compress_to_network(RDMACompress *comp)
+static void compress_to_network(RDMAContext *rdma, RDMACompress *comp)
 {
     comp->value = htonl(comp->value);
+    /*
+     * comp->offset as passed in is an address in the local ram_addr_t
+     * space, we need to translate this for the destination
+     */
+    comp->offset -= rdma->local_ram_blocks.block[comp->block_idx].offset;
+    comp->offset += rdma->dest_blocks[comp->block_idx].offset;
     comp->block_idx = htonl(comp->block_idx);
     comp->offset = htonll(comp->offset);
     comp->length = htonll(comp->length);
@@ -1288,7 +1305,7 @@ static int qemu_rdma_unregister_waiting(RDMAContext *rdma)
         rdma->total_registrations--;
 
         reg.key.chunk = chunk;
-        register_to_network(&reg);
+        register_to_network(rdma, &reg);
         ret = qemu_rdma_exchange_send(rdma, &head, (uint8_t *) &reg,
                                 &resp, NULL, NULL);
         if (ret < 0) {
@@ -1909,7 +1926,7 @@ retry:
                 trace_qemu_rdma_write_one_zero(chunk, sge.length,
                                                current_index, current_addr);
 
-                compress_to_network(&comp);
+                compress_to_network(rdma, &comp);
                 ret = qemu_rdma_exchange_send(rdma, &head,
                                 (uint8_t *) &comp, NULL, NULL, NULL);
 
@@ -1936,7 +1953,7 @@ retry:
             trace_qemu_rdma_write_one_sendreg(chunk, sge.length, current_index,
                                               current_addr);
 
-            register_to_network(&reg);
+            register_to_network(rdma, &reg);
             ret = qemu_rdma_exchange_send(rdma, &head, (uint8_t *) &reg,
                                     &resp, &reg_result_idx, NULL);
             if (ret < 0) {
-- 
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 ` Dr. David Alan Gilbert (git) [this message]
2015-05-19 18:28   ` [Qemu-devel] [PATCH 04/10] Translate offsets to destination address space 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 ` [Qemu-devel] [PATCH 07/10] Simplify rdma_delete_block and remove it's dependence on the hash Dr. David Alan Gilbert (git)
2015-05-19 18:44   ` 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-5-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).