lkml.org 
[lkml]   [2014]   [May]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] workqueue: remove the unneeded cpu_relax() in __queue_work()
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


\
 
 \ /
  Last update: 2014-05-22 16:21    [W:2.148 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site