[sheepdog] [PATCH 4/4] work: make pending lock fine grain
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Tue Oct 22 09:13:13 CEST 2013
Current queue_work() locks worker_info->pending_lock before growing a
number of worker threads (if it is required). Clearly this behavior
harms performance. This patch makes the lock fine grain.
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
lib/work.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/work.c b/lib/work.c
index 57b38dd..d27aee1 100644
--- a/lib/work.c
+++ b/lib/work.c
@@ -232,12 +232,11 @@ 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_queued_work);
- 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