init_workqueues() incorrectly marks workqueues for all possible CPUs associated. Combined with mayday_mask initialization bug, this can make rescuers keep trying to bind to an offline gcwq indefinitely. Fix init_workqueues() such that only online CPUs have their gcwqs have GCWQ_DISASSOCIATED cleared.
Showing the changes to kernel/workqueue.c (1 of 1 file). Show all
Unified · Split
| @@ -3558,8 +3558,7 @@ static int __init init_workqueues(void) · 3557 unmodified lines | |||
| 3558 | spin_lock_init(&gcwq->lock); | 3558 | spin_lock_init(&gcwq->lock); |
| 3559 | INIT_LIST_HEAD(&gcwq->worklist); | 3559 | INIT_LIST_HEAD(&gcwq->worklist); |
| 3560 | gcwq->cpu = cpu; | 3560 | gcwq->cpu = cpu; |
| 3561 | if (cpu == WORK_CPU_UNBOUND) | 3561 | gcwq->flags |= GCWQ_DISASSOCIATED; |
| 3562 | gcwq->flags |= GCWQ_DISASSOCIATED; | ||
| 3563 | 3562 | ||
| 3564 | INIT_LIST_HEAD(&gcwq->idle_list); | 3563 | INIT_LIST_HEAD(&gcwq->idle_list); |
| 3565 | for (i = 0; i < BUSY_WORKER_HASH_SIZE; i++) | 3564 | for (i = 0; i < BUSY_WORKER_HASH_SIZE; i++) |
| @@ -3583,6 +3582,8 @@ static int __init init_workqueues(void) · 17 unmodified lines | |||
| 3583 | struct global_cwq *gcwq = get_gcwq(cpu); | 3582 | struct global_cwq *gcwq = get_gcwq(cpu); |
| 3584 | struct worker *worker; | 3583 | struct worker *worker; |
| 3585 | 3584 | ||
| 3585 | if (cpu != WORK_CPU_UNBOUND) | ||
| 3586 | gcwq->flags &= ~GCWQ_DISASSOCIATED; | ||
| 3586 | worker = create_worker(gcwq, true); | 3587 | worker = create_worker(gcwq, true); |
| 3587 | BUG_ON(!worker); | 3588 | BUG_ON(!worker); |
| 3588 | spin_lock_irq(&gcwq->lock); | 3589 | spin_lock_irq(&gcwq->lock); |