qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] spapr: introduce helpers to migrate HPT chunks and the end marker
@ 2017-09-19 14:11 Greg Kurz
  2017-09-20  0:59 ` David Gibson
  0 siblings, 1 reply; 2+ messages in thread
From: Greg Kurz @ 2017-09-19 14:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-ppc, David Gibson, Alexey Kardashevskiy, Thomas Huth

This consolidates some duplicated code in a dedicated helpers.

Signed-off-by: Greg Kurz <groug@kaod.org>
---
v2: - open-code writes for the end marker
---
 hw/ppc/spapr.c |   38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index f680f28a15ea..c18c36da71d6 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1708,6 +1708,23 @@ static int htab_save_setup(QEMUFile *f, void *opaque)
     return 0;
 }
 
+static void htab_save_chunk(QEMUFile *f, sPAPRMachineState *spapr,
+                            int chunkstart, int n_valid, int n_invalid)
+{
+    qemu_put_be32(f, chunkstart);
+    qemu_put_be16(f, n_valid);
+    qemu_put_be16(f, n_invalid);
+    qemu_put_buffer(f, HPTE(spapr->htab, chunkstart),
+                    HASH_PTE_SIZE_64 * n_valid);
+}
+
+static void htab_save_end_marker(QEMUFile *f)
+{
+    qemu_put_be32(f, 0);
+    qemu_put_be16(f, 0);
+    qemu_put_be16(f, 0);
+}
+
 static void htab_save_first_pass(QEMUFile *f, sPAPRMachineState *spapr,
                                  int64_t max_ns)
 {
@@ -1739,11 +1756,7 @@ static void htab_save_first_pass(QEMUFile *f, sPAPRMachineState *spapr,
         if (index > chunkstart) {
             int n_valid = index - chunkstart;
 
-            qemu_put_be32(f, chunkstart);
-            qemu_put_be16(f, n_valid);
-            qemu_put_be16(f, 0);
-            qemu_put_buffer(f, HPTE(spapr->htab, chunkstart),
-                            HASH_PTE_SIZE_64 * n_valid);
+            htab_save_chunk(f, spapr, chunkstart, n_valid, 0);
 
             if (has_timeout &&
                 (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) {
@@ -1805,11 +1818,7 @@ static int htab_save_later_pass(QEMUFile *f, sPAPRMachineState *spapr,
             int n_valid = invalidstart - chunkstart;
             int n_invalid = index - invalidstart;
 
-            qemu_put_be32(f, chunkstart);
-            qemu_put_be16(f, n_valid);
-            qemu_put_be16(f, n_invalid);
-            qemu_put_buffer(f, HPTE(spapr->htab, chunkstart),
-                            HASH_PTE_SIZE_64 * n_valid);
+            htab_save_chunk(f, spapr, chunkstart, n_valid, n_invalid);
             sent += index - chunkstart;
 
             if (!final && (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) {
@@ -1872,10 +1881,7 @@ static int htab_save_iterate(QEMUFile *f, void *opaque)
         rc = htab_save_later_pass(f, spapr, MAX_ITERATION_NS);
     }
 
-    /* End marker */
-    qemu_put_be32(f, 0);
-    qemu_put_be16(f, 0);
-    qemu_put_be16(f, 0);
+    htab_save_end_marker(f);
 
     return rc;
 }
@@ -1915,9 +1921,7 @@ static int htab_save_complete(QEMUFile *f, void *opaque)
     }
 
     /* End marker */
-    qemu_put_be32(f, 0);
-    qemu_put_be16(f, 0);
-    qemu_put_be16(f, 0);
+    htab_save_end_marker(f);
 
     return 0;
 }

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

* Re: [Qemu-devel] [PATCH v2] spapr: introduce helpers to migrate HPT chunks and the end marker
  2017-09-19 14:11 [Qemu-devel] [PATCH v2] spapr: introduce helpers to migrate HPT chunks and the end marker Greg Kurz
@ 2017-09-20  0:59 ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2017-09-20  0:59 UTC (permalink / raw)
  To: Greg Kurz; +Cc: qemu-devel, qemu-ppc, Alexey Kardashevskiy, Thomas Huth

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

On Tue, Sep 19, 2017 at 04:11:07PM +0200, Greg Kurz wrote:
> This consolidates some duplicated code in a dedicated helpers.
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>

Applied to ppc-for-2.11.

> ---
> v2: - open-code writes for the end marker
> ---
>  hw/ppc/spapr.c |   38 +++++++++++++++++++++-----------------
>  1 file changed, 21 insertions(+), 17 deletions(-)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index f680f28a15ea..c18c36da71d6 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1708,6 +1708,23 @@ static int htab_save_setup(QEMUFile *f, void *opaque)
>      return 0;
>  }
>  
> +static void htab_save_chunk(QEMUFile *f, sPAPRMachineState *spapr,
> +                            int chunkstart, int n_valid, int n_invalid)
> +{
> +    qemu_put_be32(f, chunkstart);
> +    qemu_put_be16(f, n_valid);
> +    qemu_put_be16(f, n_invalid);
> +    qemu_put_buffer(f, HPTE(spapr->htab, chunkstart),
> +                    HASH_PTE_SIZE_64 * n_valid);
> +}
> +
> +static void htab_save_end_marker(QEMUFile *f)
> +{
> +    qemu_put_be32(f, 0);
> +    qemu_put_be16(f, 0);
> +    qemu_put_be16(f, 0);
> +}
> +
>  static void htab_save_first_pass(QEMUFile *f, sPAPRMachineState *spapr,
>                                   int64_t max_ns)
>  {
> @@ -1739,11 +1756,7 @@ static void htab_save_first_pass(QEMUFile *f, sPAPRMachineState *spapr,
>          if (index > chunkstart) {
>              int n_valid = index - chunkstart;
>  
> -            qemu_put_be32(f, chunkstart);
> -            qemu_put_be16(f, n_valid);
> -            qemu_put_be16(f, 0);
> -            qemu_put_buffer(f, HPTE(spapr->htab, chunkstart),
> -                            HASH_PTE_SIZE_64 * n_valid);
> +            htab_save_chunk(f, spapr, chunkstart, n_valid, 0);
>  
>              if (has_timeout &&
>                  (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) {
> @@ -1805,11 +1818,7 @@ static int htab_save_later_pass(QEMUFile *f, sPAPRMachineState *spapr,
>              int n_valid = invalidstart - chunkstart;
>              int n_invalid = index - invalidstart;
>  
> -            qemu_put_be32(f, chunkstart);
> -            qemu_put_be16(f, n_valid);
> -            qemu_put_be16(f, n_invalid);
> -            qemu_put_buffer(f, HPTE(spapr->htab, chunkstart),
> -                            HASH_PTE_SIZE_64 * n_valid);
> +            htab_save_chunk(f, spapr, chunkstart, n_valid, n_invalid);
>              sent += index - chunkstart;
>  
>              if (!final && (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) {
> @@ -1872,10 +1881,7 @@ static int htab_save_iterate(QEMUFile *f, void *opaque)
>          rc = htab_save_later_pass(f, spapr, MAX_ITERATION_NS);
>      }
>  
> -    /* End marker */
> -    qemu_put_be32(f, 0);
> -    qemu_put_be16(f, 0);
> -    qemu_put_be16(f, 0);
> +    htab_save_end_marker(f);
>  
>      return rc;
>  }
> @@ -1915,9 +1921,7 @@ static int htab_save_complete(QEMUFile *f, void *opaque)
>      }
>  
>      /* End marker */
> -    qemu_put_be32(f, 0);
> -    qemu_put_be16(f, 0);
> -    qemu_put_be16(f, 0);
> +    htab_save_end_marker(f);
>  
>      return 0;
>  }
> 

-- 
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: 833 bytes --]

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

end of thread, other threads:[~2017-09-20  2:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-19 14:11 [Qemu-devel] [PATCH v2] spapr: introduce helpers to migrate HPT chunks and the end marker Greg Kurz
2017-09-20  0:59 ` 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).