Skip to contentSkip to conversation

libxc: checkpoint compression

PATCH Superseded [email protected] 3 participants 7 messages Oct 19, 2011 – Nov 2, 2011 Arm/actions semi architecture

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 libxc: checkpoint compression

This patch series adds checkpoint compression functionality, while running under Remus.

Tested under xen-4.2-unstable.

A simple benchmark: SpecJBB (Java Benchmark)
- 4 minute Remus run, with PV domU (2.6.32 xenolinux kernel), 1G memory and 2 VCPUs
- Data sent without compression: ~70GB.
- Data sent with compression: ~8GB.

Changes since last version:
1. Added some more sanity checks and bounds check to the decompression code.
2. Bit of code cleanup.
3. Merged the wire protocol documentation and the libxc compression patch
4. Added comments to xc_domain_save.c, explaining the use of two outbufs.

Shriram

#1 lore raw

PATCH v4 1/1 tools/libxc: Remus Checkpoint Compression

# HG changeset patch
# User Shriram Rajagopalan <[email protected]> # Date 1319049367 25200
# Node ID 64d6b8a65a7ed4939fef93d44ea5199efc9c127a # Parent 4b0907c6a08c348962bd976c2976257b412408be tools/libxc: Remus Checkpoint Compression

Instead of sending dirty pages of guest memory as-is, use a simple compression algorithm that sends a RLE-encoded XOR of the page against its last sent copy. A small LRU cache is used to hold recently dirtied pages. Pagetable pages are sent as-is, as they are canonicalized at sender side and uncanonicalized at receiver.

tools/libxc/Makefile +1 -1
diff -r 4b0907c6a08c -r 64d6b8a65a7e tools/libxc/Makefile
@@ -42,7 +42,7 @@
 GUEST_SRCS-y :=
 GUEST_SRCS-y += xg_private.c xc_suspend.c
 GUEST_SRCS-$(CONFIG_MIGRATE) += xc_domain_restore.c xc_domain_save.c
-GUEST_SRCS-$(CONFIG_MIGRATE) += xc_offline_page.c
+GUEST_SRCS-$(CONFIG_MIGRATE) += xc_offline_page.c xc_compression.c
 GUEST_SRCS-$(CONFIG_HVM) += xc_hvm_build.c
 
 vpath %.c ../../xen/common/libelf
tools/libxc/xc_compression.c new file +551 -0

551 lines not on this page · raw message

tools/libxc/xc_domain_restore.c +72 -1

133 lines not on this page · raw message

tools/libxc/xc_domain_save.c +210 -8

302 lines not on this page · raw message

tools/libxc/xenctrl.h +60 -0

64 lines not on this page · raw message

tools/libxc/xenguest.h +1 -0
diff -r 4b0907c6a08c -r 64d6b8a65a7e tools/libxc/xenguest.h
@@ -27,6 +27,7 @@
 #define XCFLAGS_DEBUG     2
 #define XCFLAGS_HVM       4
 #define XCFLAGS_STDVGA    8
+#define XCFLAGS_CHECKPOINT_COMPRESS    16
 #define X86_64_B_SIZE   64 
 #define X86_32_B_SIZE   32
 
tools/libxc/xg_save_restore.h +119 -1

138 lines not on this page · raw message

#2 lore raw

Re: [PATCH 1 of 2 V4] tools/libxc: Remus Checkpoint Compression

Quoted 9 lines · On Wed, Oct 19, 2011 at 7:50 PM, <[email protected]> wrote:

+    /* Without checkpoint compression, the dirty pages, pfn arrays
+     * and tailbuf (vcpu ctx, shared info page, etc.)  are written
+     * directly to outbuf. All of this is done while the domain is
+     * suspended.
+     *
+     * When checkpoint compression is enabled, the dirty pages are
+     * buffered, compressed "after" the domain is resumed and then
+     * written to outbuf. Since tailbuf data are collected while a
+     * domain is suspended, they cannot be directly written to the

Quoted 8 lines

+     * outbuf as there is no dirty page data preceeding tailbuf.
+     *
+     * So,two output buffers are maintained. Tailbuf data goes into
+     * ob_tailbuf. The dirty pages are compressed after resuming the
+     * domain and written to ob_pagebuf. ob_tailbuf is then appended
+     * to ob_pagebuf and finally flushed out.
+     */
+    struct outbuf ob_pagebuf, ob_tailbuf, *ob = NULL;

Thanks, that's very helpful.

I don't have any more objections / comments.

-George

#3 lore raw

PATCH v4 1/1 remus: command line switch to enable/disable checkpoint compression

