From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753274AbdLAOV3 (ORCPT ); Fri, 1 Dec 2017 09:21:29 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:42857 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752916AbdLAOV0 (ORCPT ); Fri, 1 Dec 2017 09:21:26 -0500 X-Google-Smtp-Source: AGs4zMbWA7/16gWxPlRQvVzyttjVB+WBNS+A12ePIgNVj++OpyaxdWlUTea7IFK+yK9hSkHn7+gdVg== From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Lai Jiangshan , Tejun Heo Subject: [PATCH] workqueue/hotplug: simplify workqueue_offline_cpu() Date: Fri, 1 Dec 2017 22:20:36 +0800 Message-Id: <20171201142036.22225-1-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.13.6 (Apple Git-96) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since the refactor for the cpu/hotplug is done, workqueue_offline_cpu() is ensured to be run on the local cpu which is going off. Signed-off-by: Lai Jiangshan --- kernel/workqueue.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 8fdb710bfdd7..5c99beb8577d 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1634,7 +1634,7 @@ static void worker_enter_idle(struct worker *worker) mod_timer(&pool->idle_timer, jiffies + IDLE_WORKER_TIMEOUT); /* - * Sanity check nr_running. Because wq_unbind_fn() releases + * Sanity check nr_running. Because unbind_workers() releases * pool->lock between setting %WORKER_UNBOUND and zapping * nr_running, the warning may trigger spuriously. Check iff * unbind is not in progress. @@ -4510,9 +4510,8 @@ void show_workqueue_state(void) * cpu comes back online. */ -static void wq_unbind_fn(struct work_struct *work) +static void unbind_workers(int cpu) { - int cpu = smp_processor_id(); struct worker_pool *pool; struct worker *worker; @@ -4709,12 +4708,13 @@ int workqueue_online_cpu(unsigned int cpu) int workqueue_offline_cpu(unsigned int cpu) { - struct work_struct unbind_work; struct workqueue_struct *wq; /* unbinding per-cpu workers should happen on the local CPU */ - INIT_WORK_ONSTACK(&unbind_work, wq_unbind_fn); - queue_work_on(cpu, system_highpri_wq, &unbind_work); + if (WARN_ON(cpu != smp_processor_id())) + return -1; + + unbind_workers(cpu); /* update NUMA affinity of unbound workqueues */ mutex_lock(&wq_pool_mutex); @@ -4722,9 +4722,6 @@ int workqueue_offline_cpu(unsigned int cpu) wq_update_unbound_numa(wq, cpu, false); mutex_unlock(&wq_pool_mutex); - /* wait for per-cpu unbinding to finish */ - flush_work(&unbind_work); - destroy_work_on_stack(&unbind_work); return 0; } -- 2.13.6 (Apple Git-96)