[sheepdog] [PATCH v5 2/3] work: make locking by queue_work() more fine grain
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Wed Dec 18 07:43:56 CET 2013
wi->nr_threads is protected by wi->startup_lock now, we can make the
critical section in queue_work() smaller.
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
lib/work.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/work.c b/lib/work.c
index 2969c21..7fd9c45 100644
--- a/lib/work.c
+++ b/lib/work.c
@@ -277,12 +277,12 @@ void queue_work(struct work_queue *q, struct work *work)
struct worker_info *wi = container_of(q, struct worker_info, q);
uatomic_inc(&wi->nr_workers);
- pthread_mutex_lock(&wi->pending_lock);
if (wq_need_grow(wi))
/* double the thread pool size */
create_worker_threads(wi, wi->nr_threads * 2);
+ pthread_mutex_lock(&wi->pending_lock);
list_add_tail(&work->w_list, &wi->q.pending_list);
pthread_mutex_unlock(&wi->pending_lock);
--
1.7.10.4
More information about the sheepdog
mailing list