mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: Tejun Heo <tj@kernel.org>, linux-kernel@vger.kernel.org
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Subject: [V2 for-next PATCH 3/7] workqueue: new day don't need WORKER_REBIND for busy rebinding
Date: Mon, 17 Sep 2012 23:46:44 +0800	[thread overview]
Message-ID: <1347896808-2398-4-git-send-email-laijs@cn.fujitsu.com> (raw)
In-Reply-To: <1347896808-2398-1-git-send-email-laijs@cn.fujitsu.com>

because old busy_worker_rebind_fn() have to wait until all idle worker finish.
so we have to use two flags WORKER_UNBOUND and WORKER_REBIND to avoid
prematurely clear all NOT_RUNNING bit when highly frequent offline/online.

but current code don't need to wait idle workers nor release gcwq->lock
when it is doing rebind in rebind_workers(), so we don't need to use two flags,
just one is enough. remove WORKER_REBIND from busy rebinding.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 kernel/workqueue.c |   19 ++-----------------
 1 files changed, 2 insertions(+), 17 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index dbc942e..6b643df 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1642,17 +1642,8 @@ static void busy_worker_rebind_fn(struct work_struct *work)
 	struct worker *worker = container_of(work, struct worker, rebind_work);
 	struct global_cwq *gcwq = worker->pool->gcwq;
 
-	worker_maybe_bind_and_lock(worker);
-
-	/*
-	 * If hotplug has happened after rebind_workers(), a new %UNBOUND will
-	 * have been set in worker->flags, so we can clear WORKER_REBIND
-	 * unconditionaly(even the above worker_maybe_bind_and_lock() failed).
-	 *
-	 * And we must clear this WORKER_REBIND before return, otherwise
-	 * this worker may go to call idle_worker_rebind() wrongly.
-	 */
-	worker_clr_flags(worker, WORKER_REBIND);
+	if (worker_maybe_bind_and_lock(worker))
+		worker_clr_flags(worker, WORKER_UNBOUND);
 
 	spin_unlock_irq(&gcwq->lock);
 }
@@ -1727,15 +1718,9 @@ static void rebind_workers(struct global_cwq *gcwq)
 
 	/* rebind busy workers */
 	for_each_busy_worker(worker, i, pos, gcwq) {
-		unsigned long worker_flags = worker->flags;
 		struct work_struct *rebind_work = &worker->rebind_work;
 		struct workqueue_struct *wq;
 
-		/* morph UNBOUND to REBIND atomically */
-		worker_flags &= ~WORKER_UNBOUND;
-		worker_flags |= WORKER_REBIND;
-		ACCESS_ONCE(worker->flags) = worker_flags;
-
 		if (test_and_set_bit(WORK_STRUCT_PENDING_BIT,
 				     work_data_bits(rebind_work)))
 			continue;
-- 
1.7.4.4


  parent reply	other threads:[~2012-09-17 15:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-17 15:46 [V2 for-next PATCH 0/7] workqueue: async idle rebinding and cleanup for hotplug Lai Jiangshan
2012-09-17 15:46 ` [V2 for-3.6-fixes PATCH 1/7] workqueue: clear WORKER_REBIND unconditionaly in busy_worker_rebind_fn() Lai Jiangshan
2012-09-17 15:46 ` [V2 for-next PATCH 2/7] workqueue: async idle rebinding Lai Jiangshan
2012-09-17 15:46 ` Lai Jiangshan [this message]
2012-09-17 15:46 ` [V2 for-next PATCH 4/7] workqueue: remove WORKER_REBIND Lai Jiangshan
2012-09-17 15:46 ` [V2 for-next PATCH 5/7] workqueue: rename manager_mutex to assoc_mutex Lai Jiangshan
2012-09-17 15:46 ` [V2 for-next PATCH 6/7] workqueue: use __cpuinit instead of __devinit for cpu callback Lai Jiangshan
2012-09-17 15:46 ` [V2 for-next PATCH 7/7] workqueue: use hotcpu_notifier() for workqueue_cpu_down_callback() Lai Jiangshan
2012-09-18  9:40 ` [V2 for-next PATCH 0/7] workqueue: async idle rebinding and cleanup for hotplug Lai Jiangshan
2012-09-18 17:03   ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1347896808-2398-4-git-send-email-laijs@cn.fujitsu.com \
    --to=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®