[libvirt] [PATCH v2 09/10] admin: Introduce virAdmServerSetThreadPoolParameters

Michal Privoznik mprivozn at redhat.com
Fri Apr 1 15:33:13 UTC 2016


On 29.03.2016 09:51, Erik Skultety wrote:
> Since threadpool increments the current number of threads according to current
> load, i.e. how many jobs are waiting in the queue. The count however, is
> constrained by max and min limits of workers. The logic of this new API works
> like this:
>     1) setting the minimum
>         a) When the limit is increased, depending on the current number of
>            threads, new threads are possibly spawned if the current number of
>            threads is less than the new minimum limit
>         b) Decreasing the minimum limit has no possible effect on the current
>            number of threads
>     2) setting the maximum
>         a) Icreasing the maximum limit has no immediate effect on the current
>            number of threads, it only allows the threadpool to spawn more
>            threads when new jobs, that would otherwise end up queued, arrive.
>         b) Decreasing the maximum limit may affect the current number of
>            threads, if the current number of threads is less than the new
>            maximum limit. Since there may be some ongoing time-consuming jobs
>            that would effectively block this API from killing any threads.
>            Therefore, this API is asynchronous with best-effort execution,
>            i.e. the necessary number of workers will be terminated once they
>            finish their previous job, unless other workers had already
>            terminated, decreasing the limit to the requested value.
>     3) setting priority workers
>         - both increase and decrease in count of these workers have an
>           immediate impact on the current number of workers, new ones will be
>           spawned or some of them get terminated respectively.
> ---
>  daemon/admin.c                  | 43 +++++++++++++++++++++++
>  daemon/admin_server.c           | 43 +++++++++++++++++++++++
>  daemon/admin_server.h           |  5 +++
>  include/libvirt/libvirt-admin.h |  5 +++
>  src/admin/admin_protocol.x      | 13 ++++++-
>  src/admin/admin_remote.c        | 34 ++++++++++++++++++
>  src/admin_protocol-structs      |  9 +++++
>  src/libvirt-admin.c             | 37 ++++++++++++++++++++
>  src/libvirt_admin_private.syms  |  1 +
>  src/libvirt_admin_public.syms   |  1 +
>  src/libvirt_private.syms        |  1 +
>  src/rpc/virnetserver.c          | 15 ++++++++
>  src/util/virthreadpool.c        | 77 +++++++++++++++++++++++++++++++++++++++--
>  src/util/virthreadpool.h        |  5 +++
>  14 files changed, 285 insertions(+), 4 deletions(-)
> 


> diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c
> index c528f79..9b31ad2 100644
> --- a/src/libvirt-admin.c
> +++ b/src/libvirt-admin.c
> @@ -720,3 +720,40 @@ virAdmServerGetThreadPoolParameters(virAdmServerPtr srv,
>      virDispatchError(NULL);
>      return -1;
>  }
> +
> +/**
> + * virAdmServerSetThreadPoolParameters:
> + * @srv: a valid server object reference
> + * @params: pointer to threadpool parameter objects
> + * @nparams: number of parameters in @params
> + * @flags: bitwise-OR of extra flags virAdmServerSetThreadPoolParametersFlags
> + *
> + * Change server threadpool parameters according to @params. Note that some
> + * tunables are read-only, thus any attempt to set them will result in a
> + * failure.
> + *
> + * Returns 0 on success, -1 in case of an error.
> + */
> +int
> +virAdmServerSetThreadPoolParameters(virAdmServerPtr srv,
> +                                    virTypedParameterPtr params,
> +                                    int nparams,
> +                                    unsigned int flags)
> +{
> +    VIR_DEBUG("srv=%p, params=%p, nparams=%x, flags=%x",
> +              srv, params, nparams, flags);
> +
> +    virResetLastError();
> +
> +    virCheckAdmServerReturn(srv, NULL);

Function is returning an int, not a pointer.

> +    virCheckNonNullArgGoto(params, error);
> +
> +    if (remoteAdminServerSetThreadPoolParameters(srv, params,
> +                                                 nparams, flags) < 0)
> +        goto error;
> +
> +    return 0;
> + error:
> +    virDispatchError(NULL);
> +    return -1;
> +}

Michal




More information about the libvir-list mailing list