From nobody Mon Feb 9 03:12:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1556215720; cv=none; d=zoho.com; s=zohoarc; b=C2YNd1Hn5h+lWKc95/fZXyVcK6WOQcvESA87+16NDgbah+Vt3FNqevTnnjyd0cTGPQyNV7Yfr6TXuQEF+sreH8HoY+PW5XEJaoYCW1OV9Utbg7kWZvM/M1t2b3lOcDbpIwwgpxPtPyqiPrRaDcMdHsknMM0tPwPOdCW21KxDI2w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556215720; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=pHGtoJy4YtVULGUNc8I7nmiM2EzN3tHwyR2Y1TRvNWg=; b=k01WByA+KXO5L0mNygo3JBmbz6mUMSvcAwYGMVcShUrm1Tzc/3MheXv4WxoXNnNg0uPpOmc8urpKISwwTElzG1ms2jNEX2Op45p9upFfzmNqkxztJUimtzbsW+928po27Gz72eTzpcA4GKAVIJ0Cq2uom6EwF/TgDlb0cUP2mLI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1556215720505760.1846229305985; Thu, 25 Apr 2019 11:08:40 -0700 (PDT) Received: from localhost ([127.0.0.1]:33402 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJinS-0000Nm-IN for importer@patchew.org; Thu, 25 Apr 2019 14:08:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:41511) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJici-0000Xo-V4 for qemu-devel@nongnu.org; Thu, 25 Apr 2019 13:57:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hJicb-00059S-9y for qemu-devel@nongnu.org; Thu, 25 Apr 2019 13:57:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38532) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hJicZ-00056i-9i for qemu-devel@nongnu.org; Thu, 25 Apr 2019 13:57:20 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18EDA792B3; Thu, 25 Apr 2019 17:57:18 +0000 (UTC) Received: from localhost (ovpn-116-9.gru2.redhat.com [10.97.116.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2D785D9C6; Thu, 25 Apr 2019 17:57:17 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Thu, 25 Apr 2019 14:56:56 -0300 Message-Id: <20190425175659.24876-9-ehabkost@redhat.com> In-Reply-To: <20190425175659.24876-1-ehabkost@redhat.com> References: <20190425175659.24876-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 25 Apr 2019 17:57:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 08/11] util/mmap-alloc: Add a 'is_pmem' parameter to qemu_ram_mmap 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: Zhang Yi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Zhang Yi besides the existing 'shared' flags, we are going to add 'is_pmem' to qemu_ram_mmap(), which indicated the memory backend file is a persist memory. Signed-off-by: Haozhong Zhang Signed-off-by: Zhang Yi Reviewed-by: Pankaj Gupta Message-Id: <786c46862cfeb253ee0ea2f44d62ffe76edb7fa4.1549555521.git.yi.z.z= hang@linux.intel.com> Reviewed-by: Michael S. Tsirkin Reviewed-by: Pankaj Gupta Signed-off-by: Eduardo Habkost --- include/qemu/mmap-alloc.h | 21 ++++++++++++++++++++- exec.c | 2 +- util/mmap-alloc.c | 6 +++++- util/oslib-posix.c | 2 +- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/include/qemu/mmap-alloc.h b/include/qemu/mmap-alloc.h index ef04f0ed5b..eec98d82c1 100644 --- a/include/qemu/mmap-alloc.h +++ b/include/qemu/mmap-alloc.h @@ -7,7 +7,26 @@ size_t qemu_fd_getpagesize(int fd); =20 size_t qemu_mempath_getpagesize(const char *mem_path); =20 -void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared); +/** + * qemu_ram_mmap: mmap the specified file or device. + * + * Parameters: + * @fd: the file or the device to mmap + * @size: the number of bytes to be mmaped + * @align: if not zero, specify the alignment of the starting mapping add= ress; + * otherwise, the alignment in use will be determined by QEMU. + * @shared: map has RAM_SHARED flag. + * @is_pmem: map has RAM_PMEM flag. + * + * Return: + * On success, return a pointer to the mapped area. + * On failure, return MAP_FAILED. + */ +void *qemu_ram_mmap(int fd, + size_t size, + size_t align, + bool shared, + bool is_pmem); =20 void qemu_ram_munmap(int fd, void *ptr, size_t size); =20 diff --git a/exec.c b/exec.c index f7f3cdbf4a..aa07432929 100644 --- a/exec.c +++ b/exec.c @@ -1883,7 +1883,7 @@ static void *file_ram_alloc(RAMBlock *block, } =20 area =3D qemu_ram_mmap(fd, memory, block->mr->align, - block->flags & RAM_SHARED); + block->flags & RAM_SHARED, block->flags & RAM_PME= M); if (area =3D=3D MAP_FAILED) { error_setg_errno(errp, errno, "unable to map backing store for guest RAM"); diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c index 8565885420..9713f4b960 100644 --- a/util/mmap-alloc.c +++ b/util/mmap-alloc.c @@ -75,7 +75,11 @@ size_t qemu_mempath_getpagesize(const char *mem_path) return getpagesize(); } =20 -void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared) +void *qemu_ram_mmap(int fd, + size_t size, + size_t align, + bool shared, + bool is_pmem) { int flags; int guardfd; diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 88dda9cd39..d97b1717d5 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -203,7 +203,7 @@ void *qemu_memalign(size_t alignment, size_t size) void *qemu_anon_ram_alloc(size_t size, uint64_t *alignment, bool shared) { size_t align =3D QEMU_VMALLOC_ALIGN; - void *ptr =3D qemu_ram_mmap(-1, size, align, shared); + void *ptr =3D qemu_ram_mmap(-1, size, align, shared, false); =20 if (ptr =3D=3D MAP_FAILED) { return NULL; --=20 2.18.0.rc1.1.g3f1ff2140