Extend iothreadset to allow configuring the iothread poll-weight value from the command line.
Add a --poll-weight option to opts_iothreadset and wire it up in cmdIOThreadSet. The value is validated against the accepted range [0, 63] before being passed to the backend as VIR_DOMAIN_IOTHREAD_POLL_WEIGHT. If the option is omitted the parameter is not added to the list and the backend leaves the value unchanged. Document --poll-weight in the iothreadset section of the virsh manpage and update the syntax synopsis to include the new option. Extend the virsh test suite with an iothreadset --poll-weight 3 call followed by a domstats check that confirms the updated value is reflected. Signed-off-by: Jaehoon Kim <[email protected]> --- docs/manpages/virsh.rst | 16 ++++++++++------ tests/virshtestdata/iothreads.in | 2 ++ tests/virshtestdata/iothreads.out | 14 ++++++++++++++ tools/virsh-domain.c | 17 +++++++++++++++++ 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 8465f19c12..e1b08a299a 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -3500,8 +3500,8 @@ iothreadset :: iothreadset domain iothread_id [[--poll-max-ns ns] [--poll-grow factor] - [--poll-shrink divisor] [--thread-pool-min value] - [--thread-pool-max value]] + [--poll-shrink divisor] [--poll-weight factor] + [--thread-pool-min value] [--thread-pool-max value]] [[--config] [--live] | [--current]] Modifies an existing iothread of the domain using the specified @@ -3513,10 +3513,14 @@ reach the maximum polling time. If a 0 (zero) is provided, then the default factor will be used. The *--poll-shrink* is the quotient by which the current polling time will be reduced in order to get below the maximum polling interval. If a 0 (zero) is provided, then -the default quotient will be used. The polling values are purely dynamic -for a running guest. Saving, destroying, stopping, etc. the guest will -result in the polling values returning to hypervisor defaults at the -next start, restore, etc. +the default quotient will be used. The *--poll-weight* sets the weight +shift value for adaptive polling, determining how much the most recent +event interval affects the next polling duration calculation. Larger +values reduce the weight of recent events. Valid range is [0, 63]. +If omitted, the value is not changed. The polling values are purely +dynamic for a running guest. Saving, destroying, stopping, etc. the +guest will result in the polling values returning to hypervisor defaults +at the next start, restore, etc. The *--thread-pool-min* and *--thread-pool-max* options then set lower and upper bound, respectively of number of threads in worker pool of given diff --git a/tests/virshtestdata/iothreads.in b/tests/virshtestdata/iothreads.in index 25ebcb5cda..b5aed83bba 100644 --- a/tests/virshtestdata/iothreads.in +++ b/tests/virshtestdata/iothreads.in @@ -7,6 +7,8 @@ iothreadinfo --domain fc4 domstats --domain fc4 iothreadset --domain fc4 --id 6 --poll-max-ns 100 --poll-shrink 10 --poll-grow 10 domstats --domain fc4 +iothreadset --domain fc4 --id 6 --poll-weight 3 +domstats --domain fc4 iothreadadd --domain fc5 --id 2 iothreadinfo --domain fc5 diff --git a/tests/virshtestdata/iothreads.out b/tests/virshtestdata/iothreads.out index 4526a00313..a51593d765 100644 --- a/tests/virshtestdata/iothreads.out +++ b/tests/virshtestdata/iothreads.out @@ -44,6 +44,20 @@ Domain: 'fc4' iothread.6.poll-weight=0 +Domain: 'fc4' + state.state=1 + state.reason=0 + iothread.count=2 + iothread.4.poll-max-ns=32768 + iothread.4.poll-grow=0 + iothread.4.poll-shrink=0 + iothread.4.poll-weight=0 + iothread.6.poll-max-ns=100 + iothread.6.poll-grow=10 + iothread.6.poll-shrink=10 + iothread.6.poll-weight=3 + + IOThread ID CPU Affinity ----------------------------- 2 0-3 diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 0f177fb69a..c5158889cc 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -8271,6 +8271,11 @@ static const vshCmdOptDef opts_iothreadset[] = { .unwanted_positional = true, .help = N_("set the value for reduction of the IOThread polling time") }, + {.name = "poll-weight", + .type = VSH_OT_INT, + .unwanted_positional = true, + .help = N_("set the adaptive polling weight factor") + }, {.name = "thread-pool-min", .type = VSH_OT_INT, .unwanted_positional = true, @@ -8300,6 +8305,7 @@ cmdIOThreadSet(vshControl *ctl, const vshCmd *cmd) virTypedParameterPtr par; size_t npar = 0; unsigned long long poll_val; + unsigned int poll_weight; int thread_val; int rc; @@ -8336,6 +8342,17 @@ cmdIOThreadSet(vshControl *ctl, const vshCmd *cmd) if (rc > 0) virTypedParamListAddUnsigned(params, poll_val, VIR_DOMAIN_IOTHREAD_POLL_SHRINK); + if ((rc = vshCommandOptUInt(ctl, cmd, "poll-weight", &poll_weight)) < 0) + return false; + if (rc > 0) { + if (poll_weight > 63) { + vshError(ctl, _("poll-weight value %1$u is out of range [0, 63]"), + poll_weight); + return false; + } + virTypedParamListAddUInt(params, poll_weight, VIR_DOMAIN_IOTHREAD_POLL_WEIGHT); + } + if ((rc = vshCommandOptInt(ctl, cmd, "thread-pool-min", &thread_val)) < 0) return false; if (rc > 0) -- 2.54.0
