mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] workqueue: remove the unneeded cpu_relax() in __queue_work()
Date: Thu, 22 May 2014 09:47:58 -0400	[thread overview]
Message-ID: <20140522134758.GA5065@htj.dyndns.org> (raw)
In-Reply-To: <1400748257-14165-1-git-send-email-laijs@cn.fujitsu.com>

On Thu, May 22, 2014 at 04:44:16PM +0800, Lai Jiangshan wrote:
> 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.

cpu_relax() doesn't have much to do with guaranteeing forward
progress.  It's about giving a breather during busy wait so that the
waiting cpu doesn't busy loop claiming the same cache lines over and
over ultimately delaying the event being waited on.  If you're doing a
busy wait, you better use cpu_relax().

Thanks.

-- 
tejun

  reply	other threads:[~2014-05-22 13:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-22  8:44 Lai Jiangshan
2014-05-22 13:47 ` Tejun Heo [this message]
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

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=20140522134758.GA5065@htj.dyndns.org \
    --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

all inboxes | Powered by JetHome®