In reply to [email protected]

# HG changeset patch
# User Shriram Rajagopalan <[email protected]>
# Date 1319049481 25200
# Node ID c043f91da30401c96c1e7aeca40645fc8afde5bb
# Parent 64d6b8a65a7ed4939fef93d44ea5199efc9c127a
remus: command line switch to enable/disable checkpoint compression

Add a command line switch to remus script that allows the user to enable or disable checkpoint compression in the libxc code.

tools/python/xen/lowlevel/checkpoint/checkpoint.c +4 -3
diff -r 64d6b8a65a7e -r c043f91da304 tools/python/xen/lowlevel/checkpoint/checkpoint.c
@@ -104,13 +104,14 @@
   PyObject* postcopy_cb = NULL;
   PyObject* checkpoint_cb = NULL;
   unsigned int interval = 0;
+  unsigned int flags = 0;
 
   int fd;
   struct save_callbacks callbacks;
   int rc;
 
-  if (!PyArg_ParseTuple(args, "O|OOOI", &iofile, &suspend_cb, &postcopy_cb,
-                       &checkpoint_cb, &interval))
+  if (!PyArg_ParseTuple(args, "O|OOOII", &iofile, &suspend_cb, &postcopy_cb,
+			&checkpoint_cb, &interval, &flags))
     return NULL;
 
   self->interval = interval;
@@ -160,7 +161,7 @@
   callbacks.data = self;
 
   self->threadstate = PyEval_SaveThread();
-  rc = checkpoint_start(&self->cps, fd, &callbacks);
+  rc = checkpoint_start(&self->cps, fd, &callbacks, flags);
   PyEval_RestoreThread(self->threadstate);
 
   if (rc < 0) {
tools/python/xen/lowlevel/checkpoint/checkpoint.h +3 -1
diff -r 64d6b8a65a7e -r c043f91da304 tools/python/xen/lowlevel/checkpoint/checkpoint.h
@@ -40,13 +40,15 @@
     timer_t timer;
 } checkpoint_state;
 
+#define CHECKPOINT_FLAGS_COMPRESSION 1
 char* checkpoint_error(checkpoint_state* s);
 
 void checkpoint_init(checkpoint_state* s);
 int checkpoint_open(checkpoint_state* s, unsigned int domid);
 void checkpoint_close(checkpoint_state* s);
 int checkpoint_start(checkpoint_state* s, int fd,
-                    struct save_callbacks* callbacks);
+		     struct save_callbacks* callbacks,
+		     unsigned int remus_flags);
 int checkpoint_suspend(checkpoint_state* s);
 int checkpoint_resume(checkpoint_state* s);
 int checkpoint_postflush(checkpoint_state* s);
tools/python/xen/lowlevel/checkpoint/libcheckpoint.c +4 -1
diff -r 64d6b8a65a7e -r c043f91da304 tools/python/xen/lowlevel/checkpoint/libcheckpoint.c
@@ -170,7 +170,8 @@
 }
 
 int checkpoint_start(checkpoint_state* s, int fd,
-                    struct save_callbacks* callbacks)
+		     struct save_callbacks* callbacks,
+		     unsigned int remus_flags)
 {
     int hvm, rc;
     int flags = XCFLAGS_LIVE;
@@ -188,6 +189,8 @@
        if (switch_qemu_logdirty(s, 1))
            return -1;
     }
+    if (remus_flags & CHECKPOINT_FLAGS_COMPRESSION)
+      flags |= XCFLAGS_CHECKPOINT_COMPRESS;
 
     callbacks->switch_qemu_logdirty = noop_switch_logdirty;
 
tools/python/xen/remus/save.py +5 -2
diff -r 64d6b8a65a7e -r c043f91da304 tools/python/xen/remus/save.py
@@ -133,7 +133,7 @@
 
 class Saver(object):
     def __init__(self, domid, fd, suspendcb=None, resumecb=None,
-                 checkpointcb=None, interval=0):
+                 checkpointcb=None, interval=0, flags=0):
         """Create a Saver object for taking guest checkpoints.
         domid:        name, number or UUID of a running domain
         fd:           a stream to which checkpoint data will be written.
@@ -141,12 +141,14 @@
         resumecb:     callback invoked before guest resumes
         checkpointcb: callback invoked when a checkpoint is complete. Return
                       True to take another checkpoint, or False to stop.
+        flags:        Remus flags to be passed to xc_domain_save
         """
         self.fd = fd
         self.suspendcb = suspendcb
         self.resumecb = resumecb
         self.checkpointcb = checkpointcb
         self.interval = interval
