[libvirt] [PATCH] fixed bug:if expand thread pool, will lose some one

Di Wei posted 1 patch 6 years, 3 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20180111153041.6047-1-dwlinuxkernel@163.com
src/util/virthreadpool.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[libvirt] [PATCH] fixed bug:if expand thread pool, will lose some one
Posted by Di Wei 6 years, 3 months ago
---
 src/util/virthreadpool.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c
index 10f2bd2..0983ee2 100644
--- a/src/util/virthreadpool.c
+++ b/src/util/virthreadpool.c
@@ -186,6 +186,7 @@ virThreadPoolExpand(virThreadPoolPtr pool, size_t gain, bool priority)
     size_t *curWorkers = priority ? &pool->nPrioWorkers : &pool->nWorkers;
     size_t i = 0;
     struct virThreadPoolWorkerData *data = NULL;
+    size_t oldNWorkers = *curWorkers;
 
     if (VIR_EXPAND_N(*workers, *curWorkers, gain) < 0)
         return -1;
@@ -198,7 +199,7 @@ virThreadPoolExpand(virThreadPoolPtr pool, size_t gain, bool priority)
         data->cond = priority ? &pool->prioCond : &pool->cond;
         data->priority = priority;
 
-        if (virThreadCreateFull(&(*workers)[i],
+        if (virThreadCreateFull(&(*workers)[i + oldNWorkers],
                                 false,
                                 virThreadPoolWorker,
                                 pool->jobFuncName,
-- 
2.9.3


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] fixed bug:if expand thread pool, will lose some one
Posted by Peter Krempa 6 years, 3 months ago
On Thu, Jan 11, 2018 at 23:30:41 +0800, Di Wei wrote:
> ---

Could you please provide more information on when this is happening and
what the consequences are? It's really not obvious from the summary and
it's required to be part of the commit message.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] fixed bug:if expand thread pool, will lose some one
Posted by diwei 6 years, 3 months ago
Sorry for that the information is not obvious.
I hope that the information below is sufficient.If need more information,let me know.


Bug’s consequence:
Assume that there is a threadpool like 

[ thread 1 | thread 2 | thread 3 ]

After expanding this threadpool with virThreadPoolExpand(ptr,1,priority), it should be

[ thread 1 | thread 2 | thread 3 | thread 4 ]

but the result will be

[ thread 4 | thread 2 | thread 3 | NULL ] 

the first one thread 1 is lost.





> 在 2018年1月12日,下午5:19,Peter Krempa <pkrempa@redhat.com> 写道:
> 
> On Thu, Jan 11, 2018 at 23:30:41 +0800, Di Wei wrote:
>> ---
> 
> Could you please provide more information on when this is happening and
> what the consequences are? It's really not obvious from the summary and
> it's required to be part of the commit message.



--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list