All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: "Michael R. Hines" <mrhines@linux.vnet.ibm.com>
Cc: amit.shah@redhat.com, quintela@redhat.com,
	arei.gonglei@huawei.com, qemu-devel@nongnu.org,
	mrhines@us.ibm.com
Subject: Re: [Qemu-devel] [PATCH v2 06/12] Translate offsets to destination address space
Date: Fri, 12 Jun 2015 19:50:35 +0100	[thread overview]
Message-ID: <20150612185034.GF2141@work-vm> (raw)
In-Reply-To: <5579DC91.70002@linux.vnet.ibm.com>

* Michael R. Hines (mrhines@linux.vnet.ibm.com) wrote:
> On 06/11/2015 01:58 PM, Dr. David Alan Gilbert wrote:
> >* Michael R. Hines (mrhines@linux.vnet.ibm.com) wrote:
> >>On 06/11/2015 12:17 PM, Dr. David Alan Gilbert (git) wrote:
> >>>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 9532461..cb66721 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);
> >>So, why add the destination block's offset on the source side
> >>just for it to be re-adjusted again when it gets to the destination side?
> >>
> >>Can you just stop at this:
> >>
> >>+        reg->key.current_addr -= local_block->offset;
> >>
> >>Without this:
> >>
> >>+        reg->key.current_addr +=
> >>rdma->dest_blocks[reg->current_index].offset;
> >>
> >>... on the source, followed by this on the destionation:
> >>
> >>+    comp->offset -= rdma->local_ram_blocks.block[comp->block_idx].offset;
> >>
> >>Without this:
> >>
> >>+    comp->offset += rdma->dest_blocks[comp->block_idx].offset;
> >>
> >>Did I follow correctly?
> >Aren't both of those conversions happening on the source?
> >Anyway, I think what you're saying is that we change the value sent over
> >the network to be an offset within the block instead of an offset in
> >the whole ram_addr_t space (i.e. that's what happens if you don't
> >add back on the dest_blocks[].offset).
> 
> Yes, right. Can you skip adding/subtracting the local block offset on each
> side?

I don't understand how I can do that without changing the wire format so
that it would be subtly incompatible, and I'd like to get 2.1ish migrating to 2.3ish.
If I didn't add the local_block->offset on the source, the value on the wire
would now be the offset within the RAMBlock rather than the offset in ram_addr_t.

Except for compatibility I'd agree it would be simpler.

Dave


> 
> - Michael
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

  reply	other threads:[~2015-06-12 18:50 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-11 17:17 [Qemu-devel] [PATCH v2 00/12] Remove RDMA migration dependence on RAMBlock offset Dr. David Alan Gilbert (git)
2015-06-11 17:17 ` [Qemu-devel] [PATCH v2 01/12] Rename RDMA structures to make destination clear Dr. David Alan Gilbert (git)
2015-07-01  8:36   ` Juan Quintela
2015-06-11 17:17 ` [Qemu-devel] [PATCH v2 02/12] qemu_ram_foreach_block: pass up error value, and down the ramblock name Dr. David Alan Gilbert (git)
2015-07-01  8:36   ` Juan Quintela
2015-06-11 17:17 ` [Qemu-devel] [PATCH v2 03/12] Remove unneeded memset Dr. David Alan Gilbert (git)
2015-07-01  8:37   ` Juan Quintela
2015-06-11 17:17 ` [Qemu-devel] [PATCH v2 04/12] rdma typos Dr. David Alan Gilbert (git)
2015-06-11 17:56   ` Michael R. Hines
2015-06-11 18:37     ` Dr. David Alan Gilbert
2015-07-01  8:37   ` Juan Quintela
2015-06-11 17:17 ` [Qemu-devel] [PATCH v2 05/12] Store block name in local blocks structure Dr. David Alan Gilbert (git)
2015-07-01  8:38   ` Juan Quintela
2015-06-11 17:17 ` [Qemu-devel] [PATCH v2 06/12] Translate offsets to destination address space Dr. David Alan Gilbert (git)
2015-06-11 18:12   ` Michael R. Hines
2015-06-11 18:58     ` Dr. David Alan Gilbert
2015-06-11 19:08       ` Michael R. Hines
2015-06-12 18:50         ` Dr. David Alan Gilbert [this message]
2015-06-12 19:17           ` Michael R. Hines
2015-07-01  8:43   ` Juan Quintela
2015-06-11 17:17 ` [Qemu-devel] [PATCH v2 07/12] Rework ram_control_load_hook to hook during block load Dr. David Alan Gilbert (git)
2015-06-11 18:20   ` Michael R. Hines
2015-06-11 18:44     ` Dr. David Alan Gilbert
2015-07-01  8:47       ` Juan Quintela
2015-07-01  8:49   ` Juan Quintela
2015-07-01  8:51     ` Dr. David Alan Gilbert
2015-06-11 17:17 ` [Qemu-devel] [PATCH v2 08/12] Allow rdma_delete_block to work without the hash Dr. David Alan Gilbert (git)
2015-06-11 18:36   ` Michael R. Hines
2015-06-11 18:39     ` Dr. David Alan Gilbert
2015-06-11 17:17 ` [Qemu-devel] [PATCH v2 09/12] Rework ram block hash Dr. David Alan Gilbert (git)
2015-06-11 18:40   ` Michael R. Hines
2015-06-11 18:45     ` Dr. David Alan Gilbert
2015-06-11 17:17 ` [Qemu-devel] [PATCH v2 10/12] Sort destination RAMBlocks to be the same as the source Dr. David Alan Gilbert (git)
2015-06-11 18:55   ` Michael R. Hines
2015-06-11 17:17 ` [Qemu-devel] [PATCH v2 11/12] Sanity check RDMA remote data Dr. David Alan Gilbert (git)
2015-06-11 17:17 ` [Qemu-devel] [PATCH v2 12/12] Fail more cleanly in mismatched RAM cases Dr. David Alan Gilbert (git)

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=20150612185034.GF2141@work-vm \
    --to=dgilbert@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=mrhines@linux.vnet.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.