From: Tejun Heo <tj@kernel.org>
To: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH wq/for-3.6-fixes 3/3] workqueue: fix possible idle worker depletion during CPU_ONLINE
Date: Fri, 7 Sep 2012 12:25:56 -0700 [thread overview]
Message-ID: <20120907192556.GE9426@google.com> (raw)
In-Reply-To: <50495395.10407@cn.fujitsu.com>
Hello, Lai.
On Fri, Sep 07, 2012 at 09:53:25AM +0800, Lai Jiangshan wrote:
> > This patch fixes the bug by releasing manager_mutexes before letting
> > the rebound idle workers go. This ensures that by the time idle
> > workers check whether management is necessary, CPU_ONLINE already has
> > released the positions.
>
> This can't fix the problem.
>
> + gcwq_claim_management(gcwq);
> + spin_lock_irq(&gcwq->lock);
>
>
> If manage_workers() happens between the two line, the problem occurs!.
Indeed. I was only looking at rebinding completion. Hmmm... I
suppose any simple solution is out of window at this point. I guess
we'll have to defer the fix to 3.7. I reverted the posted patches.
> My non_manager_role_manager_mutex_unlock() approach has the same
> idea: release manage_mutex before release gcwq->lock. but
> non_manager_role_manager_mutex_unlock() approach will detect the
> fail reason of failing to grab manage_lock and go to sleep.
> rebind_workers()/gcwq_unbind_fn() will release manage_mutex and then
> wait up some before release gcwq->lock.
Can you please try to fit the text to 80 column? It would be much
easier to read.
> A "release manage_mutex before release gcwq->lock" approach.(no one
> likes it, I think)
>
>
> /* claim manager positions of all pools */
> static void gcwq_claim_management_and_lock(struct global_cwq *gcwq)
> {
> struct worker_pool *pool, *pool_fail;
>
> again:
> spin_lock_irq(&gcwq->lock);
> for_each_worker_pool(pool, gcwq) {
> if (!mutex_trylock(&pool->manager_mutex))
> goto fail;
> }
> return;
>
> fail: /* unlikely, because manage_workers() are very unlike path in my box */
>
> for_each_worker_pool(pool_fail, gcwq) {
> if (pool_fail != pool)
> mutex_unlock(&pool->manager_mutex);
> else
> break;
> }
> spin_unlock_irq(&gcwq->lock);
> cpu_relax();
> goto again;
> }
Yeah, that's kinda ugly and also has the potential to cause extended
period of busy looping. Let's think of something else.
Thanks.
--
tejun
next prev parent reply other threads:[~2012-09-07 19:26 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-06 20:06 [PATCH wq/for-3.6-fixes 1/3] workqueue: break out gcwq->lock locking from gcwq_claim/release_management_and_[un]lock() Tejun Heo
2012-09-06 20:07 ` [PATCH wq/for-3.6-fixes 2/3] workqueue: rename rebind_workers() to gcwq_associate() and let it handle locking and DISASSOCIATED clearing Tejun Heo
2012-09-06 20:08 ` [PATCH wq/for-3.6-fixes 3/3] workqueue: fix possible idle worker depletion during CPU_ONLINE Tejun Heo
2012-09-07 1:53 ` Lai Jiangshan
2012-09-07 19:25 ` Tejun Heo [this message]
2012-09-07 3:10 ` Lai Jiangshan
2012-09-07 19:29 ` Tejun Heo
2012-09-07 20:22 ` Tejun Heo
2012-09-07 20:34 ` Tejun Heo
2012-09-07 23:05 ` Tejun Heo
2012-09-07 23:07 ` Tejun Heo
2012-09-07 23:41 ` Tejun Heo
2012-09-08 17:18 ` Lai Jiangshan
2012-09-08 17:29 ` Tejun Heo
2012-09-08 17:32 ` Tejun Heo
2012-09-08 17:40 ` Lai Jiangshan
2012-09-08 17:41 ` 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=20120907192556.GE9426@google.com \
--to=tj@kernel.org \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.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