mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-22 14:41:27 +00:00
workqueue: fix locking in retry path of maybe_create_worker()
maybe_create_worker() mismanaged locking when worker creation fails and it has to retry. Fix locking and simplify lock manipulation. Signed-off-by: Tejun Heo <tj@kernel.org> Reported-by: Yong Zhang <yong.zhang@windriver.com>
This commit is contained in:
parent
083b804c4d
commit
9f9c23644b
1 changed files with 3 additions and 5 deletions
|
@ -1442,14 +1442,14 @@ static bool maybe_create_worker(struct global_cwq *gcwq)
|
||||||
if (!need_to_create_worker(gcwq))
|
if (!need_to_create_worker(gcwq))
|
||||||
return false;
|
return false;
|
||||||
restart:
|
restart:
|
||||||
|
spin_unlock_irq(&gcwq->lock);
|
||||||
|
|
||||||
/* if we don't make progress in MAYDAY_INITIAL_TIMEOUT, call for help */
|
/* if we don't make progress in MAYDAY_INITIAL_TIMEOUT, call for help */
|
||||||
mod_timer(&gcwq->mayday_timer, jiffies + MAYDAY_INITIAL_TIMEOUT);
|
mod_timer(&gcwq->mayday_timer, jiffies + MAYDAY_INITIAL_TIMEOUT);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
struct worker *worker;
|
struct worker *worker;
|
||||||
|
|
||||||
spin_unlock_irq(&gcwq->lock);
|
|
||||||
|
|
||||||
worker = create_worker(gcwq, true);
|
worker = create_worker(gcwq, true);
|
||||||
if (worker) {
|
if (worker) {
|
||||||
del_timer_sync(&gcwq->mayday_timer);
|
del_timer_sync(&gcwq->mayday_timer);
|
||||||
|
@ -1462,15 +1462,13 @@ restart:
|
||||||
if (!need_to_create_worker(gcwq))
|
if (!need_to_create_worker(gcwq))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
spin_unlock_irq(&gcwq->lock);
|
|
||||||
__set_current_state(TASK_INTERRUPTIBLE);
|
__set_current_state(TASK_INTERRUPTIBLE);
|
||||||
schedule_timeout(CREATE_COOLDOWN);
|
schedule_timeout(CREATE_COOLDOWN);
|
||||||
spin_lock_irq(&gcwq->lock);
|
|
||||||
if (!need_to_create_worker(gcwq))
|
if (!need_to_create_worker(gcwq))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_unlock_irq(&gcwq->lock);
|
|
||||||
del_timer_sync(&gcwq->mayday_timer);
|
del_timer_sync(&gcwq->mayday_timer);
|
||||||
spin_lock_irq(&gcwq->lock);
|
spin_lock_irq(&gcwq->lock);
|
||||||
if (need_to_create_worker(gcwq))
|
if (need_to_create_worker(gcwq))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue