From nobody Sun Apr 28 19:00:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531900333724141.59355801580466; Wed, 18 Jul 2018 00:52:13 -0700 (PDT) Received: from localhost ([::1]:35221 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffhFs-0004fl-NN for importer@patchew.org; Wed, 18 Jul 2018 03:52:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffhC7-0001xM-HK for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffhC4-0003YZ-Cc for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:19 -0400 Received: from mga12.intel.com ([192.55.52.136]:63886) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffhC4-0003XX-3E for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:16 -0400 Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jul 2018 00:48:14 -0700 Received: from natrouter.sh.intel.com (HELO robinhe-hp.domain) ([10.239.13.3]) by fmsmga007.fm.intel.com with ESMTP; 18 Jul 2018 00:48:09 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,369,1526367600"; d="scan'208";a="55232096" From: junyan.he@gmx.com To: qemu-devel@nongnu.org Date: Wed, 18 Jul 2018 15:47:57 +0800 Message-Id: <1531900083-18167-2-git-send-email-junyan.he@gmx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531900083-18167-1-git-send-email-junyan.he@gmx.com> References: <1531900083-18167-1-git-send-email-junyan.he@gmx.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.136 Subject: [Qemu-devel] [PATCH 1/7 V11] memory, exec: Expose all memory block related flags. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xiaoguangrong.eric@gmail.com, crosthwaite.peter@gmail.com, mst@redhat.com, dgilbert@redhat.com, ehabkost@redhat.com, quintela@redhat.com, Junyan He , stefanha@redhat.com, pbonzini@redhat.com, imammedo@redhat.com, yi.z.zhang@intel.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Junyan He We need to use these flags in other files rather than just in exec.c, For example, RAM_SHARED should be used when create a ram block from file. We expose them the exec/memory.h Signed-off-by: Junyan He Reviewed-by: Stefan Hajnoczi Reviewed-by: Igor Mammedov Reviewed-by: Richard Henderson --- exec.c | 20 -------------------- include/exec/memory.h | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/exec.c b/exec.c index 4f5df07..cc042dc 100644 --- a/exec.c +++ b/exec.c @@ -87,26 +87,6 @@ AddressSpace address_space_memory; =20 MemoryRegion io_mem_rom, io_mem_notdirty; static MemoryRegion io_mem_unassigned; - -/* RAM is pre-allocated and passed into qemu_ram_alloc_from_ptr */ -#define RAM_PREALLOC (1 << 0) - -/* RAM is mmap-ed with MAP_SHARED */ -#define RAM_SHARED (1 << 1) - -/* Only a portion of RAM (used_length) is actually used, and migrated. - * This used_length size can change across reboots. - */ -#define RAM_RESIZEABLE (1 << 2) - -/* UFFDIO_ZEROPAGE is available on this RAMBlock to atomically - * zero the page and wake waiting processes. - * (Set during postcopy) - */ -#define RAM_UF_ZEROPAGE (1 << 3) - -/* RAM can be migrated */ -#define RAM_MIGRATABLE (1 << 4) #endif =20 #ifdef TARGET_PAGE_BITS_VARY diff --git a/include/exec/memory.h b/include/exec/memory.h index 448d41a..6d0af29 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -103,6 +103,26 @@ struct IOMMUNotifier { }; typedef struct IOMMUNotifier IOMMUNotifier; =20 +/* RAM is pre-allocated and passed into qemu_ram_alloc_from_ptr */ +#define RAM_PREALLOC (1 << 0) + +/* RAM is mmap-ed with MAP_SHARED */ +#define RAM_SHARED (1 << 1) + +/* Only a portion of RAM (used_length) is actually used, and migrated. + * This used_length size can change across reboots. + */ +#define RAM_RESIZEABLE (1 << 2) + +/* UFFDIO_ZEROPAGE is available on this RAMBlock to atomically + * zero the page and wake waiting processes. + * (Set during postcopy) + */ +#define RAM_UF_ZEROPAGE (1 << 3) + +/* RAM can be migrated */ +#define RAM_MIGRATABLE (1 << 4) + static inline void iommu_notifier_init(IOMMUNotifier *n, IOMMUNotify fn, IOMMUNotifierFlag flags, hwaddr start, hwaddr end, --=20 2.7.4 From nobody Sun Apr 28 19:00:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531900214026297.29997851209214; Wed, 18 Jul 2018 00:50:14 -0700 (PDT) Received: from localhost ([::1]:35208 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffhDp-00030o-Ls for importer@patchew.org; Wed, 18 Jul 2018 03:50:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56523) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffhC7-0001xJ-H8 for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffhC4-0003ZX-TB for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:19 -0400 Received: from mga12.intel.com ([192.55.52.136]:63886) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffhC4-0003XX-I2 for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:16 -0400 Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jul 2018 00:48:14 -0700 Received: from natrouter.sh.intel.com (HELO robinhe-hp.domain) ([10.239.13.3]) by fmsmga007.fm.intel.com with ESMTP; 18 Jul 2018 00:48:12 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,369,1526367600"; d="scan'208";a="55232102" From: junyan.he@gmx.com To: qemu-devel@nongnu.org Date: Wed, 18 Jul 2018 15:47:58 +0800 Message-Id: <1531900083-18167-3-git-send-email-junyan.he@gmx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531900083-18167-1-git-send-email-junyan.he@gmx.com> References: <1531900083-18167-1-git-send-email-junyan.he@gmx.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.136 Subject: [Qemu-devel] [PATCH 2/7 V11] memory, exec: switch file ram allocation functions to 'flags' parameters X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Haozhong Zhang , xiaoguangrong.eric@gmail.com, crosthwaite.peter@gmail.com, mst@redhat.com, dgilbert@redhat.com, ehabkost@redhat.com, quintela@redhat.com, Junyan He , stefanha@redhat.com, pbonzini@redhat.com, imammedo@redhat.com, yi.z.zhang@intel.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Junyan He As more flag parameters besides the existing 'share' are going to be added to following functions memory_region_init_ram_from_file qemu_ram_alloc_from_fd qemu_ram_alloc_from_file let's switch them to use the 'flags' parameters so as to ease future flag additions. The existing 'share' flag is converted to the RAM_SHARED bit in ram_flags, and other flag bits are ignored by above functions right now. Signed-off-by: Junyan He Signed-off-by: Haozhong Zhang Reviewed-by: Stefan Hajnoczi Reviewed-by: Igor Mammedov Reviewed-by: Richard Henderson --- backends/hostmem-file.c | 3 ++- exec.c | 10 +++++----- include/exec/memory.h | 7 +++++-- include/exec/ram_addr.h | 25 +++++++++++++++++++++++-- memory.c | 8 +++++--- numa.c | 2 +- 6 files changed, 41 insertions(+), 14 deletions(-) diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index 134b08d..34c68bb 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -58,7 +58,8 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Err= or **errp) path =3D object_get_canonical_path(OBJECT(backend)); memory_region_init_ram_from_file(&backend->mr, OBJECT(backend), path, - backend->size, fb->align, backend->share, + backend->size, fb->align, + backend->share ? RAM_SHARED : 0, fb->mem_path, errp); g_free(path); } diff --git a/exec.c b/exec.c index cc042dc..3b8f914 100644 --- a/exec.c +++ b/exec.c @@ -2238,7 +2238,7 @@ static void ram_block_add(RAMBlock *new_block, Error = **errp, bool shared) =20 #ifdef __linux__ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr, - bool share, int fd, + uint32_t ram_flags, int fd, Error **errp) { RAMBlock *new_block; @@ -2280,14 +2280,14 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, M= emoryRegion *mr, new_block->mr =3D mr; new_block->used_length =3D size; new_block->max_length =3D size; - new_block->flags =3D share ? RAM_SHARED : 0; + new_block->flags =3D ram_flags; new_block->host =3D file_ram_alloc(new_block, size, fd, !file_size, er= rp); if (!new_block->host) { g_free(new_block); return NULL; } =20 - ram_block_add(new_block, &local_err, share); + ram_block_add(new_block, &local_err, ram_flags & RAM_SHARED); if (local_err) { g_free(new_block); error_propagate(errp, local_err); @@ -2299,7 +2299,7 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, Mem= oryRegion *mr, =20 =20 RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr, - bool share, const char *mem_path, + uint32_t ram_flags, const char *mem_pat= h, Error **errp) { int fd; @@ -2311,7 +2311,7 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, M= emoryRegion *mr, return NULL; } =20 - block =3D qemu_ram_alloc_from_fd(size, mr, share, fd, errp); + block =3D qemu_ram_alloc_from_fd(size, mr, ram_flags, fd, errp); if (!block) { if (created) { unlink(mem_path); diff --git a/include/exec/memory.h b/include/exec/memory.h index 6d0af29..30e7166 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -640,6 +640,7 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr, void *host), Error **errp); #ifdef __linux__ + /** * memory_region_init_ram_from_file: Initialize RAM memory region with a * mmap-ed backend. @@ -651,7 +652,9 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr, * @size: size of the region. * @align: alignment of the region base address; if 0, the default alignme= nt * (getpagesize()) will be used. - * @share: %true if memory must be mmaped with the MAP_SHARED flag + * @ram_flags: Memory region features: + * - RAM_SHARED: memory must be mmaped with the MAP_SHARED flag + * Other bits are ignored now. * @path: the path in which to allocate the RAM. * @errp: pointer to Error*, to store an error if it happens. * @@ -663,7 +666,7 @@ void memory_region_init_ram_from_file(MemoryRegion *mr, const char *name, uint64_t size, uint64_t align, - bool share, + uint32_t ram_flags, const char *path, Error **errp); =20 diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index cf4ce06..8a4a9bc 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -71,12 +71,33 @@ static inline unsigned long int ramblock_recv_bitmap_of= fset(void *host_addr, } =20 long qemu_getrampagesize(void); + +/** + * qemu_ram_alloc_from_file, + * qemu_ram_alloc_from_fd: Allocate a ram block from the specified backing + * file or device + * + * Parameters: + * @size: the size in bytes of the ram block + * @mr: the memory region where the ram block is + * @ram_flags: specify the properties of the ram block, which can be one + * or bit-or of following values + * - RAM_SHARED: mmap the backing file or device with MAP_SHA= RED + * Other bits are ignored. + * @mem_path or @fd: specify the backing file or device + * @errp: pointer to Error*, to store an error if it happens + * + * Return: + * On success, return a pointer to the ram block. + * On failure, return NULL. + */ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr, - bool share, const char *mem_path, + uint32_t ram_flags, const char *mem_pat= h, Error **errp); RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr, - bool share, int fd, + uint32_t ram_flags, int fd, Error **errp); + RAMBlock *qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, MemoryRegion *mr, Error **errp); RAMBlock *qemu_ram_alloc(ram_addr_t size, bool share, MemoryRegion *mr, diff --git a/memory.c b/memory.c index e9cd446..d20f0a7 100644 --- a/memory.c +++ b/memory.c @@ -1551,7 +1551,7 @@ void memory_region_init_ram_from_file(MemoryRegion *m= r, const char *name, uint64_t size, uint64_t align, - bool share, + uint32_t ram_flags, const char *path, Error **errp) { @@ -1560,7 +1560,7 @@ void memory_region_init_ram_from_file(MemoryRegion *m= r, mr->terminates =3D true; mr->destructor =3D memory_region_destructor_ram; mr->align =3D align; - mr->ram_block =3D qemu_ram_alloc_from_file(size, mr, share, path, errp= ); + mr->ram_block =3D qemu_ram_alloc_from_file(size, mr, ram_flags, path, = errp); mr->dirty_log_mask =3D tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0; } =20 @@ -1576,7 +1576,9 @@ void memory_region_init_ram_from_fd(MemoryRegion *mr, mr->ram =3D true; mr->terminates =3D true; mr->destructor =3D memory_region_destructor_ram; - mr->ram_block =3D qemu_ram_alloc_from_fd(size, mr, share, fd, errp); + mr->ram_block =3D qemu_ram_alloc_from_fd(size, mr, + share ? RAM_SHARED : 0, + fd, errp); mr->dirty_log_mask =3D tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0; } #endif diff --git a/numa.c b/numa.c index 5f6367b..81542d4 100644 --- a/numa.c +++ b/numa.c @@ -479,7 +479,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion= *mr, Object *owner, if (mem_path) { #ifdef __linux__ Error *err =3D NULL; - memory_region_init_ram_from_file(mr, owner, name, ram_size, 0, fal= se, + memory_region_init_ram_from_file(mr, owner, name, ram_size, 0, 0, mem_path, &err); if (err) { error_report_err(err); --=20 2.7.4 From nobody Sun Apr 28 19:00:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531900206787429.1417608893088; Wed, 18 Jul 2018 00:50:06 -0700 (PDT) Received: from localhost ([::1]:35207 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffhDm-0002sG-Pj for importer@patchew.org; Wed, 18 Jul 2018 03:50:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffhC7-0001xK-HC for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffhC6-0003cQ-44 for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:19 -0400 Received: from mga12.intel.com ([192.55.52.136]:63886) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffhC5-0003XX-Nn for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:18 -0400 Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jul 2018 00:48:17 -0700 Received: from natrouter.sh.intel.com (HELO robinhe-hp.domain) ([10.239.13.3]) by fmsmga007.fm.intel.com with ESMTP; 18 Jul 2018 00:48:14 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,369,1526367600"; d="scan'208";a="55232108" From: junyan.he@gmx.com To: qemu-devel@nongnu.org Date: Wed, 18 Jul 2018 15:47:59 +0800 Message-Id: <1531900083-18167-4-git-send-email-junyan.he@gmx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531900083-18167-1-git-send-email-junyan.he@gmx.com> References: <1531900083-18167-1-git-send-email-junyan.he@gmx.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.136 Subject: [Qemu-devel] [PATCH 3/7 V11] configure: add libpmem support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Haozhong Zhang , xiaoguangrong.eric@gmail.com, crosthwaite.peter@gmail.com, mst@redhat.com, dgilbert@redhat.com, ehabkost@redhat.com, quintela@redhat.com, Junyan He , stefanha@redhat.com, pbonzini@redhat.com, imammedo@redhat.com, yi.z.zhang@intel.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Junyan He Add a pair of configure options --{enable,disable}-libpmem to control whether QEMU is compiled with PMDK libpmem [1]. QEMU may write to the host persistent memory (e.g. in vNVDIMM label emulation and live migration), so it must take the proper operations to ensure the persistence of its own writes. Depending on the CPU models and available instructions, the optimal operation can vary [2]. PMDK libpmem have already implemented those operations on multiple CPU models (x86 and ARM) and the logic to select the optimal ones, so QEMU can just use libpmem rather than re-implement them. Libpem is a part of PMDK project(formerly known as NMVL). The project's home page is: http://pmem.io/pmdk/ And the project's repository is: https://github.com/pmem/pmdk/ For more information about libpmem APIs, you can refer to the comments in source code of: pmdk/src/libpmem/pmem.c, begin at line 33. Signed-off-by: Junyan He Signed-off-by: Haozhong Zhang Reviewed-by: Stefan Hajnoczi Reviewed-by: Igor Mammedov Reviewed-by: Richard Henderson --- configure | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/configure b/configure index 2a7796e..1c9288b 100755 --- a/configure +++ b/configure @@ -475,6 +475,7 @@ vxhs=3D"" libxml2=3D"" docker=3D"no" debug_mutex=3D"no" +libpmem=3D"" =20 # cross compilers defaults, can be overridden with --cross-cc-ARCH cross_cc_aarch64=3D"aarch64-linux-gnu-gcc" @@ -1435,6 +1436,10 @@ for opt do ;; --disable-debug-mutex) debug_mutex=3Dno ;; + --enable-libpmem) libpmem=3Dyes + ;; + --disable-libpmem) libpmem=3Dno + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -1710,6 +1715,7 @@ disabled with --disable-FEATURE, default is enabled i= f available: vhost-user vhost-user support capstone capstone disassembler support debug-mutex mutex debugging support + libpmem libpmem support =20 NOTE: The object files are built at the place where configure is launched EOF @@ -5546,6 +5552,24 @@ if has "docker"; then fi =20 ########################################## +# check for libpmem + +if test "$libpmem" !=3D "no"; then + if $pkg_config --exists "libpmem"; then + libpmem=3D"yes" + libpmem_libs=3D$($pkg_config --libs libpmem) + libpmem_cflags=3D$($pkg_config --cflags libpmem) + libs_softmmu=3D"$libs_softmmu $libpmem_libs" + QEMU_CFLAGS=3D"$QEMU_CFLAGS $libpmem_cflags" + else + if test "$libpmem" =3D "yes" ; then + feature_not_found "libpmem" "Install nvml or pmdk" + fi + libpmem=3D"no" + fi +fi + +########################################## # End of CC checks # After here, no more $cc or $ld runs =20 @@ -6010,6 +6034,7 @@ echo "replication support $replication" echo "VxHS block device $vxhs" echo "capstone $capstone" echo "docker $docker" +echo "libpmem support $libpmem" =20 if test "$sdl_too_old" =3D "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support" @@ -6763,6 +6788,10 @@ if test "$vxhs" =3D "yes" ; then echo "VXHS_LIBS=3D$vxhs_libs" >> $config_host_mak fi =20 +if test "$libpmem" =3D "yes" ; then + echo "CONFIG_LIBPMEM=3Dy" >> $config_host_mak +fi + if test "$tcg_interpreter" =3D "yes"; then QEMU_INCLUDES=3D"-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES" elif test "$ARCH" =3D "sparc64" ; then --=20 2.7.4 From nobody Sun Apr 28 19:00:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531900342488220.31215795258743; Wed, 18 Jul 2018 00:52:22 -0700 (PDT) Received: from localhost ([::1]:35222 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffhG1-0004kq-DV for importer@patchew.org; Wed, 18 Jul 2018 03:52:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56557) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffhCA-0001zm-Kn for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffhC8-0003go-S8 for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:22 -0400 Received: from mga12.intel.com ([192.55.52.136]:63886) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffhC8-0003XX-Fl for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:20 -0400 Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jul 2018 00:48:20 -0700 Received: from natrouter.sh.intel.com (HELO robinhe-hp.domain) ([10.239.13.3]) by fmsmga007.fm.intel.com with ESMTP; 18 Jul 2018 00:48:17 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,369,1526367600"; d="scan'208";a="55232115" From: junyan.he@gmx.com To: qemu-devel@nongnu.org Date: Wed, 18 Jul 2018 15:48:00 +0800 Message-Id: <1531900083-18167-5-git-send-email-junyan.he@gmx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531900083-18167-1-git-send-email-junyan.he@gmx.com> References: <1531900083-18167-1-git-send-email-junyan.he@gmx.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.136 Subject: [Qemu-devel] [PATCH 4/7 V11] hostmem-file: add the 'pmem' option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Haozhong Zhang , xiaoguangrong.eric@gmail.com, crosthwaite.peter@gmail.com, mst@redhat.com, dgilbert@redhat.com, ehabkost@redhat.com, quintela@redhat.com, Junyan He , stefanha@redhat.com, pbonzini@redhat.com, imammedo@redhat.com, yi.z.zhang@intel.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Junyan He When QEMU emulates vNVDIMM labels and migrates vNVDIMM devices, it needs to know whether the backend storage is a real persistent memory, in order to decide whether special operations should be performed to ensure the data persistence. This boolean option 'pmem' allows users to specify whether the backend storage of memory-backend-file is a real persistent memory. If 'pmem=3Don', QEMU will set the flag RAM_PMEM in the RAM block of the corresponding memory region. If 'pmem' is set while lack of libpmem support, a error is generated. Signed-off-by: Junyan He Signed-off-by: Haozhong Zhang Reviewed-by: Stefan Hajnoczi Reviewed-by: Igor Mammedov Reviewed-by: Richard Henderson --- backends/hostmem-file.c | 43 +++++++++++++++++++++++++++++++++++++++++-- docs/nvdimm.txt | 22 ++++++++++++++++++++++ exec.c | 8 ++++++++ include/exec/memory.h | 4 ++++ include/exec/ram_addr.h | 3 +++ qemu-options.hx | 7 +++++++ 6 files changed, 85 insertions(+), 2 deletions(-) diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index 34c68bb..2476dcb 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -12,6 +12,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu-common.h" +#include "qemu/error-report.h" #include "sysemu/hostmem.h" #include "sysemu/sysemu.h" #include "qom/object_interfaces.h" @@ -31,9 +32,10 @@ typedef struct HostMemoryBackendFile HostMemoryBackendFi= le; struct HostMemoryBackendFile { HostMemoryBackend parent_obj; =20 - bool discard_data; char *mem_path; uint64_t align; + bool discard_data; + bool is_pmem; }; =20 static void @@ -59,7 +61,8 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Err= or **errp) memory_region_init_ram_from_file(&backend->mr, OBJECT(backend), path, backend->size, fb->align, - backend->share ? RAM_SHARED : 0, + (backend->share ? RAM_SHARED : 0) | + (fb->is_pmem ? RAM_PMEM : 0), fb->mem_path, errp); g_free(path); } @@ -131,6 +134,39 @@ static void file_memory_backend_set_align(Object *o, V= isitor *v, error_propagate(errp, local_err); } =20 +static bool file_memory_backend_get_pmem(Object *o, Error **errp) +{ + return MEMORY_BACKEND_FILE(o)->is_pmem; +} + +static void file_memory_backend_set_pmem(Object *o, bool value, Error **er= rp) +{ + HostMemoryBackend *backend =3D MEMORY_BACKEND(o); + HostMemoryBackendFile *fb =3D MEMORY_BACKEND_FILE(o); + + if (host_memory_backend_mr_inited(backend)) { + error_setg(errp, "cannot change property 'pmem' of %s '%s'", + object_get_typename(o), + object_get_canonical_path_component(o)); + return; + } + +#ifndef CONFIG_LIBPMEM + if (value) { + Error *local_err =3D NULL; + error_setg(&local_err, + "Lack of libpmem support while setting the 'pmem=3Don'" + " of %s '%s'. We can't ensure data persistence.", + object_get_typename(o), + object_get_canonical_path_component(o)); + error_propagate(errp, local_err); + return; + } +#endif + + fb->is_pmem =3D value; +} + static void file_backend_unparent(Object *obj) { HostMemoryBackend *backend =3D MEMORY_BACKEND(obj); @@ -162,6 +198,9 @@ file_backend_class_init(ObjectClass *oc, void *data) file_memory_backend_get_align, file_memory_backend_set_align, NULL, NULL, &error_abort); + object_class_property_add_bool(oc, "pmem", + file_memory_backend_get_pmem, file_memory_backend_set_pmem, + &error_abort); } =20 static void file_backend_instance_finalize(Object *o) diff --git a/docs/nvdimm.txt b/docs/nvdimm.txt index 24b443b..5f158a6 100644 --- a/docs/nvdimm.txt +++ b/docs/nvdimm.txt @@ -173,3 +173,25 @@ There are currently two valid values for this option: the NVDIMMs in the event of power loss. This implies that the platform also supports flushing dirty data through the memory controller on power loss. + +If the vNVDIMM backend is in host persistent memory that can be accessed in +SNIA NVM Programming Model [1] (e.g., Intel NVDIMM), it's suggested to set +the 'pmem' option of memory-backend-file to 'on'. When 'pmem' is 'on' and = QEMU +is built with libpmem [2] support (configured with --enable-libpmem), QEMU +will take necessary operations to guarantee the persistence of its own wri= tes +to the vNVDIMM backend(e.g., in vNVDIMM label emulation and live migration= ). +If 'pmem' is 'on' while there is no libpmem support, qemu will exit and re= port +a "lack of libpmem support" message to ensure the persistence is available. +For example, if we want to ensure the persistence for some backend file, +use the QEMU command line: + + -object memory-backend-file,id=3Dnv_mem,mem-path=3D/XXX/yyy,size=3D4G,= pmem=3Don + +References +---------- + +[1] NVM Programming Model (NPM) + Version 1.2 + https://www.snia.org/sites/default/files/technical_work/final/NVMProgr= ammingModel_v1.2.pdf +[2] Persistent Memory Development Kit (PMDK), formerly known as NVML proje= ct, home page: + http://pmem.io/pmdk/ diff --git a/exec.c b/exec.c index 3b8f914..fa3fbc6 100644 --- a/exec.c +++ b/exec.c @@ -2245,6 +2245,9 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, Mem= oryRegion *mr, Error *local_err =3D NULL; int64_t file_size; =20 + /* Just support these ram flags by now. */ + assert((ram_flags & ~(RAM_SHARED | RAM_PMEM)) =3D=3D 0); + if (xen_enabled()) { error_setg(errp, "-mem-path not supported with Xen"); return NULL; @@ -4072,6 +4075,11 @@ err: return ret; } =20 +bool ramblock_is_pmem(RAMBlock *rb) +{ + return rb->flags & RAM_PMEM; +} + #endif =20 void page_size_init(void) diff --git a/include/exec/memory.h b/include/exec/memory.h index 30e7166..cd62029 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -123,6 +123,9 @@ typedef struct IOMMUNotifier IOMMUNotifier; /* RAM can be migrated */ #define RAM_MIGRATABLE (1 << 4) =20 +/* RAM is a persistent kind memory */ +#define RAM_PMEM (1 << 5) + static inline void iommu_notifier_init(IOMMUNotifier *n, IOMMUNotify fn, IOMMUNotifierFlag flags, hwaddr start, hwaddr end, @@ -654,6 +657,7 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr, * (getpagesize()) will be used. * @ram_flags: Memory region features: * - RAM_SHARED: memory must be mmaped with the MAP_SHARED flag + * - RAM_PMEM: the memory is persistent memory * Other bits are ignored now. * @path: the path in which to allocate the RAM. * @errp: pointer to Error*, to store an error if it happens. diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index 8a4a9bc..3abb639 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -70,6 +70,8 @@ static inline unsigned long int ramblock_recv_bitmap_offs= et(void *host_addr, return host_addr_offset >> TARGET_PAGE_BITS; } =20 +bool ramblock_is_pmem(RAMBlock *rb); + long qemu_getrampagesize(void); =20 /** @@ -83,6 +85,7 @@ long qemu_getrampagesize(void); * @ram_flags: specify the properties of the ram block, which can be one * or bit-or of following values * - RAM_SHARED: mmap the backing file or device with MAP_SHA= RED + * - RAM_PMEM: the backend @mem_path or @fd is persistent mem= ory * Other bits are ignored. * @mem_path or @fd: specify the backing file or device * @errp: pointer to Error*, to store an error if it happens diff --git a/qemu-options.hx b/qemu-options.hx index 371c427..ee2920b 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4070,6 +4070,13 @@ requires an alignment different than the default one= used by QEMU, eg the device DAX /dev/dax0.0 requires 2M alignment rather than 4K. In such cases, users can specify the required alignment via this option. =20 +The @option{pmem} option specifies whether the backing file specified +by @option{mem-path} is in host persistent memory that can be accessed +using the SNIA NVM programming model (e.g. Intel NVDIMM). +If @option{pmem} is set to 'on', QEMU will take necessary operations to +guarantee the persistence of its own writes to @option{mem-path} +(e.g. in vNVDIMM label emulation and live migration). + @item -object memory-backend-ram,id=3D@var{id},merge=3D@var{on|off},dump= =3D@var{on|off},share=3D@var{on|off},prealloc=3D@var{on|off},size=3D@var{si= ze},host-nodes=3D@var{host-nodes},policy=3D@var{default|preferred|bind|inte= rleave} =20 Creates a memory backend object, which can be used to back the guest RAM. --=20 2.7.4 From nobody Sun Apr 28 19:00:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531900462976153.4111434695485; Wed, 18 Jul 2018 00:54:22 -0700 (PDT) Received: from localhost ([::1]:35230 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffhHy-0006KK-13 for importer@patchew.org; Wed, 18 Jul 2018 03:54:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffhCF-00022A-KA for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffhCB-0003l5-Iz for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:27 -0400 Received: from mga12.intel.com ([192.55.52.136]:63886) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffhCB-0003XX-7X for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:23 -0400 Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jul 2018 00:48:22 -0700 Received: from natrouter.sh.intel.com (HELO robinhe-hp.domain) ([10.239.13.3]) by fmsmga007.fm.intel.com with ESMTP; 18 Jul 2018 00:48:20 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,369,1526367600"; d="scan'208";a="55232118" From: junyan.he@gmx.com To: qemu-devel@nongnu.org Date: Wed, 18 Jul 2018 15:48:01 +0800 Message-Id: <1531900083-18167-6-git-send-email-junyan.he@gmx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531900083-18167-1-git-send-email-junyan.he@gmx.com> References: <1531900083-18167-1-git-send-email-junyan.he@gmx.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.136 Subject: [Qemu-devel] [PATCH 5/7 V11] mem/nvdimm: ensure write persistence to PMEM in label emulation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Haozhong Zhang , xiaoguangrong.eric@gmail.com, crosthwaite.peter@gmail.com, mst@redhat.com, dgilbert@redhat.com, ehabkost@redhat.com, quintela@redhat.com, Junyan He , stefanha@redhat.com, pbonzini@redhat.com, imammedo@redhat.com, yi.z.zhang@intel.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Junyan He Guest writes to vNVDIMM labels are intercepted and performed on the backend by QEMU. When the backend is a real persistent memort, QEMU needs to take proper operations to ensure its write persistence on the persistent memory. Otherwise, a host power failure may result in the loss of guest label configurations. Signed-off-by: Haozhong Zhang Reviewed-by: Stefan Hajnoczi Reviewed-by: Igor Mammedov Reviewed-by: Richard Henderson --- hw/mem/nvdimm.c | 9 ++++++++- include/qemu/pmem.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 include/qemu/pmem.h diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c index 021d1c3..1c6674c 100644 --- a/hw/mem/nvdimm.c +++ b/hw/mem/nvdimm.c @@ -23,6 +23,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/pmem.h" #include "qapi/error.h" #include "qapi/visitor.h" #include "hw/mem/nvdimm.h" @@ -164,11 +165,17 @@ static void nvdimm_write_label_data(NVDIMMDevice *nvd= imm, const void *buf, { MemoryRegion *mr; PCDIMMDevice *dimm =3D PC_DIMM(nvdimm); + bool is_pmem =3D object_property_get_bool(OBJECT(dimm->hostmem), + "pmem", NULL); uint64_t backend_offset; =20 nvdimm_validate_rw_label_data(nvdimm, size, offset); =20 - memcpy(nvdimm->label_data + offset, buf, size); + if (!is_pmem) { + memcpy(nvdimm->label_data + offset, buf, size); + } else { + pmem_memcpy_persist(nvdimm->label_data + offset, buf, size); + } =20 mr =3D host_memory_backend_get_memory(dimm->hostmem); backend_offset =3D memory_region_size(mr) - nvdimm->label_size + offse= t; diff --git a/include/qemu/pmem.h b/include/qemu/pmem.h new file mode 100644 index 0000000..ebdb070 --- /dev/null +++ b/include/qemu/pmem.h @@ -0,0 +1,30 @@ +/* + * QEMU header file for libpmem. + * + * Copyright (c) 2018 Intel Corporation. + * + * Author: Haozhong Zhang + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_PMEM_H +#define QEMU_PMEM_H + +#ifdef CONFIG_LIBPMEM +#include +#else /* !CONFIG_LIBPMEM */ + +static inline void * +pmem_memcpy_persist(void *pmemdest, const void *src, size_t len) +{ + /* If 'pmem' option is 'on', we should always have libpmem support, + or qemu will report a error and exit, never come here. */ + g_assert_not_reached(); + return NULL; +} + +#endif /* CONFIG_LIBPMEM */ + +#endif /* !QEMU_PMEM_H */ --=20 2.7.4 From nobody Sun Apr 28 19:00:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531900554886383.9466824477479; Wed, 18 Jul 2018 00:55:54 -0700 (PDT) Received: from localhost ([::1]:35242 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffhJO-0007nH-MS for importer@patchew.org; Wed, 18 Jul 2018 03:55:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffhCH-00023Z-6L for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffhCE-0003pE-3I for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:29 -0400 Received: from mga12.intel.com ([192.55.52.136]:63886) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffhCD-0003XX-Qy for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:26 -0400 Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jul 2018 00:48:25 -0700 Received: from natrouter.sh.intel.com (HELO robinhe-hp.domain) ([10.239.13.3]) by fmsmga007.fm.intel.com with ESMTP; 18 Jul 2018 00:48:23 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,369,1526367600"; d="scan'208";a="55232126" From: junyan.he@gmx.com To: qemu-devel@nongnu.org Date: Wed, 18 Jul 2018 15:48:02 +0800 Message-Id: <1531900083-18167-7-git-send-email-junyan.he@gmx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531900083-18167-1-git-send-email-junyan.he@gmx.com> References: <1531900083-18167-1-git-send-email-junyan.he@gmx.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.136 Subject: [Qemu-devel] [PATCH 6/7 V11] migration/ram: Add check and info message to nvdimm post copy. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xiaoguangrong.eric@gmail.com, crosthwaite.peter@gmail.com, mst@redhat.com, dgilbert@redhat.com, ehabkost@redhat.com, quintela@redhat.com, Junyan He , stefanha@redhat.com, pbonzini@redhat.com, imammedo@redhat.com, yi.z.zhang@intel.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Junyan He The nvdimm kind memory does not support post copy now. We disable post copy if we have nvdimm memory and print some log hint to user. Signed-off-by: Junyan He Reviewed-by: Stefan Hajnoczi Reviewed-by: Igor Mammedov --- migration/ram.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index 52dd678..309b567 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3899,6 +3899,15 @@ static int ram_load(QEMUFile *f, void *opaque, int v= ersion_id) =20 static bool ram_has_postcopy(void *opaque) { + RAMBlock *rb; + RAMBLOCK_FOREACH_MIGRATABLE(rb) { + if (ramblock_is_pmem(rb)) { + info_report("Block: %s, host: %p is a nvdimm memory, postcopy" + "is not supported now!", rb->idstr, rb->host); + return false; + } + } + return migrate_postcopy_ram(); } =20 --=20 2.7.4 From nobody Sun Apr 28 19:00:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531900622201161.22708538066877; Wed, 18 Jul 2018 00:57:02 -0700 (PDT) Received: from localhost ([::1]:35245 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffhKT-0000B8-73 for importer@patchew.org; Wed, 18 Jul 2018 03:56:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffhCH-00024s-KA for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffhCG-0003t0-O8 for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:29 -0400 Received: from mga12.intel.com ([192.55.52.136]:63886) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffhCG-0003XX-Do for qemu-devel@nongnu.org; Wed, 18 Jul 2018 03:48:28 -0400 Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jul 2018 00:48:28 -0700 Received: from natrouter.sh.intel.com (HELO robinhe-hp.domain) ([10.239.13.3]) by fmsmga007.fm.intel.com with ESMTP; 18 Jul 2018 00:48:25 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,369,1526367600"; d="scan'208";a="55232132" From: junyan.he@gmx.com To: qemu-devel@nongnu.org Date: Wed, 18 Jul 2018 15:48:03 +0800 Message-Id: <1531900083-18167-8-git-send-email-junyan.he@gmx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531900083-18167-1-git-send-email-junyan.he@gmx.com> References: <1531900083-18167-1-git-send-email-junyan.he@gmx.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.136 Subject: [Qemu-devel] [PATCH 7/7 V11] migration/ram: ensure write persistence on loading all data to PMEM. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xiaoguangrong.eric@gmail.com, crosthwaite.peter@gmail.com, mst@redhat.com, dgilbert@redhat.com, ehabkost@redhat.com, quintela@redhat.com, Junyan He , stefanha@redhat.com, pbonzini@redhat.com, imammedo@redhat.com, yi.z.zhang@intel.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Junyan He Because we need to make sure the pmem kind memory data is synced after migration, we choose to call pmem_persist() when the migration finish. This will make sure the data of pmem is safe and will not lose if power is off. Signed-off-by: Junyan He Reviewed-by: Stefan Hajnoczi Reviewed-by: Igor Mammedov --- include/qemu/pmem.h | 6 ++++++ migration/ram.c | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/include/qemu/pmem.h b/include/qemu/pmem.h index ebdb070..dfb6d0d 100644 --- a/include/qemu/pmem.h +++ b/include/qemu/pmem.h @@ -25,6 +25,12 @@ pmem_memcpy_persist(void *pmemdest, const void *src, siz= e_t len) return NULL; } =20 +static inline void +pmem_persist(const void *addr, size_t len) +{ + g_assert_not_reached(); +} + #endif /* CONFIG_LIBPMEM */ =20 #endif /* !QEMU_PMEM_H */ diff --git a/migration/ram.c b/migration/ram.c index 309b567..67b620b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -33,6 +33,7 @@ #include "qemu/bitops.h" #include "qemu/bitmap.h" #include "qemu/main-loop.h" +#include "qemu/pmem.h" #include "xbzrle.h" #include "ram.h" #include "migration.h" @@ -3540,6 +3541,13 @@ static int ram_load_setup(QEMUFile *f, void *opaque) static int ram_load_cleanup(void *opaque) { RAMBlock *rb; + + RAMBLOCK_FOREACH_MIGRATABLE(rb) { + if (ramblock_is_pmem(rb)) { + pmem_persist(rb->host, rb->used_length); + } + } + xbzrle_load_cleanup(); compress_threads_load_cleanup(); =20 --=20 2.7.4