public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] workqueue: remove the unneeded cpu_relax() in __queue_work()
@ 2014-05-22  8:44 Lai Jiangshan
  2014-05-22 13:47 ` Tejun Heo
  0 siblings, 1 reply; 7+ messages in thread
From: Lai Jiangshan @ 2014-05-22  8:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Tejun Heo, Lai Jiangshan

When pwq->refcnt == 0, the retrying is guaranteed to make forward-progress.
The comment above the code explains it well:

	/*
	 * pwq is determined and locked.  For unbound pools, we could have
	 * raced with pwq release and it could already be dead.  If its
	 * refcnt is zero, repeat pwq selection.  Note that pwqs never die
	 * without another pwq replacing it in the numa_pwq_tbl or while
	 * work items are executing on it, so the retrying is guaranteed to
	 * make forward-progress.
	 */

It means the cpu_relax() here is useless and sometimes misleading,
it should retry directly and make some progress rather than waste time.

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

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 23f9a2b..98b38b5 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1368,7 +1368,6 @@ retry:
 	if (unlikely(!pwq->refcnt)) {
 		if (wq->flags & WQ_UNBOUND) {
 			spin_unlock(&pwq->pool->lock);
-			cpu_relax();
 			goto retry;
 		}
 		/* oops */
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-05-26 10:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-22  8:44 [PATCH] workqueue: remove the unneeded cpu_relax() in __queue_work() Lai Jiangshan
2014-05-22 13:47 ` Tejun Heo
2014-05-22 14:21   ` Lai Jiangshan
2014-05-26  3:19     ` Lai Jiangshan
2014-05-26  4:23     ` Tejun Heo
2014-05-26  5:27       ` Lai Jiangshan
2014-05-26 10:54         ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox