qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael R. Hines" <mrhines@linux.vnet.ibm.com>
To: Isaku Yamahata <yamahata@private.email.ne.jp>
Cc: owasserm@redhat.com, quintela@redhat.com, mrhines@us.ibm.com,
	qemu-devel@nongnu.org, pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH 2/2] rdma: simplify qemu_rdma_register_and_get_keys()
Date: Wed, 18 Sep 2013 11:01:16 -0400	[thread overview]
Message-ID: <5239C03C.3050209@linux.vnet.ibm.com> (raw)
In-Reply-To: <9683795de456be26be098f36807d1d4da3027cd0.1378261891.git.yamahata@private.email.ne.jp>

On 09/03/2013 10:32 PM, Isaku Yamahata wrote:
> Signed-off-by: Isaku Yamahata <yamahata@private.email.ne.jp>
> ---
>   migration-rdma.c |   23 +++++++----------------
>   1 file changed, 7 insertions(+), 16 deletions(-)
>
> diff --git a/migration-rdma.c b/migration-rdma.c
> index db5a908..941c07e 100644
> --- a/migration-rdma.c
> +++ b/migration-rdma.c
> @@ -1128,8 +1128,7 @@ static int qemu_rdma_search_ram_block(RDMAContext *rdma,
>    */
>   static int qemu_rdma_register_and_get_keys(RDMAContext *rdma,
>           RDMALocalBlock *block, uint8_t *host_addr,
> -        uint32_t *lkey, uint32_t *rkey, int chunk,
> -        uint8_t *chunk_start, uint8_t *chunk_end)
> +        uint32_t *lkey, uint32_t *rkey, int chunk)
>   {
>       if (block->mr) {
>           if (lkey) {
> @@ -1155,6 +1154,8 @@ static int qemu_rdma_register_and_get_keys(RDMAContext *rdma,
>        * If 'lkey', then we're the source VM, so grant access only to ourselves.
>        */
>       if (!block->pmr[chunk]) {
> +        uint8_t *chunk_start = ram_chunk_start(block, chunk);
> +        uint8_t *chunk_end = ram_chunk_end(block, chunk);
>           uint64_t len = chunk_end - chunk_start;

NACK. chunk_end cannot be calculated like this for all calls to this 
function.

See below.......

>
>           DDPRINTF("Registering %" PRIu64 " bytes @ %p\n",
> @@ -1849,7 +1850,6 @@ static int qemu_rdma_write_one(QEMUFile *f, RDMAContext *rdma,
>       struct ibv_send_wr *bad_wr;
>       int reg_result_idx, ret, count = 0;
>       uint64_t chunk, chunks;
> -    uint8_t *chunk_start, *chunk_end;
>       RDMALocalBlock *block = &(rdma->local_ram_blocks.block[current_index]);
>       RDMARegister reg;
>       RDMARegisterResult *reg_result;
> @@ -1865,7 +1865,6 @@ retry:
>       sge.length = length;
>
>       chunk = ram_chunk_index(block->local_host_addr, (uint8_t *) sge.addr);
> -    chunk_start = ram_chunk_start(block, chunk);
>
>       if (block->is_ram_block) {
>           chunks = length / (1UL << RDMA_REG_CHUNK_SHIFT);
> @@ -1884,8 +1883,6 @@ retry:
>       DDPRINTF("Writing %" PRIu64 " chunks, (%" PRIu64 " MB)\n",
>           chunks + 1, (chunks + 1) * (1UL << RDMA_REG_CHUNK_SHIFT) / 1024 / 1024);
>
> -    chunk_end = ram_chunk_end(block, chunk + chunks);
> -

NACK.

The value of chunk_end changes based on whether or not the value of 
block->is_ram_block is true of false.

>       if (!rdma->pin_all) {
>   #ifdef RDMA_UNREGISTRATION_EXAMPLE
>           qemu_rdma_unregister_waiting(rdma);
> @@ -1974,8 +1971,7 @@ retry:
>               /* try to overlap this single registration with the one we sent. */
>               if (qemu_rdma_register_and_get_keys(rdma, block,
>                                                   (uint8_t *) sge.addr,
> -                                                &sge.lkey, NULL, chunk,
> -                                                chunk_start, chunk_end)) {
> +                                                &sge.lkey, NULL, chunk)) {
>                   fprintf(stderr, "cannot get lkey!\n");
>                   return -EINVAL;
>               }
> @@ -1995,8 +1991,7 @@ retry:
>               /* already registered before */
>               if (qemu_rdma_register_and_get_keys(rdma, block,
>                                                   (uint8_t *)sge.addr,
> -                                                &sge.lkey, NULL, chunk,
> -                                                chunk_start, chunk_end)) {
> +                                                &sge.lkey, NULL, chunk)) {
>                   fprintf(stderr, "cannot get lkey!\n");
>                   return -EINVAL;
>               }
> @@ -2007,8 +2002,7 @@ retry:
>           send_wr.wr.rdma.rkey = block->remote_rkey;
>
>           if (qemu_rdma_register_and_get_keys(rdma, block, (uint8_t *)sge.addr,
> -                                                     &sge.lkey, NULL, chunk,
> -                                                     chunk_start, chunk_end)) {
> +                                                     &sge.lkey, NULL, chunk)) {
>               fprintf(stderr, "cannot get lkey!\n");
>               return -EINVAL;
>           }
> @@ -3054,7 +3048,6 @@ static int qemu_rdma_registration_handle(QEMUFile *f, void *opaque,
>
>               for (count = 0; count < head.repeat; count++) {
>                   uint64_t chunk;
> -                uint8_t *chunk_start, *chunk_end;
>
>                   reg = &registers[count];
>                   network_to_register(reg);
> @@ -3076,11 +3069,9 @@ static int qemu_rdma_registration_handle(QEMUFile *f, void *opaque,
>                       host_addr = block->local_host_addr +
>                           (reg->key.chunk * (1UL << RDMA_REG_CHUNK_SHIFT));
>                   }
> -                chunk_start = ram_chunk_start(block, chunk);
> -                chunk_end = ram_chunk_end(block, chunk + reg->chunks);
>                   if (qemu_rdma_register_and_get_keys(rdma, block,
>                               (uint8_t *)host_addr, NULL, &reg_result->rkey,
> -                            chunk, chunk_start, chunk_end)) {
> +                            chunk)) {
>                       fprintf(stderr, "cannot get rkey!\n");
>                       ret = -EINVAL;
>                       goto out;

  parent reply	other threads:[~2013-09-18 15:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-04  2:32 [Qemu-devel] [PATCH 1/2] rdma: constify ram_chunk_{index, start, end} Isaku Yamahata
2013-09-04  2:32 ` [Qemu-devel] [PATCH 2/2] rdma: simplify qemu_rdma_register_and_get_keys() Isaku Yamahata
2013-09-18 13:00   ` Juan Quintela
2013-09-18 15:01   ` Michael R. Hines [this message]
2013-09-20 16:59     ` Isaku Yamahata
2013-09-20 17:44       ` Michael R. Hines
2013-09-18 12:55 ` [Qemu-devel] [PATCH 1/2] rdma: constify ram_chunk_{index, start, end} Juan Quintela
2013-09-18 14:28 ` Michael R. Hines
2013-09-20  7:55   ` Isaku Yamahata
2013-09-20 14:11     ` Michael R. Hines
2013-09-24 16:36       ` Juan Quintela
2013-09-24 17:21         ` Michael R. Hines
2013-09-24 17:38           ` Juan Quintela
2013-09-24 17:44             ` 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=5239C03C.3050209@linux.vnet.ibm.com \
    --to=mrhines@linux.vnet.ibm.com \
    --cc=mrhines@us.ibm.com \
    --cc=owasserm@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=yamahata@private.email.ne.jp \
    /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).