qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] migration: ensure htab_save_first completes after timeout
@ 2016-02-10 18:20 Jianjun Duan
  2016-02-10 21:12 ` Michael Roth
  2016-02-11  0:43 ` David Gibson
  0 siblings, 2 replies; 3+ messages in thread
From: Jianjun Duan @ 2016-02-10 18:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jianjun Duan, qemu-ppc, mdroth, david

htab_save_first_pass could return without finishing its work due to
timeout. The patch checks if another invocation of it is necessary and
will call it in htab_save_complete if necessary.

Signed-off-by: Jianjun Duan <duanj@linux.vnet.ibm.com>
---
 hw/ppc/spapr.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 6bfb908..f6b6749 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1317,6 +1317,7 @@ static int htab_save_setup(QEMUFile *f, void *opaque)
 static void htab_save_first_pass(QEMUFile *f, sPAPRMachineState *spapr,
                                  int64_t max_ns)
 {
+    bool has_timeout = max_ns != -1;
     int htabslots = HTAB_SIZE(spapr) / HASH_PTE_SIZE_64;
     int index = spapr->htab_save_index;
     int64_t starttime = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
@@ -1350,7 +1351,7 @@ static void htab_save_first_pass(QEMUFile *f, sPAPRMachineState *spapr,
             qemu_put_buffer(f, HPTE(spapr->htab, chunkstart),
                             HASH_PTE_SIZE_64 * n_valid);
 
-            if ((qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) {
+            if (has_timeout && (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) {
                 break;
             }
         }
@@ -1503,6 +1504,9 @@ static int htab_save_complete(QEMUFile *f, void *opaque)
         close(spapr->htab_fd);
         spapr->htab_fd = -1;
     } else {
+        if (spapr->htab_first_pass) {
+            htab_save_first_pass(f, spapr, -1);
+        }
         htab_save_later_pass(f, spapr, -1);
     }
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: ensure htab_save_first completes after timeout
  2016-02-10 18:20 [Qemu-devel] [PATCH] migration: ensure htab_save_first completes after timeout Jianjun Duan
@ 2016-02-10 21:12 ` Michael Roth
  2016-02-11  0:43 ` David Gibson
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Roth @ 2016-02-10 21:12 UTC (permalink / raw)
  To: Jianjun Duan, qemu-devel; +Cc: qemu-ppc, david

Quoting Jianjun Duan (2016-02-10 12:20:40)
> htab_save_first_pass could return without finishing its work due to
> timeout. The patch checks if another invocation of it is necessary and
> will call it in htab_save_complete if necessary.
> 
> Signed-off-by: Jianjun Duan <duanj@linux.vnet.ibm.com>

Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>

> ---
>  hw/ppc/spapr.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 6bfb908..f6b6749 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1317,6 +1317,7 @@ static int htab_save_setup(QEMUFile *f, void *opaque)
>  static void htab_save_first_pass(QEMUFile *f, sPAPRMachineState *spapr,
>                                   int64_t max_ns)
>  {
> +    bool has_timeout = max_ns != -1;
>      int htabslots = HTAB_SIZE(spapr) / HASH_PTE_SIZE_64;
>      int index = spapr->htab_save_index;
>      int64_t starttime = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
> @@ -1350,7 +1351,7 @@ static void htab_save_first_pass(QEMUFile *f, sPAPRMachineState *spapr,
>              qemu_put_buffer(f, HPTE(spapr->htab, chunkstart),
>                              HASH_PTE_SIZE_64 * n_valid);
> 
> -            if ((qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) {
> +            if (has_timeout && (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) {
>                  break;
>              }
>          }
> @@ -1503,6 +1504,9 @@ static int htab_save_complete(QEMUFile *f, void *opaque)
>          close(spapr->htab_fd);
>          spapr->htab_fd = -1;
>      } else {
> +        if (spapr->htab_first_pass) {
> +            htab_save_first_pass(f, spapr, -1);
> +        }
>          htab_save_later_pass(f, spapr, -1);
>      }
> 
> -- 
> 1.9.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: ensure htab_save_first completes after timeout
  2016-02-10 18:20 [Qemu-devel] [PATCH] migration: ensure htab_save_first completes after timeout Jianjun Duan
  2016-02-10 21:12 ` Michael Roth
@ 2016-02-11  0:43 ` David Gibson
  1 sibling, 0 replies; 3+ messages in thread
From: David Gibson @ 2016-02-11  0:43 UTC (permalink / raw)
  To: Jianjun Duan; +Cc: qemu-ppc, qemu-devel, mdroth

[-- Attachment #1: Type: text/plain, Size: 2070 bytes --]

On Wed, Feb 10, 2016 at 10:20:40AM -0800, Jianjun Duan wrote:
> htab_save_first_pass could return without finishing its work due to
> timeout. The patch checks if another invocation of it is necessary and
> will call it in htab_save_complete if necessary.
> 
> Signed-off-by: Jianjun Duan <duanj@linux.vnet.ibm.com>

Looks good, applied to ppc-for-2.6 (with a small fix to remove the
overly long line).

> ---
>  hw/ppc/spapr.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 6bfb908..f6b6749 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1317,6 +1317,7 @@ static int htab_save_setup(QEMUFile *f, void *opaque)
>  static void htab_save_first_pass(QEMUFile *f, sPAPRMachineState *spapr,
>                                   int64_t max_ns)
>  {
> +    bool has_timeout = max_ns != -1;
>      int htabslots = HTAB_SIZE(spapr) / HASH_PTE_SIZE_64;
>      int index = spapr->htab_save_index;
>      int64_t starttime = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
> @@ -1350,7 +1351,7 @@ static void htab_save_first_pass(QEMUFile *f, sPAPRMachineState *spapr,
>              qemu_put_buffer(f, HPTE(spapr->htab, chunkstart),
>                              HASH_PTE_SIZE_64 * n_valid);
>  
> -            if ((qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) {
> +            if (has_timeout && (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) {
>                  break;
>              }
>          }
> @@ -1503,6 +1504,9 @@ static int htab_save_complete(QEMUFile *f, void *opaque)
>          close(spapr->htab_fd);
>          spapr->htab_fd = -1;
>      } else {
> +        if (spapr->htab_first_pass) {
> +            htab_save_first_pass(f, spapr, -1);
> +        }
>          htab_save_later_pass(f, spapr, -1);
>      }
>  

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-11  1:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-10 18:20 [Qemu-devel] [PATCH] migration: ensure htab_save_first completes after timeout Jianjun Duan
2016-02-10 21:12 ` Michael Roth
2016-02-11  0:43 ` David Gibson

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).