From: junyan.he@gmx.com
To: qemu-devel@nongnu.org
Cc: ehabkost@redhat.com, imammedo@redhat.com, pbonzini@redhat.com,
crosthwaite.peter@gmail.com, rth@twiddle.net,
xiaoguangrong.eric@gmail.com, mst@redhat.com,
quintela@redhat.com, dgilbert@redhat.com, stefanha@redhat.com,
Junyan He <junyan.he@intel.com>,
Haozhong Zhang <haozhong.zhang@intel.com>
Subject: [Qemu-devel] [PATCH 8/9 V5] migration/ram: ensure write persistence on loading xbzrle pages to PMEM
Date: Thu, 10 May 2018 10:08:57 +0800 [thread overview]
Message-ID: <1525918138-6189-9-git-send-email-junyan.he@gmx.com> (raw)
In-Reply-To: <1525918138-6189-1-git-send-email-junyan.he@gmx.com>
From: Junyan He <junyan.he@intel.com>
When loading a xbzrle encoded page to persistent memory, load the data
via libpmem function pmem_memcpy_nodrain() instead of memcpy().
Combined with a call to pmem_drain() at the end of memory loading, we
can guarantee those xbzrle encoded pages are persistently loaded to PMEM.
Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
---
migration/ram.c | 6 +++---
migration/xbzrle.c | 8 ++++++--
migration/xbzrle.h | 3 ++-
tests/Makefile.include | 2 +-
tests/test-xbzrle.c | 4 ++--
5 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index e0f3dbc..afe227e 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2441,7 +2441,7 @@ static void ram_save_pending(QEMUFile *f, void *opaque, uint64_t max_size,
}
}
-static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host)
+static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host, bool is_pmem)
{
unsigned int xh_len;
int xh_flags;
@@ -2467,7 +2467,7 @@ static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host)
/* decode RLE */
if (xbzrle_decode_buffer(loaded_data, xh_len, host,
- TARGET_PAGE_SIZE) == -1) {
+ TARGET_PAGE_SIZE, is_pmem) == -1) {
error_report("Failed to load XBZRLE page - decode error!");
return -1;
}
@@ -3083,7 +3083,7 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
break;
case RAM_SAVE_FLAG_XBZRLE:
- if (load_xbzrle(f, addr, host) < 0) {
+ if (load_xbzrle(f, addr, host, is_pmem) < 0) {
error_report("Failed to decompress XBZRLE page at "
RAM_ADDR_FMT, addr);
ret = -EINVAL;
diff --git a/migration/xbzrle.c b/migration/xbzrle.c
index 1ba482d..ca713c3 100644
--- a/migration/xbzrle.c
+++ b/migration/xbzrle.c
@@ -12,6 +12,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/cutils.h"
+#include "qemu/pmem.h"
#include "xbzrle.h"
/*
@@ -126,11 +127,14 @@ int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen,
return d;
}
-int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen)
+int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen,
+ bool is_pmem)
{
int i = 0, d = 0;
int ret;
uint32_t count = 0;
+ void *(*memcpy_func)(void *d, const void *s, size_t n) =
+ is_pmem ? pmem_memcpy_nodrain : memcpy;
while (i < slen) {
@@ -167,7 +171,7 @@ int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen)
return -1;
}
- memcpy(dst + d, src + i, count);
+ memcpy_func(dst + d, src + i, count);
d += count;
i += count;
}
diff --git a/migration/xbzrle.h b/migration/xbzrle.h
index a0db507..f18f679 100644
--- a/migration/xbzrle.h
+++ b/migration/xbzrle.h
@@ -17,5 +17,6 @@
int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen,
uint8_t *dst, int dlen);
-int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen);
+int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen,
+ bool is_pmem);
#endif
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 5c25b9b..23d7162 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -631,7 +631,7 @@ tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(test-block-obj-y)
tests/test-iov$(EXESUF): tests/test-iov.o $(test-util-obj-y)
tests/test-hbitmap$(EXESUF): tests/test-hbitmap.o $(test-util-obj-y) $(test-crypto-obj-y)
tests/test-x86-cpuid$(EXESUF): tests/test-x86-cpuid.o
-tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o migration/xbzrle.o migration/page_cache.o $(test-util-obj-y)
+tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o migration/xbzrle.o migration/page_cache.o stubs/pmem.o $(test-util-obj-y)
tests/test-cutils$(EXESUF): tests/test-cutils.o util/cutils.o $(test-util-obj-y)
tests/test-int128$(EXESUF): tests/test-int128.o
tests/rcutorture$(EXESUF): tests/rcutorture.o $(test-util-obj-y)
diff --git a/tests/test-xbzrle.c b/tests/test-xbzrle.c
index f5e08de..9afa0c4 100644
--- a/tests/test-xbzrle.c
+++ b/tests/test-xbzrle.c
@@ -101,7 +101,7 @@ static void test_encode_decode_1_byte(void)
PAGE_SIZE);
g_assert(dlen == (uleb128_encode_small(&buf[0], 4095) + 2));
- rc = xbzrle_decode_buffer(compressed, dlen, buffer, PAGE_SIZE);
+ rc = xbzrle_decode_buffer(compressed, dlen, buffer, PAGE_SIZE, false);
g_assert(rc == PAGE_SIZE);
g_assert(memcmp(test, buffer, PAGE_SIZE) == 0);
@@ -156,7 +156,7 @@ static void encode_decode_range(void)
dlen = xbzrle_encode_buffer(test, buffer, PAGE_SIZE, compressed,
PAGE_SIZE);
- rc = xbzrle_decode_buffer(compressed, dlen, test, PAGE_SIZE);
+ rc = xbzrle_decode_buffer(compressed, dlen, test, PAGE_SIZE, false);
g_assert(rc < PAGE_SIZE);
g_assert(memcmp(test, buffer, PAGE_SIZE) == 0);
--
2.7.4
next prev parent reply other threads:[~2018-05-10 2:09 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-10 2:08 [Qemu-devel] [PATCH V5 0/9] nvdimm: guarantee persistence of QEMU writes to persistent memory junyan.he
2018-05-10 2:08 ` [Qemu-devel] [PATCH 1/9 V5] memory, exec: switch file ram allocation functions to 'flags' parameters junyan.he
2018-05-10 21:08 ` Murilo Opsfelder Araujo
2018-05-11 7:20 ` Junyan He
2018-05-31 12:46 ` Stefan Hajnoczi
2018-05-10 2:08 ` [Qemu-devel] [PATCH 2/9 V5] hostmem-file: add the 'pmem' option junyan.he
2018-05-31 12:35 ` Stefan Hajnoczi
2018-05-31 13:09 ` Stefan Hajnoczi
2018-06-01 5:14 ` Junyan He
2018-05-10 2:08 ` [Qemu-devel] [PATCH 3/9 V5] configure: add libpmem support junyan.he
2018-05-31 12:54 ` Stefan Hajnoczi
2018-05-10 2:08 ` [Qemu-devel] [PATCH 4/9 V5] mem/nvdimm: ensure write persistence to PMEM in label emulation junyan.he
2018-05-10 2:08 ` [Qemu-devel] [PATCH 5/9 V5] migration/ram: ensure write persistence on loading zero pages to PMEM junyan.he
2018-05-10 2:08 ` [Qemu-devel] [PATCH 6/9 V5] migration/ram: ensure write persistence on loading normal " junyan.he
2018-05-10 2:08 ` [Qemu-devel] [PATCH 7/9 V5] migration/ram: ensure write persistence on loading compressed " junyan.he
2018-05-10 2:08 ` junyan.he [this message]
2018-05-10 2:08 ` [Qemu-devel] [PATCH 9/9 V5] migration/ram: Add check and info message to nvdimm post copy junyan.he
2018-05-10 2:21 ` [Qemu-devel] [PATCH V5 0/9] nvdimm: guarantee persistence of QEMU writes to persistent memory He, Junyan
2018-05-10 2:22 ` no-reply
2018-05-21 3:19 ` Junyan He
2018-05-28 5:26 ` Junyan He
2018-05-31 13:18 ` Stefan Hajnoczi
2018-05-31 14:28 ` Dr. David Alan Gilbert
2018-05-31 14:36 ` Junyan He
2018-05-31 14:42 ` Dr. David Alan Gilbert
2018-05-31 15:04 ` Junyan He
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=1525918138-6189-9-git-send-email-junyan.he@gmx.com \
--to=junyan.he@gmx.com \
--cc=crosthwaite.peter@gmail.com \
--cc=dgilbert@redhat.com \
--cc=ehabkost@redhat.com \
--cc=haozhong.zhang@intel.com \
--cc=imammedo@redhat.com \
--cc=junyan.he@intel.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=rth@twiddle.net \
--cc=stefanha@redhat.com \
--cc=xiaoguangrong.eric@gmail.com \
/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).