[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100709091138.GA7304@windriver.com>
Date: Fri, 9 Jul 2010 17:11:38 +0800
From: Yong Zhang <yong.zhang@...driver.com>
To: Tejun Heo <tj@...nel.org>
Cc: torvalds@...ux-foundation.org, mingo@...e.hu,
linux-kernel@...r.kernel.org, jeff@...zik.org,
akpm@...ux-foundation.org, rusty@...tcorp.com.au,
cl@...ux-foundation.org, dhowells@...hat.com,
arjan@...ux.intel.com, oleg@...hat.com, axboe@...nel.dk,
fweisbec@...il.com, dwalker@...eaurora.org,
stefanr@...6.in-berlin.de, florian@...kler.org,
andi@...stfloor.org, mst@...hat.com, randy.dunlap@...cle.com
Subject: Re: [PATCH 27/35] workqueue: implement concurrency managed dynamic
worker pool
On Mon, Jun 28, 2010 at 11:04:15PM +0200, Tejun Heo wrote:
> +static bool maybe_create_worker(struct global_cwq *gcwq)
> +{
> + if (!need_to_create_worker(gcwq))
> + return false;
> +restart:
> + /* if we don't make progress in MAYDAY_INITIAL_TIMEOUT, call for help */
> + mod_timer(&gcwq->mayday_timer, jiffies + MAYDAY_INITIAL_TIMEOUT);
> +
> + while (true) {
> + struct worker *worker;
> +
> + spin_unlock_irq(&gcwq->lock);
> +
> + worker = create_worker(gcwq, true);
> + if (worker) {
> + del_timer_sync(&gcwq->mayday_timer);
> + spin_lock_irq(&gcwq->lock);
> + start_worker(worker);
> + BUG_ON(need_to_create_worker(gcwq));
> + return true;
> + }
> +
> + if (!need_to_create_worker(gcwq))
> + break;
> +
> + spin_unlock_irq(&gcwq->lock);
> + __set_current_state(TASK_INTERRUPTIBLE);
> + schedule_timeout(CREATE_COOLDOWN);
> + spin_lock_irq(&gcwq->lock);
> + if (!need_to_create_worker(gcwq))
> + break;
> + }
> +
> + spin_unlock_irq(&gcwq->lock);
A little worried about the lock operation. We may call spin_unlock_irq() twice
under some special situation. Couldn't that happen? Or Am I missing something?
And a rough patch for this issue if needed:
---
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 2eb9fbd..84a9cb9 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1427,10 +1427,11 @@ restart:
return true;
}
- if (!need_to_create_worker(gcwq))
+ if (!need_to_create_worker(gcwq)) {
+ spin_lock_irq(&gcwq->lock);
break;
+ }
- spin_unlock_irq(&gcwq->lock);
__set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(CREATE_COOLDOWN);
spin_lock_irq(&gcwq->lock);
> + del_timer_sync(&gcwq->mayday_timer);
> + spin_lock_irq(&gcwq->lock);
> + if (need_to_create_worker(gcwq))
> + goto restart;
> + return true;
> +}
> +
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists