From nobody Sat May 18 11:25:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1672919673; cv=none; d=zohomail.com; s=zohoarc; b=F/h4GI98KCbGWPekIG3S5bcVZvBzMJRaC+6vcqJGcy59SuHA4YMeqSptluCEi6KraBiuhF2Bfp7U6vnSMjnK5nbvVrQETCs/xCA9y6PCkXQeHxAbUTDmY9MGC5RvcDRJ3+RI9gr3y2egA287oIzG1ug24fnCTtGV3gQFQcdQ2yM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672919673; 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=Sf/21k3ubzhimtcIakwGsDfcIOgoziahtBmNNAG2oO8=; b=f/wdnzn9UJnEDQArvA39cNNgSm2cRT7S24b6Wuc+uRai/3kltOssHLctK4pwDGAMC1WOwAl9uVXalQsuIoF6trwGB/Vu81TYYlXdLgrRVl6dQoSBaslKyTgW3HXEZgnfPDkGelAKqt7xwJMbe/f8j4uR1vENRcUq+e0yvePQ9tA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1672919673342215.42139110842925; Thu, 5 Jan 2023 03:54:33 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-616-S9_4S7mBNVqMyfOQUwIchw-1; Thu, 05 Jan 2023 06:54:28 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2E2EB3C01E06; Thu, 5 Jan 2023 11:54:26 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDCF82166B30; Thu, 5 Jan 2023 11:54:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9ECAA1946589; Thu, 5 Jan 2023 11:54:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2FAFF1946586 for ; Thu, 5 Jan 2023 11:54:25 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 12F4240C1141; Thu, 5 Jan 2023 11:54:25 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF0BE400E107 for ; Thu, 5 Jan 2023 11:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672919671; 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=Sf/21k3ubzhimtcIakwGsDfcIOgoziahtBmNNAG2oO8=; b=aoG+GOGojh3goeNlg5wrUHdpGLI8Om7ZBuOrcCYwA+YV6lAsVTqGPOpIm0abXURx54b0Lf Z+p1lFNZT0+1PyZbegsDRsFgxwJKVZZnYTWfe/C+FSlYJUNUYvC+qlyIGj/oGnp2gPHbJo rfOyIOIa3KPC3atGZy0XBn0I3p6Gvz0= X-MC-Unique: S9_4S7mBNVqMyfOQUwIchw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] qemuBuildThreadContextProps: Generate ThreadContext less frequently Date: Thu, 5 Jan 2023 12:54:23 +0100 Message-Id: <7d4c33b21eb242046177f23d387317ca132c83d5.1672919663.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672919674710100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Currently, the ThreadContext object is generated whenever we see .host-nodes attribute for a memory-backend-* object. The idea was that when the backend is pinned to a specific set of host NUMA nodes, then the allocation could be happening on CPUs from those nodes too. But this may not be always possible. Users might configure their guests in such way that vCPUs and corresponding guest NUMA nodes are on different host NUMA nodes than emulator thread. In this case, ThreadContext won't work, because ThreadContext objects live in context of the emulator thread (vCPU threads are moved around by us later, when emulator thread finished its setup and spawned vCPU threads - see qemuProcessSetupVcpus()). Therefore, memory allocation is done by emulator thread which is pinned to a subset of host NUMA nodes, but tries to create a ThreadContext object with a disjoint subset of host NUMA nodes, which fails. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2154750 Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 11 ++++++----- .../hugepages-memaccess2.x86_64-latest.args | 9 +++------ .../memory-hotplug-virtio-mem.x86_64-latest.args | 3 +-- .../numatune-memnode.x86_64-latest.args | 9 +++------ .../numatune-system-memory.x86_64-latest.args | 3 +-- 5 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 06e29ff8ae..af17f37754 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3633,6 +3633,10 @@ qemuBuildThreadContextProps(virJSONValue **tcProps, if (!nodemask) return 0; =20 + if (virJSONValueObjectGetBoolean(*memProps, "prealloc", &prealloc) < 0= || + !prealloc) + return 0; + memalias =3D virJSONValueObjectGetString(*memProps, "id"); if (!memalias) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -3655,11 +3659,8 @@ qemuBuildThreadContextProps(virJSONValue **tcProps, NULL) < 0) return -1; =20 - if (virJSONValueObjectGetBoolean(*memProps, "prealloc", &prealloc) >= =3D 0 && - prealloc) { - priv->threadContextAliases =3D g_slist_prepend(priv->threadContext= Aliases, - g_steal_pointer(&tcAl= ias)); - } + priv->threadContextAliases =3D g_slist_prepend(priv->threadContextAlia= ses, + g_steal_pointer(&tcAlias)= ); =20 *tcProps =3D g_steal_pointer(&props); return 0; diff --git a/tests/qemuxml2argvdata/hugepages-memaccess2.x86_64-latest.args= b/tests/qemuxml2argvdata/hugepages-memaccess2.x86_64-latest.args index f73da5865d..fedc9fe1ce 100644 --- a/tests/qemuxml2argvdata/hugepages-memaccess2.x86_64-latest.args +++ b/tests/qemuxml2argvdata/hugepages-memaccess2.x86_64-latest.args @@ -16,17 +16,14 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config= \ -m size=3D4194304k,slots=3D16,maxmem=3D8388608k \ -overcommit mem-lock=3Doff \ -smp 4,sockets=3D4,cores=3D1,threads=3D1 \ --object '{"qom-type":"thread-context","id":"tc-ram-node0","node-affinity":= [0,1,2,3]}' \ --object '{"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/v= ar/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node0","share":false,"size":10737= 41824,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"tc-ram-nod= e0"}' \ +-object '{"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/v= ar/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node0","share":false,"size":10737= 41824,"host-nodes":[0,1,2,3],"policy":"bind"}' \ -numa node,nodeid=3D0,cpus=3D0,memdev=3Dram-node0 \ -object '{"qom-type":"thread-context","id":"tc-ram-node1","node-affinity":= [0,1,2,3]}' \ -object '{"qom-type":"memory-backend-file","id":"ram-node1","mem-path":"/d= ev/hugepages2M/libvirt/qemu/-1-QEMUGuest1","share":true,"prealloc":true,"si= ze":1073741824,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"t= c-ram-node1"}' \ -numa node,nodeid=3D1,cpus=3D1,memdev=3Dram-node1 \ --object '{"qom-type":"thread-context","id":"tc-ram-node2","node-affinity":= [0,1,2,3]}' \ --object '{"qom-type":"memory-backend-file","id":"ram-node2","mem-path":"/v= ar/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node2","share":false,"size":10737= 41824,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"tc-ram-nod= e2"}' \ +-object '{"qom-type":"memory-backend-file","id":"ram-node2","mem-path":"/v= ar/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node2","share":false,"size":10737= 41824,"host-nodes":[0,1,2,3],"policy":"bind"}' \ -numa node,nodeid=3D2,cpus=3D2,memdev=3Dram-node2 \ --object '{"qom-type":"thread-context","id":"tc-ram-node3","node-affinity":= [3]}' \ --object '{"qom-type":"memory-backend-file","id":"ram-node3","mem-path":"/v= ar/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node3","share":false,"size":10737= 41824,"host-nodes":[3],"policy":"bind","prealloc-context":"tc-ram-node3"}' \ +-object '{"qom-type":"memory-backend-file","id":"ram-node3","mem-path":"/v= ar/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node3","share":false,"size":10737= 41824,"host-nodes":[3],"policy":"bind"}' \ -numa node,nodeid=3D3,cpus=3D3,memdev=3Dram-node3 \ -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ -display none \ diff --git a/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest= .args b/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest.args index 04876fc044..5aa8110aeb 100644 --- a/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest.args +++ b/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest.args @@ -32,8 +32,7 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ -object '{"qom-type":"memory-backend-ram","id":"memvirtiomem0","reserve":f= alse,"size":1073741824}' \ -device '{"driver":"virtio-mem-pci","node":0,"block-size":2097152,"request= ed-size":536870912,"memdev":"memvirtiomem0","id":"virtiomem0","bus":"pci.0"= ,"addr":"0x2"}' \ --object '{"qom-type":"thread-context","id":"tc-memvirtiomem1","node-affini= ty":[1,2,3]}' \ --object '{"qom-type":"memory-backend-file","id":"memvirtiomem1","mem-path"= :"/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1","reserve":false,"size":21474= 83648,"host-nodes":[1,2,3],"policy":"bind","prealloc-context":"tc-memvirtio= mem1"}' \ +-object '{"qom-type":"memory-backend-file","id":"memvirtiomem1","mem-path"= :"/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1","reserve":false,"size":21474= 83648,"host-nodes":[1,2,3],"policy":"bind"}' \ -device '{"driver":"virtio-mem-pci","node":0,"block-size":2097152,"request= ed-size":1073741824,"memdev":"memvirtiomem1","prealloc":true,"id":"virtiome= m1","bus":"pci.1","addr":"0x1"}' \ -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","no= de-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw= ","file":"libvirt-1-storage"}' \ diff --git a/tests/qemuxml2argvdata/numatune-memnode.x86_64-latest.args b/t= ests/qemuxml2argvdata/numatune-memnode.x86_64-latest.args index f4ef91006f..7cb7e659a4 100644 --- a/tests/qemuxml2argvdata/numatune-memnode.x86_64-latest.args +++ b/tests/qemuxml2argvdata/numatune-memnode.x86_64-latest.args @@ -16,14 +16,11 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest/.config \ -m 24105 \ -overcommit mem-lock=3Doff \ -smp 32,sockets=3D32,cores=3D1,threads=3D1 \ --object '{"qom-type":"thread-context","id":"tc-ram-node0","node-affinity":= [3]}' \ --object '{"qom-type":"memory-backend-ram","id":"ram-node0","size":20971520= ,"host-nodes":[3],"policy":"preferred","prealloc-context":"tc-ram-node0"}' \ +-object '{"qom-type":"memory-backend-ram","id":"ram-node0","size":20971520= ,"host-nodes":[3],"policy":"preferred"}' \ -numa node,nodeid=3D0,cpus=3D0,memdev=3Dram-node0 \ --object '{"qom-type":"thread-context","id":"tc-ram-node1","node-affinity":= [0,1,2,3,4,5,6,7]}' \ --object '{"qom-type":"memory-backend-ram","id":"ram-node1","size":67633152= 0,"host-nodes":[0,1,2,3,4,5,6,7],"policy":"bind","prealloc-context":"tc-ram= -node1"}' \ +-object '{"qom-type":"memory-backend-ram","id":"ram-node1","size":67633152= 0,"host-nodes":[0,1,2,3,4,5,6,7],"policy":"bind"}' \ -numa node,nodeid=3D1,cpus=3D1-27,cpus=3D29,memdev=3Dram-node1 \ --object '{"qom-type":"thread-context","id":"tc-ram-node2","node-affinity":= [1,2,5,7]}' \ --object '{"qom-type":"memory-backend-ram","id":"ram-node2","size":24578621= 440,"host-nodes":[1,2,5,7],"policy":"bind","prealloc-context":"tc-ram-node2= "}' \ +-object '{"qom-type":"memory-backend-ram","id":"ram-node2","size":24578621= 440,"host-nodes":[1,2,5,7],"policy":"bind"}' \ -numa node,nodeid=3D2,cpus=3D28,cpus=3D30-31,memdev=3Dram-node2 \ -uuid 9f4b6512-e73a-4a25-93e8-5307802821ce \ -display none \ diff --git a/tests/qemuxml2argvdata/numatune-system-memory.x86_64-latest.ar= gs b/tests/qemuxml2argvdata/numatune-system-memory.x86_64-latest.args index 125dc43153..fd93abe3eb 100644 --- a/tests/qemuxml2argvdata/numatune-system-memory.x86_64-latest.args +++ b/tests/qemuxml2argvdata/numatune-system-memory.x86_64-latest.args @@ -14,8 +14,7 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -accel tcg \ -cpu qemu64 \ -m 214 \ --object '{"qom-type":"thread-context","id":"tc-pc.ram","node-affinity":[0]= }' \ --object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264,"= host-nodes":[0],"policy":"bind","prealloc-context":"tc-pc.ram"}' \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264,"= host-nodes":[0],"policy":"bind"}' \ -overcommit mem-lock=3Doff \ -smp 2,sockets=3D2,cores=3D1,threads=3D1 \ -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ --=20 2.38.2