From nobody Tue May 14 06:39:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1648120625; cv=none; d=zohomail.com; s=zohoarc; b=A1ySCweykqUr3NUEg9EOBa0nUVZQU2NCySmRdXWKeh0oAHMGTExkgIjD3SLjL9SzMaVmkzHIlLA6N5w+y4JKixKHM5EiAKYBqVaRvg9CT6PnAvCCymKvG7DnB93F84y/6sjB7YfY12kDCi18jSr6Bo3QwzHHIHULVo5IOxnmiCQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648120625; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RLNOMxuzU4Yur+w5hhPA8dyM+3QoqI5tUXceQEPzSnQ=; b=gJda79cslu6N8E5/zKC3VRkxDE/TPjw4yCCSesRBbd+FNf71P5JidKUtupUDkZE8ah8HKl8HHctNYHfQLJKOIU4FNmhcJQVky/6M3Q5gw5Nw7T67JSaTR5/qag52oAUBB8mlWx1us/eGqGSMezSwuHkymlLq7/kNmgu+qtRK+es= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1648120625448286.95348803158583; Thu, 24 Mar 2022 04:17:05 -0700 (PDT) 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-107-E526bHvPMAKhX9u1NO9bKQ-1; Thu, 24 Mar 2022 07:16:08 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9379B3C11A1F; Thu, 24 Mar 2022 11:16:06 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7CA95403176; Thu, 24 Mar 2022 11:16:06 +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 21120194034E; Thu, 24 Mar 2022 11:16:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6B60D194034B for ; Thu, 24 Mar 2022 11:16:04 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 39D7A43F505; Thu, 24 Mar 2022 11:16:04 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5FE7492CA6 for ; Thu, 24 Mar 2022 11:16:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648120624; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=RLNOMxuzU4Yur+w5hhPA8dyM+3QoqI5tUXceQEPzSnQ=; b=KpMr57wFwj8ShSpEDo4usRAGL8CUOLEcgKbGRkVSeKKU4Juk3M6UpJmqdGWHPOztHnF/kL 4KK80tMW6fm6WOnta8BA8F/OhNBGGAR9DcnTusjbaghJxDAY5+UgcDO0DN5u1ZDvn3kCEn LFEymaehC1w++G4Q3o98bsBrDTmTT6s= X-MC-Unique: E526bHvPMAKhX9u1NO9bKQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2] conf: Introduce memory allocation threads Date: Thu, 24 Mar 2022 12:16:01 +0100 Message-Id: <26c90a52560e013c0c8fcc3f676b8dbc04c6b58d.1648120011.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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 2.85 on 10.11.54.10 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) X-ZM-MESSAGEID: 1648120627139100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Since its v5.0.0 release QEMU is capable of specifying number of threads used to allocate memory. It defaults to 1, which may be too low for humongous guests with gigantic pages. In general, on QEMU cmd line level it is possible to use different number of threads per each memory-backend-* object, in practical terms it's not useful. Therefore, use to set guest wide value and let all memory devices 'inherit' it, silently. IOW, don't introduce per device knob because that would only complicate things for a little or no benefit. Signed-off-by: Michal Privoznik Reviewed-by: Martin Kletzander --- docs/formatdomain.rst | 8 +++++--- src/conf/domain_conf.c | 15 ++++++++++++++- src/conf/domain_conf.h | 1 + src/conf/schemas/domaincommon.rng | 19 +++++++++++++------ tests/qemuxml2argvdata/memfd-memory-numa.xml | 2 +- 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index d188de4858..e492532004 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -1004,7 +1004,7 @@ Memory Backing - + ... @@ -1053,8 +1053,10 @@ influence how virtual memory pages are backed by hos= t pages. Using the ``mode`` attribute, specify if the memory is to be "shared" or "private". This can be overridden per numa node by ``memAccess``. ``allocation`` - Using the ``mode`` attribute, specify when to allocate the memory by - supplying either "immediate" or "ondemand". + Using the optional ``mode`` attribute, specify when to allocate the mem= ory by + supplying either "immediate" or "ondemand". :since:`Since 8.2.0` it is + possible to set the number of threads that hypervisor uses to allocate + memory via ``threads`` attribute. ``discard`` When set and supported by hypervisor the memory content is discarded ju= st before guest shuts down (or when DIMM module is unplugged). Please note= that diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 153954a0b0..731139f80f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18915,6 +18915,13 @@ virDomainDefParseMemory(virDomainDef *def, VIR_FREE(tmp); } =20 + if (virXPathUInt("string(./memoryBacking/allocation/@threads)", + ctxt, &def->mem.allocation_threads) =3D=3D -2) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Failed to parse memory allocation threads")); + return -1; + } + if (virXPathNode("./memoryBacking/hugepages", ctxt)) { /* hugepages will be used */ if ((n =3D virXPathNodeSet("./memoryBacking/hugepages/page", ctxt,= &nodes)) < 0) { @@ -27465,6 +27472,7 @@ virDomainMemorybackingFormat(virBuffer *buf, const virDomainMemtune *mem) { g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); + g_auto(virBuffer) allocAttrBuf =3D VIR_BUFFER_INITIALIZER; =20 if (mem->nhugepages) virDomainHugepagesFormat(&childBuf, mem->hugepages, mem->nhugepage= s); @@ -27479,8 +27487,13 @@ virDomainMemorybackingFormat(virBuffer *buf, virBufferAsprintf(&childBuf, "\n", virDomainMemoryAccessTypeToString(mem->access)); if (mem->allocation) - virBufferAsprintf(&childBuf, "\n", + virBufferAsprintf(&allocAttrBuf, " mode=3D'%s'", virDomainMemoryAllocationTypeToString(mem->alloc= ation)); + if (mem->allocation_threads > 0) + virBufferAsprintf(&allocAttrBuf, " threads=3D'%u'", mem->allocatio= n_threads); + + virXMLFormatElement(&childBuf, "allocation", &allocAttrBuf, NULL); + if (mem->discard) virBufferAddLit(&childBuf, "\n"); =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index b69abfa270..49c964e6e1 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2702,6 +2702,7 @@ struct _virDomainMemtune { int source; /* enum virDomainMemorySource */ int access; /* enum virDomainMemoryAccess */ int allocation; /* enum virDomainMemoryAllocation */ + unsigned int allocation_threads; =20 virTristateBool discard; }; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index 9c1b64a644..34bccee2f5 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -740,12 +740,19 @@ - - - immediate - ondemand - - + + + + immediate + ondemand + + + + + + + + diff --git a/tests/qemuxml2argvdata/memfd-memory-numa.xml b/tests/qemuxml2a= rgvdata/memfd-memory-numa.xml index 1ebcee8939..1ac87e3aef 100644 --- a/tests/qemuxml2argvdata/memfd-memory-numa.xml +++ b/tests/qemuxml2argvdata/memfd-memory-numa.xml @@ -10,7 +10,7 @@ - + 8 --=20 2.34.1