History

workqueue/hotplug: simplify workqueue_offline_cpu()

Since the recent cpu/hotplug refactoring, workqueue_offline_cpu() is guaranteed to run on the local cpu which is going offline. This also fixes the following deadlock by removing work item scheduling and flushing from CPU hotplug path. http://lkml.kernel.org/r/1504764252-29091-1-git-send-email-prsood@codeaurora.org tj: Description update.

Lai Jiangshan committed 8 years ago

Commit e8b3f8d1 parent c98a9801 file · +6 −9Browse files

Showing the changes to kernel/workqueue.c (1 of 1 file). Show all

Unified · Split

kernel/workqueue.c+6−9
@@ -1635,7 +1635,7 @@ static void worker_enter_idle(struct worker *worker) · 1634 unmodified lines
16351635 mod_timer(&pool->idle_timer, jiffies + IDLE_WORKER_TIMEOUT);
16361636
16371637 /*
1638− * Sanity check nr_running. Because wq_unbind_fn() releases
1638+ * Sanity check nr_running. Because unbind_workers() releases
16391639 * pool->lock between setting %WORKER_UNBOUND and zapping
16401640 * nr_running, the warning may trigger spuriously. Check iff
16411641 * unbind is not in progress.
@@ -4511,9 +4511,8 @@ void show_workqueue_state(void) · 2869 unmodified lines
45114511 * cpu comes back online.
45124512 */
45134513
4514−static void wq_unbind_fn(struct work_struct *work)
4514+static void unbind_workers(int cpu)
45154515 {
4516− int cpu = smp_processor_id();
45174516 struct worker_pool *pool;
45184517 struct worker *worker;
45194518
@@ -4710,12 +4709,13 @@ int workqueue_online_cpu(unsigned int cpu) · 190 unmodified lines
47104709
47114710 int workqueue_offline_cpu(unsigned int cpu)
47124711 {
4713− struct work_struct unbind_work;
47144712 struct workqueue_struct *wq;
47154713
47164714 /* unbinding per-cpu workers should happen on the local CPU */
4717− INIT_WORK_ONSTACK(&unbind_work, wq_unbind_fn);
4718− queue_work_on(cpu, system_highpri_wq, &unbind_work);
4715+ if (WARN_ON(cpu != smp_processor_id()))
4716+ return -1;
4717+
4718+ unbind_workers(cpu);
47194719
47204720 /* update NUMA affinity of unbound workqueues */
47214721 mutex_lock(&wq_pool_mutex);
@@ -4723,9 +4723,6 @@ int workqueue_offline_cpu(unsigned int cpu) · 1 unmodified line
47234723 wq_update_unbound_numa(wq, cpu, false);
47244724 mutex_unlock(&wq_pool_mutex);
47254725
4726− /* wait for per-cpu unbinding to finish */
4727− flush_work(&unbind_work);
4728− destroy_work_on_stack(&unbind_work);
47294726 return 0;
47304727 }
47314728

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t