+        self.flags = flags
 
         self.vm = vm.VM(domid)
 
@@ -164,7 +166,8 @@
             try:
                 self.checkpointer.open(self.vm.domid)
                 self.checkpointer.start(self.fd, self.suspendcb, self.resumecb,
-                                        self.checkpointcb, self.interval)
+                                        self.checkpointcb, self.interval,
+                                        self.flags)
             except xen.lowlevel.checkpoint.error, e:
                 raise CheckpointError(e)
         finally:
tools/remus/remus +9 -1
diff -r 64d6b8a65a7e -r c043f91da304 tools/remus/remus
@@ -16,6 +16,9 @@
 class CfgException(Exception): pass
 
 class Cfg(object):
+
+    REMUS_FLAGS_COMPRESSION = 1
+
     def __init__(self):
         # must be set
         self.domid = 0
@@ -25,6 +28,7 @@
         self.port = XendOptions.instance().get_xend_relocation_port()
         self.interval = 200
         self.netbuffer = True
+        self.flags = self.REMUS_FLAGS_COMPRESSION
         self.timer = False
 
         parser = optparse.OptionParser()
@@ -38,6 +42,8 @@
                           help='replicate to /dev/null (no disk checkpoints, only memory & net buffering)')
         parser.add_option('', '--no-net', dest='nonet', action='store_true',
                           help='run without net buffering (benchmark option)')
+        parser.add_option('', '--no-compression', dest='nocompress', action='store_true',
+                          help='run without checkpoint compression')
         parser.add_option('', '--timer', dest='timer', action='store_true',
                           help='force pause at checkpoint interval (experimental)')
         self.parser = parser
@@ -56,6 +62,8 @@
             self.nullremus = True
         if opts.nonet:
             self.netbuffer = False
+        if opts.nocompress:
+            self.flags &= ~self.REMUS_FLAGS_COMPRESSION
         if opts.timer:
             self.timer = True
 
@@ -190,7 +198,7 @@
     rc = 0
 
     checkpointer = save.Saver(cfg.domid, fd, postsuspend, preresume, commit,
-                              interval)
+                              interval, cfg.flags)
 
     try:
         checkpointer.start()
#4 lore raw
In reply to [email protected]

Ian, do you have any other comments ?

thanks
shriram

Quoted 18 lines · On Wed, Oct 19, 2011 at 11:50 AM, <[email protected]> wrote:

This patch series adds checkpoint compression functionality, while running under Remus.

Tested under xen-4.2-unstable.

A simple benchmark: SpecJBB (Java Benchmark)
- 4 minute Remus run, with PV domU (2.6.32 xenolinux kernel), 1G memory and 2 VCPUs
- Data sent without compression: ~70GB.
- Data sent with compression: ~8GB.

Changes since last version:
1. Added some more sanity checks and bounds check to the decompression code.
2. Bit of code cleanup.
3. Merged the wire protocol documentation and the libxc compression patch
4. Added comments to xc_domain_save.c, explaining the use of two outbufs.

Quoted 7 lines

Shriram

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#5 lore raw

Shriram Rajagopalan writes ("Re: [Xen-devel] [PATCH 0 of 2 V4] libxc: checkpoint compression"):

Quoted 1 line

Ian, do you have any other comments ?

No, I didn't, and tried to apply it. Unfortunately my test build failed - see my other mail.

Thanks,
Ian.

#6 lore raw
In reply to [email protected]

[email protected] writes ("[Xen-devel] [PATCH 0 of 2 V4] libxc: checkpoint compression"):

Quoted 2 lines

This patch series adds checkpoint compression functionality, while running under Remus.

Thanks. I tried to apply this but it broke the stubdom build:

cc1: warnings being treated as errors
xc_compression.c: In function 'xc_compression_create_context':
xc_compression.c:487: error: implicit declaration of function 'posix_memalign' make[3]: *** [xc_compression.o] Error 1
make[3]: Leaving directory `/u/iwj/work/xen-unstable-tools.hg/stubdom/libxc-x86_32' make[2]: *** [build] Error 2
make[2]: Leaving directory `/u/iwj/work/xen-unstable-tools.hg/stubdom/libxc-x86_32' make[1]: *** [libxc-x86_32/libxenctrl.a] Error 2
make[1]: Leaving directory `/u/iwj/work/xen-unstable-tools.hg/stubdom'
make: *** [install-stubdom] Error 2

I think you may need to #ifdef some of the code, or somehow provide posix_memalign in stubdom.

Ian.