All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>,
	"Juergen Gross" <jgross@suse.com>,
	"George Dunlap" <george.dunlap@citrix.com>,
	"Ian Jackson" <iwj@xenproject.org>
Subject: [PATCH v2 04/13] libxenguest: short-circuit "all-dirty" handling
Date: Mon, 5 Jul 2021 17:13:50 +0200	[thread overview]
Message-ID: <709a0dc1-bb68-4f06-b73b-fbefaa661c77@suse.com> (raw)
In-Reply-To: <0bebfe8c-6897-dc8b-7fe0-9127d4996eb8@suse.com>

For one it is unnecessary to fill a perhaps large chunk of memory with
all ones. Add a new parameter to send_dirty_pages() for callers to
indicate so.

Then it is further unnecessary to allocate the dirty bitmap altogether
when all that's ever going to happen is a single all-dirty run.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/tools/libs/guest/xg_sr_save.c
+++ b/tools/libs/guest/xg_sr_save.c
@@ -368,7 +368,7 @@ static int suspend_domain(struct xc_sr_c
  * Bitmap is bounded by p2m_size.
  */
 static int send_dirty_pages(struct xc_sr_context *ctx,
-                            unsigned long entries)
+                            unsigned long entries, bool all_dirty)
 {
     xc_interface *xch = ctx->xch;
     xen_pfn_t p;
@@ -379,7 +379,7 @@ static int send_dirty_pages(struct xc_sr
 
     for ( p = 0, written = 0; p < ctx->save.p2m_size; ++p )
     {
-        if ( !test_bit(p, dirty_bitmap) )
+        if ( !all_dirty && !test_bit(p, dirty_bitmap) )
             continue;
 
         rc = add_to_batch(ctx, p);
@@ -411,12 +411,7 @@ static int send_dirty_pages(struct xc_sr
  */
 static int send_all_pages(struct xc_sr_context *ctx)
 {
-    DECLARE_HYPERCALL_BUFFER_SHADOW(unsigned long, dirty_bitmap,
-                                    &ctx->save.dirty_bitmap_hbuf);
-
-    bitmap_set(dirty_bitmap, ctx->save.p2m_size);
-
-    return send_dirty_pages(ctx, ctx->save.p2m_size);
+    return send_dirty_pages(ctx, ctx->save.p2m_size, true /* all_dirty */);
 }
 
 static int enable_logdirty(struct xc_sr_context *ctx)
@@ -508,9 +503,6 @@ static int send_memory_live(struct xc_sr
     int rc;
     int policy_decision;
 
-    DECLARE_HYPERCALL_BUFFER_SHADOW(unsigned long, dirty_bitmap,
-                                    &ctx->save.dirty_bitmap_hbuf);
-
     precopy_policy_t precopy_policy = ctx->save.callbacks->precopy_policy;
     void *data = ctx->save.callbacks->data;
 
@@ -528,8 +520,6 @@ static int send_memory_live(struct xc_sr
     if ( precopy_policy == NULL )
         precopy_policy = simple_precopy_policy;
 
-    bitmap_set(dirty_bitmap, ctx->save.p2m_size);
-
     for ( ; ; )
     {
         policy_decision = precopy_policy(*policy_stats, data);
@@ -541,7 +531,7 @@ static int send_memory_live(struct xc_sr
             if ( rc )
                 goto out;
 
-            rc = send_dirty_pages(ctx, stats.dirty_count);
+            rc = send_dirty_pages(ctx, stats.dirty_count, x == 1);
             if ( rc )
                 goto out;
         }
@@ -687,7 +677,8 @@ static int suspend_and_send_dirty(struct
         }
     }
 
-    rc = send_dirty_pages(ctx, stats.dirty_count + ctx->save.nr_deferred_pages);
+    rc = send_dirty_pages(ctx, stats.dirty_count + ctx->save.nr_deferred_pages,
+                          false /* all_dirty */);
     if ( rc )
         goto out;
 
@@ -807,8 +798,11 @@ static int setup(struct xc_sr_context *c
     if ( rc )
         goto err;
 
-    dirty_bitmap = xc_hypercall_buffer_alloc_pages(
-        xch, dirty_bitmap, NRPAGES(bitmap_size(ctx->save.p2m_size)));
+    dirty_bitmap = ctx->save.live || ctx->stream_type != XC_STREAM_PLAIN
+        ? xc_hypercall_buffer_alloc_pages(
+              xch, dirty_bitmap, NRPAGES(bitmap_size(ctx->save.p2m_size)))
+        : (void *)-1L;
+
     ctx->save.batch_pfns = malloc(MAX_BATCH_SIZE *
                                   sizeof(*ctx->save.batch_pfns));
     ctx->save.deferred_pages = bitmap_alloc(ctx->save.p2m_size);



  parent reply	other threads:[~2021-07-05 15:14 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-05 15:09 [PATCH v2 00/13] x86: more or less log-dirty related improvements Jan Beulich
2021-07-05 15:11 ` [PATCH v2 01/13] libxl/x86: check return value of SHADOW_OP_SET_ALLOCATION domctl Jan Beulich
2021-07-16 13:03   ` Anthony PERARD
2021-07-05 15:12 ` [PATCH v2 02/13] libxc: split xc_logdirty_control() from xc_shadow_control() Jan Beulich
2021-08-19  9:11   ` Juergen Gross
2021-08-19  9:24     ` Jan Beulich
2021-08-19  9:50       ` Juergen Gross
2021-09-02 17:04         ` [PATCH v2 02/13] libxc: split xc_logdirty_control() from xc_shadow_control() [and 1 more messages] Ian Jackson
2021-07-05 15:13 ` [PATCH v2 03/13] libxenguest: deal with log-dirty op stats overflow Jan Beulich
2021-07-05 15:41   ` Andrew Cooper
2021-07-05 15:53     ` Jan Beulich
2021-07-05 17:26   ` Olaf Hering
2021-07-06  6:39     ` Jan Beulich
2021-07-06  6:46       ` Olaf Hering
2021-07-06  6:58         ` Jan Beulich
2021-07-06  7:15           ` Olaf Hering
2021-08-19 10:20   ` Juergen Gross
2021-08-19 11:06     ` Jan Beulich
2021-08-19 11:25       ` Juergen Gross
2021-08-19 11:51         ` Jan Beulich
2021-08-19 11:53           ` Jan Beulich
2021-09-02 16:57             ` Ian Jackson
2021-08-19 14:29           ` Juergen Gross
2021-07-05 15:13 ` Jan Beulich [this message]
2021-08-19 14:21   ` [PATCH v2 04/13] libxenguest: short-circuit "all-dirty" handling Juergen Gross
2021-07-05 15:14 ` [PATCH v2 05/13] libxenguest: avoid allocating unused deferred-pages bitmap Jan Beulich
2021-08-19 14:22   ` Juergen Gross
2021-07-05 15:14 ` [PATCH v2 06/13] libxenguest: complete loops in xc_map_domain_meminfo() Jan Beulich
2021-07-05 15:15 ` [PATCH v2 07/13] libxenguest: guard against overflow from too large p2m when checkpointing Jan Beulich
2021-07-05 15:15 ` [PATCH v2 08/13] libxenguest: fix off-by-1 in colo-secondary-bitmap merging Jan Beulich
2021-07-05 15:15 ` [PATCH v2 09/13] libxenguest: restrict PV guest size Jan Beulich
2021-07-05 15:16 ` [PATCH v2 10/13] libxc: simplify HYPERCALL_BUFFER() Jan Beulich
2021-07-05 15:47   ` Andrew Cooper
2021-07-05 15:17 ` [PATCH v2 11/13] x86/paging: supply more useful log-dirty page count Jan Beulich
2021-07-05 15:18 ` [PATCH v2 12/13] x86/mm: update log-dirty bitmap when manipulating P2M Jan Beulich
2021-07-05 15:18 ` [PATCH v2 13/13] SUPPORT.md: write down restriction of 32-bit tool stacks Jan Beulich
2021-07-14 18:16   ` Julien Grall
2021-07-15  6:38     ` Jan Beulich
2021-07-15  9:05       ` Julien Grall
2021-07-15 11:36         ` Jan Beulich
2021-07-16  7:50           ` Julien Grall
2021-07-19  7:46 ` Ping: [PATCH v2 00/13] x86: more or less log-dirty related improvements Jan Beulich
2021-08-13  9:24   ` Jan Beulich
2021-08-20  7:20   ` Jan Beulich

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=709a0dc1-bb68-4f06-b73b-fbefaa661c77@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=iwj@xenproject.org \
    --cc=jgross@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /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.