From nobody Thu May 16 00:30:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1609846758; cv=none; d=zohomail.com; s=zohoarc; b=JqxKzFdUYwik6GKJULEAXRNzUReXipPWHTKs42F3BQovoLZNBsSbKcn/FbIvRgIxdwj6dkdzsAksGJ3N4qTbi5Cx+MiXXwOvr1zwD/KWlqoz2pYu+Dcs5kKnwRBXoziQgWj+NRTpcQcEEOjTUIcWCyX9VskqdRg1Nv83hjGRr8I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609846758; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=Hx6cWRLUaeboI5NhL1zrBfGTXgvh6R4iOPBtD8ZdHRA=; b=k8xrN0vMOJE0v68VP5mbKfQIiATmSSG3vPD9WJF09EV0ZNFRSU1qOo9d6RV9eo+LJkRjpW3ZbZEPBAT2gzHDilUwuQITlD8EcRXdoZ8/iNqFpRXs1oAYK7dloYSrTsg3nM3R9DStiki991XUYExwxwe/3NzFWjAYifEnSKU8pPE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1609846758372370.17752958188123; Tue, 5 Jan 2021 03:39:18 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-585-q4Ow0xT3N4OM3OtATVJwWg-1; Tue, 05 Jan 2021 06:39:15 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C8412107ACF8; Tue, 5 Jan 2021 11:39:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9EB655C1C2; Tue, 5 Jan 2021 11:39:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5EC5C4A7C6; Tue, 5 Jan 2021 11:39:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 105Bd7jq025984 for ; Tue, 5 Jan 2021 06:39:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id 21FBF60BFA; Tue, 5 Jan 2021 11:39:07 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9857B60BE5 for ; Tue, 5 Jan 2021 11:39:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609846757; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Hx6cWRLUaeboI5NhL1zrBfGTXgvh6R4iOPBtD8ZdHRA=; b=Pg+E7b20gpIqzm9r2wWvyDp1lkhCPvJMc0DaJvxVQ99a/Tb/gxW8YT6rNBS2ulhoo9dv8g 2MHpwkqqV5IRlEJwd/a3aY2vZ5Sm9Ak5QA42qHkjrV15lCACAFSScbQIyPJHXebTEG6WVP ECACvRS1TYaRUXXLEIpGPJmcGRPCmvg= X-MC-Unique: q4Ow0xT3N4OM3OtATVJwWg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2] qemu: Don't prealloc mem for real NVDIMMs Date: Tue, 5 Jan 2021 12:39:00 +0100 Message-Id: <0698b4a22ac0afb5474fa59e4143699c26ea1bc9.1609846323.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Currently, we configure QEMU to prealloc memory almost by default. Well, by default for NVDIMMs, hugepages and if user asked us to (via memoryBacking ). However, when guest's NVDIMM is backed by real life NVDIMM this approach is not the best. In this case users should put into the device , like this: /dev/pmem0 Instructing QEMU to do prealloc in this case means that each page of the NVDIMM is "touched" (the first byte is read and written back - see QEMU commit v2.9.0-rc1~26^2) which cripples device wear. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1894053 Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza Reviewed-by: Daniel P. Berrang=C3=A9 --- v2 of: https://www.redhat.com/archives/libvir-list/2020-November/msg01568.html diff to v1: - I've dropped the first hunk of v1 which forbade prealloc even if user requested it explicitly. src/qemu/qemu_command.c | 5 ++++- .../memory-hotplug-nvdimm-pmem.x86_64-latest.args | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b06a086e18..f572ed64c1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3085,7 +3085,10 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backend= Props, =20 if (mem->nvdimmPath) { memPath =3D g_strdup(mem->nvdimmPath); - prealloc =3D true; + /* If the NVDIMM is a real device then there's nothing to prea= lloc. + * If anyhing, we would be only wearing off the device. */ + if (!mem->nvdimmPmem) + prealloc =3D true; } else if (useHugepage) { if (qemuGetDomainHupageMemPath(priv->driver, def, pagesize, &m= emPath) < 0) return -1; diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-pmem.x86_64-lates= t.args b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-pmem.x86_64-latest.ar= gs index cac02a6f6d..fb4ae4b518 100644 --- a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-pmem.x86_64-latest.args +++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-pmem.x86_64-latest.args @@ -20,7 +20,7 @@ file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -object memory-backend-ram,id=3Dram-node0,size=3D224395264 \ -numa node,nodeid=3D0,cpus=3D0-1,memdev=3Dram-node0 \ -object memory-backend-file,id=3Dmemnvdimm0,mem-path=3D/tmp/nvdimm,share= =3Dno,\ -prealloc=3Dyes,size=3D536870912,pmem=3Dyes \ +size=3D536870912,pmem=3Dyes \ -device nvdimm,node=3D0,memdev=3Dmemnvdimm0,id=3Dnvdimm0,slot=3D0 \ -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ -display none \ --=20 2.26.2