From nobody Mon Sep 16 19:13:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1541422914460136.770369379646; Mon, 5 Nov 2018 05:01:54 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6CB048763B; Mon, 5 Nov 2018 13:01:52 +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 1895C5D73F; Mon, 5 Nov 2018 13:01:52 +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 EFB9E4CA95; Mon, 5 Nov 2018 13:01:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA5CwOLm004282 for ; Mon, 5 Nov 2018 07:58:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0C8422657C; Mon, 5 Nov 2018 12:58:24 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-116-143.phx2.redhat.com [10.3.116.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC27B18522 for ; Mon, 5 Nov 2018 12:58:23 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 5 Nov 2018 07:58:07 -0500 Message-Id: <20181105125816.20385-4-jferlan@redhat.com> In-Reply-To: <20181105125816.20385-1-jferlan@redhat.com> References: <20181105125816.20385-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [REPOST PATCH v2 03/12] qemu: Implement the ability to return IOThread stats 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 05 Nov 2018 13:01:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Process the IOThreads polling stats if available. Generate the output params record to be returned to the caller with the three values - poll-max-ns, poll-grow, and poll-shrink. Signed-off-by: John Ferlan --- include/libvirt/libvirt-domain.h | 1 + src/libvirt-domain.c | 38 +++++++++++++++ src/qemu/qemu_driver.c | 81 ++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index fdd2d6b8ea..58fd4bc10c 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -2048,6 +2048,7 @@ typedef enum { VIR_DOMAIN_STATS_INTERFACE =3D (1 << 4), /* return domain interfaces i= nfo */ VIR_DOMAIN_STATS_BLOCK =3D (1 << 5), /* return domain block info */ VIR_DOMAIN_STATS_PERF =3D (1 << 6), /* return domain perf event info */ + VIR_DOMAIN_STATS_IOTHREAD =3D (1 << 7), /* return iothread poll info */ } virDomainStatsTypes; =20 typedef enum { diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 7690339521..9fda56d660 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -11499,6 +11499,44 @@ virConnectGetDomainCapabilities(virConnectPtr conn, * long long. It is produced by the * emulation_faults perf event * + * VIR_DOMAIN_STATS_IOTHREAD: + * Return IOThread statistics if available. IOThread polling is a + * timing mechanism that allows the hypervisor to generate a longer + * period of time in which the guest will perform operations on the + * CPU being used by the IOThread. The higher the value for poll-max-ns + * the longer the guest will keep the CPU. This may affect other host + * threads using the CPU. The poll-grow and poll-shrink values allow + * the hypervisor to generate a mechanism to add or remove polling time + * within the confines of 0 and poll-max-ns. For QEMU, the poll-grow is + * multiplied by the polling interval, while poll-shrink is used as a + * divisor. When not provided, QEMU may double the polling time until + * poll-max-ns is reached. When poll-shrink is 0 (zero) QEMU may reset + * the polling interval to 0 until it finds its "sweet spot". Setting + * poll-grow too large may cause frequent fluctution of the time; howe= ver, + * this can be tempered by a high poll-shrink to reduce the polling + * interval. For example, a poll-grow of 3 will triple the polling time + * which could quickly exceed poll-max-ns; however, a poll-shrink of + * 10 would cut that polling time more gradually. + * + * The typed parameter keys are in this format: + * + * "iothread.cnt" - maximum number of IOThreads in the subsequent list + * as unsigned int. Each IOThread in the list will + * will use it's iothread_id value as the . There + * may be fewer entries than the iothread.cnt + * value if the polling values are not supported. + * "iothread..poll-max-ns" - maximum polling time in ns as an unsi= gned + * long long. A 0 (zero) means polling is + * disabled. + * "iothread..poll-grow" - polling time factor as an unsigned int. + * A 0 (zero) indicates to allow the under= lying + * hypervisor to choose how to grow the + * polling time. + * "iothread..poll-shrink" - polling time divisor as an unsigned i= nt. + * A 0 (zero) indicates to allow the under= lying + * hypervisor to choose how to shrink the + * polling time. + * * Note that entire stats groups or individual stat fields may be missing = from * the output in case they are not supported by the given hypervisor, are = not * applicable for the current state of the guest domain, or their retrieval diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e13633c1e0..b50d805bf1 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20437,6 +20437,86 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver, =20 #undef QEMU_ADD_NAME_PARAM =20 +#define QEMU_ADD_IOTHREAD_PARAM_UI(record, maxparams, id, name, value) \ + do { \ + char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; \ + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, \ + "iothread.%u.%s", id, name); \ + if (virTypedParamsAddUInt(&(record)->params, \ + &(record)->nparams, \ + maxparams, \ + param_name, \ + value) < 0) \ + goto cleanup; \ + } while (0) + +#define QEMU_ADD_IOTHREAD_PARAM_ULL(record, maxparams, id, name, value) \ +do { \ + char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; \ + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, \ + "iothread.%u.%s", id, name); \ + if (virTypedParamsAddULLong(&(record)->params, \ + &(record)->nparams, \ + maxparams, \ + param_name, \ + value) < 0) \ + goto cleanup; \ +} while (0) + +static int +qemuDomainGetStatsIOThread(virQEMUDriverPtr driver, + virDomainObjPtr dom, + virDomainStatsRecordPtr record, + int *maxparams, + unsigned int privflags ATTRIBUTE_UNUSED) +{ + size_t i; + qemuMonitorIOThreadInfoPtr *iothreads =3D NULL; + int niothreads; + int ret =3D -1; + + if (!virDomainObjIsActive(dom)) + return 0; + + if ((niothreads =3D qemuDomainGetIOThreadsMon(driver, dom, &iothreads)= ) < 0) + return -1; + + if (niothreads =3D=3D 0) + return 0; + + QEMU_ADD_COUNT_PARAM(record, maxparams, "iothread", niothreads); + + for (i =3D 0; i < niothreads; i++) { + if (iothreads[i]->poll_valid) { + QEMU_ADD_IOTHREAD_PARAM_ULL(record, maxparams, + iothreads[i]->iothread_id, + "poll-max-ns", + iothreads[i]->poll_max_ns); + QEMU_ADD_IOTHREAD_PARAM_UI(record, maxparams, + iothreads[i]->iothread_id, + "poll-grow", + iothreads[i]->poll_grow); + QEMU_ADD_IOTHREAD_PARAM_UI(record, maxparams, + iothreads[i]->iothread_id, + "poll-shrink", + iothreads[i]->poll_shrink); + } + } + + ret =3D 0; + + cleanup: + for (i =3D 0; i < niothreads; i++) + VIR_FREE(iothreads[i]); + VIR_FREE(iothreads); + + return ret; +} + +#undef QEMU_ADD_IOTHREAD_PARAM_UI + +#undef QEMU_ADD_IOTHREAD_PARAM_ULL + #undef QEMU_ADD_COUNT_PARAM =20 static int @@ -20511,6 +20591,7 @@ static struct qemuDomainGetStatsWorker qemuDomainGe= tStatsWorkers[] =3D { { qemuDomainGetStatsInterface, VIR_DOMAIN_STATS_INTERFACE, false }, { qemuDomainGetStatsBlock, VIR_DOMAIN_STATS_BLOCK, true }, { qemuDomainGetStatsPerf, VIR_DOMAIN_STATS_PERF, false }, + { qemuDomainGetStatsIOThread, VIR_DOMAIN_STATS_IOTHREAD, true }, { NULL, 0, false } }; =20 --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list