On 29.03.2016 09:51, Erik Skultety wrote: > In order for the client to see all thread counts and limits, current total > and free worker count getters need to be introduced. Client might also be > interested in the job queue length, so provide a getter for that too. > --- > src/libvirt_private.syms | 3 +++ > src/util/virthreadpool.c | 15 +++++++++++++++ > src/util/virthreadpool.h | 3 +++ > 3 files changed, 21 insertions(+) > > diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms > index af133c5..c2bff17 100644 > --- a/src/libvirt_private.syms > +++ b/src/libvirt_private.syms > @@ -2333,6 +2333,9 @@ virThreadJobSetWorker; > > # util/virthreadpool.h > virThreadPoolFree; > +virThreadPoolGetCurrentWorkers; > +virThreadPoolGetFreeWorkers; > +virThreadPoolGetJobQueueDepth; > virThreadPoolGetMaxWorkers; > virThreadPoolGetMinWorkers; > virThreadPoolGetPriorityWorkers; > diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c > index e2e9fe4..518b880 100644 > --- a/src/util/virthreadpool.c > +++ b/src/util/virthreadpool.c > @@ -299,6 +299,21 @@ size_t virThreadPoolGetPriorityWorkers(virThreadPoolPtr > pool) > return pool->nPrioWorkers; > } > > +size_t virThreadPoolGetCurrentWorkers(virThreadPoolPtr pool) > +{ > + return pool->nWorkers; > +} > + > +size_t virThreadPoolGetFreeWorkers(virThreadPoolPtr pool) > +{ > + return pool->freeWorkers; > +} > + > +size_t virThreadPoolGetJobQueueDepth(virThreadPoolPtr pool) > +{ > + return pool->jobQueueDepth; > +} > +
I think these APIs should lock the @pool. Reason why pre-existing ones don't do that is because so far there's no way how to change values they're getting at runtime. So basically, once the pool is created, their value is static. But that's not the case for freeWorkers nor nWorkers, nor jobQueueDepth. I know these will be called with server locked. But if there are some jobs in the queue thread pool will process them regardless of server lock. Therefore value of freeWorkers, jobQueueDepth and nWorkers can change. I think all of these APIs should lock as soon as your patches are in, because after that even those values considered static now can change. > /* > * @priority - job priority > * Return: 0 on success, -1 otherwise > diff --git a/src/util/virthreadpool.h b/src/util/virthreadpool.h > index 538b62f..bc0c907 100644 > --- a/src/util/virthreadpool.h > +++ b/src/util/virthreadpool.h > @@ -46,6 +46,9 @@ virThreadPoolPtr virThreadPoolNewFull(size_t minWorkers, > size_t virThreadPoolGetMinWorkers(virThreadPoolPtr pool); > size_t virThreadPoolGetMaxWorkers(virThreadPoolPtr pool); > size_t virThreadPoolGetPriorityWorkers(virThreadPoolPtr pool); > +size_t virThreadPoolGetCurrentWorkers(virThreadPoolPtr pool); > +size_t virThreadPoolGetFreeWorkers(virThreadPoolPtr pool); > +size_t virThreadPoolGetJobQueueDepth(virThreadPoolPtr pool); > > void virThreadPoolFree(virThreadPoolPtr pool); > > Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list