From e40f868e4f974ea0bd7224f5d49e602cf2947570 Mon Sep 17 00:00:00 2001 Message-Id: From: John Ferlan Date: Tue, 6 Sep 2016 16:43:13 -0400 Subject: [PATCH] conf: Add IOThread quota and period scheduler/cputune defs https://bugzilla.redhat.com/show_bug.cgi?id=1356937 Add the definitions to allow for viewing/setting cgroup period and quota limits for IOThreads. This is similar to the work done for emulator quota and period by commit ids 'b65dafa' and 'e051c482'. Being able to view/set the IOThread specific values is related to more recent changes adding global period (commmit id '4d92d58f') and global quota (commit id '55ecdae') definitions and qemu support (commit id '4e17ff79' and 'fbcbd1b2'). With a global setting though, if somehow the IOThread value in the cgroup hierarchy was set "outside of libvirt" to a value that is incompatible with the global value. Allowing control over IOThread specific values provides the capability to alter the IOThread values as necessary. (cherry picked from commit 2197ea56d77ad3da2e838115eed71d2ad393a082) Signed-off-by: John Ferlan --- docs/formatdomain.html.in | 25 +++++++++++++ docs/schemas/domaincommon.rng | 10 ++++++ include/libvirt/libvirt-domain.h | 32 +++++++++++++++++ src/conf/domain_conf.c | 42 ++++++++++++++++++++++ src/conf/domain_conf.h | 2 ++ tests/qemuxml2argvdata/qemuxml2argv-cputune.xml | 2 ++ .../qemuxml2xmloutdata/qemuxml2xmlout-cputune.xml | 2 ++ tools/virsh.pod | 9 ++--- 8 files changed, 120 insertions(+), 4 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index c080bdf..5b4f83e 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -665,6 +665,8 @@ <quota>-1</quota> <emulator_period>1000000</emulator_period> <emulator_quota>-1</emulator_quota> + <iothread_period>1000000</iothread_period> + <iothread_quota>-1</iothread_quota> <vcpusched vcpus='0-4,^3' scheduler='fifo' priority='1'/> <iothreadsched iothreads='2' scheduler='batch'/> </cputune> @@ -769,6 +771,29 @@ Only QEMU driver support since 0.10.0 +
iothread_period
+
+ The optional iothread_period element specifies the + enforcement interval(unit: microseconds) for IOThreads. Within + iothread_period, each IOThread of the domain will + not be allowed to consume more than iothread_quota + worth of runtime. The value should be in range [1000, 1000000]. + An iothread_period with value 0 means no value. + Only QEMU driver support since 2.1.0 +
+
iothread_quota
+
+ The optional iothread_quota element specifies the maximum + allowed bandwidth(unit: microseconds) for IOThreads. A domain with + iothread_quota as any negative value indicates that the + domain IOThreads have infinite bandwidth, which means that it is + not bandwidth controlled. The value should be in range + [1000, 18446744073709551] or less than 0. An iothread_quota + with value 0 means no value. You can use this feature to ensure that + all IOThreads run at the same speed. + Only QEMU driver support since 2.1.0 +
+
vcpusched and iothreadsched
The optional vcpusched elements specifies the scheduler diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index bf4d795..44e39c8 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -764,6 +764,16 @@ + + + + + + + + + + diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index 7ea93aa..af3ecae 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -365,6 +365,22 @@ typedef enum { # define VIR_DOMAIN_SCHEDULER_EMULATOR_QUOTA "emulator_quota" /** + * VIR_DOMAIN_SCHEDULER_IOTHREAD_PERIOD: + * + * Macro represents the enforcement period for a quota, in microseconds, + * for IOThreads only, when using the posix scheduler, as a ullong. + */ +# define VIR_DOMAIN_SCHEDULER_IOTHREAD_PERIOD "iothread_period" + +/** + * VIR_DOMAIN_SCHEDULER_IOTHREAD_QUOTA: + * + * Macro represents the maximum bandwidth to be used within a period for + * IOThreads only, when using the posix scheduler, as an llong. + */ +# define VIR_DOMAIN_SCHEDULER_IOTHREAD_QUOTA "iothread_quota" + +/** * VIR_DOMAIN_SCHEDULER_WEIGHT: * * Macro represents the relative weight, when using the credit @@ -3604,6 +3620,22 @@ typedef void (*virConnectDomainEventJobCompletedCallback)(virConnectPtr conn, # define VIR_DOMAIN_TUNABLE_CPU_EMULATOR_QUOTA "cputune.emulator_quota" /** + * VIR_DOMAIN_TUNABLE_CPU_IOTHREAD_PERIOD: + * + * Macro represents the enforcement period for a quota, in microseconds, for + * iothreads only, when using the posix scheduler, as VIR_TYPED_PARAM_ULLONG. + */ +# define VIR_DOMAIN_TUNABLE_CPU_IOTHREAD_PERIOD "cputune.iothread_period" + +/** + * VIR_DOMAIN_TUNABLE_CPU_IOTHREAD_QUOTA: + * + * Macro represents the maximum bandwidth to be used within a period for + * iothreads only, when using the posix scheduler, as VIR_TYPED_PARAM_LLONG. + */ +# define VIR_DOMAIN_TUNABLE_CPU_IOTHREAD_QUOTA "cputune.iothread_quota" + +/** * VIR_DOMAIN_TUNABLE_BLKDEV_DISK: * * Macro represents the name of guest disk for which the values are updated, diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 261684e..67c7971 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16343,6 +16343,38 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } + if (virXPathULongLong("string(./cputune/iothread_period[1])", ctxt, + &def->cputune.iothread_period) < -1) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("can't parse cputune iothread period value")); + goto error; + } + + if (def->cputune.iothread_period > 0 && + (def->cputune.iothread_period < 1000 || + def->cputune.iothread_period > 1000000)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Value of cputune iothread_period must be in range " + "[1000, 1000000]")); + goto error; + } + + if (virXPathLongLong("string(./cputune/iothread_quota[1])", ctxt, + &def->cputune.iothread_quota) < -1) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("can't parse cputune iothread quota value")); + goto error; + } + + if (def->cputune.iothread_quota > 0 && + (def->cputune.iothread_quota < 1000 || + def->cputune.iothread_quota > 18446744073709551LL)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Value of cputune iothread_quota must be in range " + "[1000, 18446744073709551]")); + goto error; + } + if ((n = virXPathNodeSet("./cputune/vcpupin", ctxt, &nodes)) < 0) goto error; @@ -22975,6 +23007,16 @@ virDomainCputuneDefFormat(virBufferPtr buf, "\n", def->cputune.emulator_quota); + if (def->cputune.iothread_period) + virBufferAsprintf(&childrenBuf, "%llu" + "\n", + def->cputune.iothread_period); + + if (def->cputune.iothread_quota) + virBufferAsprintf(&childrenBuf, "%lld" + "\n", + def->cputune.iothread_quota); + for (i = 0; i < def->maxvcpus; i++) { char *cpumask; virDomainVcpuDefPtr vcpu = def->vcpus[i]; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 34da54c..61ca8bd 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2031,6 +2031,8 @@ struct _virDomainCputune { long long global_quota; unsigned long long emulator_period; long long emulator_quota; + unsigned long long iothread_period; + long long iothread_quota; virBitmapPtr emulatorpin; }; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cputune.xml b/tests/qemuxml2argvdata/qemuxml2argv-cputune.xml index 9595903..e6ef51d 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cputune.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cputune.xml @@ -10,6 +10,8 @@ -1 1000000 -1 + 1000000 + -1 diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cputune.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cputune.xml index baf1779..7a1f50d 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cputune.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cputune.xml @@ -10,6 +10,8 @@ -1 1000000 -1 + 1000000 + -1 diff --git a/tools/virsh.pod b/tools/virsh.pod index 601cb44..5fef86b 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1906,7 +1906,7 @@ available for each hypervisor are: LXC (posix scheduler) : cpu_shares, vcpu_period, vcpu_quota QEMU/KVM (posix scheduler): cpu_shares, vcpu_period, vcpu_quota, -emulator_period, emulator_quota +emulator_period, emulator_quota, iothread_quota, iothread_period Xen (credit scheduler): weight, cap @@ -1924,9 +1924,10 @@ values 0 and 1 are automatically converted to a minimal value of 2. B: The weight and cap parameters are defined only for the XEN_CREDIT scheduler and are now I. -B: The vcpu_period/emulator_period parameters have a valid value range -of 1000-1000000 or 0, and the vcpu_quota/emulator_quota parameters have a -valid value range of 1000-18446744073709551 or less than 0. The value 0 for +B: The vcpu_period, emulator_period, and iothread_period parameters +have a valid value range of 1000-1000000 or 0, and the vcpu_quota, +emulator_quota, and iothread_quota parameters have a valid value range of +1000-18446744073709551 or less than 0. The value 0 for either parameter is the same as not specifying that parameter. =item B I [I] [I<--screen> B] -- 2.10.0