Prev: [RFC][PATCH 09/13] perf: Reduce perf_disable() usage
Next: [PATCH 2/3] perf probe: Support comp_dir to find an absolute source path
From: Yong Zhang on 9 Jul 2010 05:20 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(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |