mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] workqueue: remove the empty check in too_many_workers()
@ 2014-06-03  7:32 Lai Jiangshan
  2014-06-19 16:25 ` Tejun Heo
  0 siblings, 1 reply; 2+ messages in thread
From: Lai Jiangshan @ 2014-06-03  7:32 UTC (permalink / raw)
  To: linux-kernel; +Cc: Tejun Heo, Lai Jiangshan

The commit ea1abd6197d5 ("workqueue: reimplement idle worker rebinding")
used a trick which simply removes all to-be-bound idle workers from the
idle list and lets them add themselves back after completing rebinding.

And this trick caused the @worker_pool->nr_idle may deviate than the actual
number of idle workers on @worker_pool->idle_list.  More specifically,
nr_idle may be non-zero while ->idle_list is empty.  All users of
->nr_idle and ->idle_list are audited.  The only affected one is
too_many_workers() which is updated to check %false if ->idle_list is
empty regardless of ->nr_idle.

The commit/trick was complicated due to it just tried to simplify an even
more complicated problem (workers had to rebind itself). But the commit
a9ab775bcadf ("workqueue: directly restore CPU affinity of workers
from CPU_ONLINE") fixed all these problems and the mentioned trick was
useless and is gone.

So, now the @worker_pool->nr_idle is exactly the actual number of workers
on @worker_pool->idle_list. too_many_workers() should recover as it was
before the trick. So we remove the empty check.

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

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 724ae35..a1c2c10 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -758,13 +758,6 @@ static bool too_many_workers(struct worker_pool *pool)
 	int nr_idle = pool->nr_idle + managing; /* manager is considered idle */
 	int nr_busy = pool->nr_workers - nr_idle;
 
-	/*
-	 * nr_idle and idle_list may disagree if idle rebinding is in
-	 * progress.  Never return %true if idle_list is empty.
-	 */
-	if (list_empty(&pool->idle_list))
-		return false;
-
 	return nr_idle > 2 && (nr_idle - 2) * MAX_IDLE_WORKERS_RATIO >= nr_busy;
 }
 
-- 
1.7.4.4


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

* Re: [PATCH] workqueue: remove the empty check in too_many_workers()
  2014-06-03  7:32 [PATCH] workqueue: remove the empty check in too_many_workers() Lai Jiangshan
@ 2014-06-19 16:25 ` Tejun Heo
  0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2014-06-19 16:25 UTC (permalink / raw)
  To: Lai Jiangshan; +Cc: linux-kernel

On Tue, Jun 03, 2014 at 03:32:07PM +0800, Lai Jiangshan wrote:
> The commit ea1abd6197d5 ("workqueue: reimplement idle worker rebinding")
> used a trick which simply removes all to-be-bound idle workers from the
> idle list and lets them add themselves back after completing rebinding.
> 
> And this trick caused the @worker_pool->nr_idle may deviate than the actual
> number of idle workers on @worker_pool->idle_list.  More specifically,
> nr_idle may be non-zero while ->idle_list is empty.  All users of
> ->nr_idle and ->idle_list are audited.  The only affected one is
> too_many_workers() which is updated to check %false if ->idle_list is
> empty regardless of ->nr_idle.
> 
> The commit/trick was complicated due to it just tried to simplify an even
> more complicated problem (workers had to rebind itself). But the commit
> a9ab775bcadf ("workqueue: directly restore CPU affinity of workers
> from CPU_ONLINE") fixed all these problems and the mentioned trick was
> useless and is gone.
> 
> So, now the @worker_pool->nr_idle is exactly the actual number of workers
> on @worker_pool->idle_list. too_many_workers() should recover as it was
> before the trick. So we remove the empty check.
> 
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>

Applied to wq/for-3.17.

Thanks.

-- 
tejun

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

end of thread, other threads:[~2014-06-19 16:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-03  7:32 [PATCH] workqueue: remove the empty check in too_many_workers() Lai Jiangshan
2014-06-19 16:25 ` Tejun Heo

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®