<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/kernel/workqueue.c, branch linux-3.5.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-3.5.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-3.5.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2012-10-12T20:46:56Z</updated>
<entry>
<title>workqueue: add missing smp_wmb() in process_one_work()</title>
<updated>2012-10-12T20:46:56Z</updated>
<author>
<name>Tejun Heo</name>
</author>
<published>2012-08-03T17:30:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=aeda28cd8dcbf2bde2194a447225f83a4a430e8c'/>
<id>urn:sha1:aeda28cd8dcbf2bde2194a447225f83a4a430e8c</id>
<content type='text'>
commit 959d1af8cffc8fd38ed53e8be1cf4ab8782f9c00 upstream.

WORK_STRUCT_PENDING is used to claim ownership of a work item and
process_one_work() releases it before starting execution.  When
someone else grabs PENDING, all pre-release updates to the work item
should be visible and all updates made by the new owner should happen
afterwards.

Grabbing PENDING uses test_and_set_bit() and thus has a full barrier;
however, clearing doesn't have a matching wmb.  Given the preceding
spin_unlock and use of clear_bit, I don't believe this can be a
problem on an actual machine and there hasn't been any related report
but it still is theretically possible for clear_pending to permeate
upwards and happen before work-&gt;entry update.

Add an explicit smp_wmb() before work_clear_pending().

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Oleg Nesterov &lt;oleg@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>workqueue: UNBOUND -&gt; REBIND morphing in rebind_workers() should be atomic</title>
<updated>2012-10-02T17:39:46Z</updated>
<author>
<name>Lai Jiangshan</name>
</author>
<published>2012-09-01T16:28:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=814b1489d0e0d0d869f3d675fb791478370de9d3'/>
<id>urn:sha1:814b1489d0e0d0d869f3d675fb791478370de9d3</id>
<content type='text'>
commit 96e65306b81351b656835c15931d1d237b252f27 upstream.

The compiler may compile the following code into TWO write/modify
instructions.

	worker-&gt;flags &amp;= ~WORKER_UNBOUND;
	worker-&gt;flags |= WORKER_REBIND;

so the other CPU may temporarily see worker-&gt;flags which doesn't have
either WORKER_UNBOUND or WORKER_REBIND set and perform local wakeup
prematurely.

Fix it by using single explicit assignment via ACCESS_ONCE().

Because idle workers have another WORKER_NOT_RUNNING flag, this bug
doesn't exist for them; however, update it to use the same pattern for
consistency.

tj: Applied the change to idle workers too and updated comments and
    patch description a bit.

Signed-off-by: Lai Jiangshan &lt;laijs@cn.fujitsu.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>workqueue: reimplement work_on_cpu() using system_wq</title>
<updated>2012-10-02T17:38:57Z</updated>
<author>
<name>Tejun Heo</name>
</author>
<published>2012-09-18T19:48:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a88ff36aef1f343074151a58926c5290e6c82b1e'/>
<id>urn:sha1:a88ff36aef1f343074151a58926c5290e6c82b1e</id>
<content type='text'>
commit ed48ece27cd3d5ee0354c32bbaec0f3e1d4715c3 upstream.

The existing work_on_cpu() implementation is hugely inefficient.  It
creates a new kthread, execute that single function and then let the
kthread die on each invocation.

Now that system_wq can handle concurrent executions, there's no
advantage of doing this.  Reimplement work_on_cpu() using system_wq
which makes it simpler and way more efficient.

stable: While this isn't a fix in itself, it's needed to fix a
        workqueue related bug in cpufreq/powernow-k8.  AFAICS, this
        shouldn't break other existing users.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: Jiri Kosina &lt;jkosina@suse.cz&gt;
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Cc: Len Brown &lt;lenb@kernel.org&gt;
Cc: Rafael J. Wysocki &lt;rjw@sisk.pl&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>workqueue: perform cpu down operations from low priority cpu_notifier()</title>
<updated>2012-08-09T15:22:54Z</updated>
<author>
<name>Tejun Heo</name>
</author>
<published>2012-07-17T19:39:26Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=20e2d5cef027128b99b459aeb2eca282146d15ba'/>
<id>urn:sha1:20e2d5cef027128b99b459aeb2eca282146d15ba</id>
<content type='text'>
commit 6575820221f7a4dd6eadecf7bf83cdd154335eda upstream.

Currently, all workqueue cpu hotplug operations run off
CPU_PRI_WORKQUEUE which is higher than normal notifiers.  This is to
ensure that workqueue is up and running while bringing up a CPU before
other notifiers try to use workqueue on the CPU.

Per-cpu workqueues are supposed to remain working and bound to the CPU
for normal CPU_DOWN_PREPARE notifiers.  This holds mostly true even
with workqueue offlining running with higher priority because
workqueue CPU_DOWN_PREPARE only creates a bound trustee thread which
runs the per-cpu workqueue without concurrency management without
explicitly detaching the existing workers.

However, if the trustee needs to create new workers, it creates
unbound workers which may wander off to other CPUs while
CPU_DOWN_PREPARE notifiers are in progress.  Furthermore, if the CPU
down is cancelled, the per-CPU workqueue may end up with workers which
aren't bound to the CPU.

While reliably reproducible with a convoluted artificial test-case
involving scheduling and flushing CPU burning work items from CPU down
notifiers, this isn't very likely to happen in the wild, and, even
when it happens, the effects are likely to be hidden by the following
successful CPU down.

Fix it by using different priorities for up and down notifiers - high
priority for up operations and low priority for down operations.

Workqueue cpu hotplug operations will soon go through further cleanup.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: "Rafael J. Wysocki" &lt;rjw@sisk.pl&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>lockdep: fix oops in processing workqueue</title>
<updated>2012-05-15T15:08:31Z</updated>
<author>
<name>Peter Zijlstra</name>
</author>
<published>2012-05-15T15:06:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4d82a1debbffec129cc387aafa8f40b7bbab3297'/>
<id>urn:sha1:4d82a1debbffec129cc387aafa8f40b7bbab3297</id>
<content type='text'>
Under memory load, on x86_64, with lockdep enabled, the workqueue's
process_one_work() has been seen to oops in __lock_acquire(), barfing
on a 0xffffffff00000000 pointer in the lockdep_map's class_cache[].

Because it's permissible to free a work_struct from its callout function,
the map used is an onstack copy of the map given in the work_struct: and
that copy is made without any locking.

Surprisingly, gcc (4.5.1 in Hugh's case) uses "rep movsl" rather than
"rep movsq" for that structure copy: which might race with a workqueue
user's wait_on_work() doing lock_map_acquire() on the source of the
copy, putting a pointer into the class_cache[], but only in time for
the top half of that pointer to be copied to the destination map.

Boom when process_one_work() subsequently does lock_map_acquire()
on its onstack copy of the lockdep_map.

Fix this, and a similar instance in call_timer_fn(), with a
lockdep_copy_map() function which additionally NULLs the class_cache[].

Note: this oops was actually seen on 3.4-next, where flush_work() newly
does the racing lock_map_acquire(); but Tejun points out that 3.4 and
earlier are already vulnerable to the same through wait_on_work().

* Patch orginally from Peter.  Hugh modified it a bit and wrote the
  description.

Signed-off-by: Peter Zijlstra &lt;peterz@infradead.org&gt;
Reported-by: Hugh Dickins &lt;hughd@google.com&gt;
LKML-Reference: &lt;alpine.LSU.2.00.1205070951170.1544@eggly.anvils&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueue: skip nr_running sanity check in worker_enter_idle() if trustee is active</title>
<updated>2012-05-14T22:04:50Z</updated>
<author>
<name>Tejun Heo</name>
</author>
<published>2012-05-14T22:04:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=544ecf310f0e7f51fa057ac2a295fc1b3b35a9d3'/>
<id>urn:sha1:544ecf310f0e7f51fa057ac2a295fc1b3b35a9d3</id>
<content type='text'>
worker_enter_idle() has WARN_ON_ONCE() which triggers if nr_running
isn't zero when every worker is idle.  This can trigger spuriously
while a cpu is going down due to the way trustee sets %WORKER_ROGUE
and zaps nr_running.

It first sets %WORKER_ROGUE on all workers without updating
nr_running, releases gcwq-&gt;lock, schedules, regrabs gcwq-&gt;lock and
then zaps nr_running.  If the last running worker enters idle
inbetween, it would see stale nr_running which hasn't been zapped yet
and trigger the WARN_ON_ONCE().

Fix it by performing the sanity check iff the trustee is idle.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Reported-by: "Paul E. McKenney" &lt;paulmck@linux.vnet.ibm.com&gt;
Cc: stable@vger.kernel.org
</content>
</entry>
<entry>
<title>workqueue: Catch more locking problems with flush_work()</title>
<updated>2012-04-23T18:06:42Z</updated>
<author>
<name>Stephen Boyd</name>
</author>
<published>2012-04-21T00:28:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0976dfc1d0cd80a4e9dfaf87bd8744612bde475a'/>
<id>urn:sha1:0976dfc1d0cd80a4e9dfaf87bd8744612bde475a</id>
<content type='text'>
If a workqueue is flushed with flush_work() lockdep checking can
be circumvented. For example:

 static DEFINE_MUTEX(mutex);

 static void my_work(struct work_struct *w)
 {
         mutex_lock(&amp;mutex);
         mutex_unlock(&amp;mutex);
 }

 static DECLARE_WORK(work, my_work);

 static int __init start_test_module(void)
 {
         schedule_work(&amp;work);
         return 0;
 }
 module_init(start_test_module);

 static void __exit stop_test_module(void)
 {
         mutex_lock(&amp;mutex);
         flush_work(&amp;work);
         mutex_unlock(&amp;mutex);
 }
 module_exit(stop_test_module);

would not always print a warning when flush_work() was called.
In this trivial example nothing could go wrong since we are
guaranteed module_init() and module_exit() don't run concurrently,
but if the work item is schedule asynchronously we could have a
scenario where the work item is running just at the time flush_work()
is called resulting in a classic ABBA locking problem.

Add a lockdep hint by acquiring and releasing the work item
lockdep_map in flush_work() so that we always catch this
potential deadlock scenario.

Signed-off-by: Stephen Boyd &lt;sboyd@codeaurora.org&gt;
Reviewed-by: Yong Zhang &lt;yong.zhang0@gmail.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueue: change BUG_ON() to WARN_ON()</title>
<updated>2012-04-16T21:54:59Z</updated>
<author>
<name>Dan Carpenter</name>
</author>
<published>2012-04-13T19:06:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f5b2552b4ebbeadcadde1532d7bbd3f850719046'/>
<id>urn:sha1:f5b2552b4ebbeadcadde1532d7bbd3f850719046</id>
<content type='text'>
This BUG_ON() can be triggered if you call schedule_work() before
calling INIT_WORK().  It is a bug definitely, but it's nicer to just
print a stack trace and return.

Reported-by: Matt Renzelmann &lt;mjr@cs.wisc.edu&gt;
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>Merge branch 'for-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq</title>
<updated>2012-03-21T01:13:22Z</updated>
<author>
<name>Linus Torvalds</name>
</author>
<published>2012-03-21T01:13:22Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e45836fafe157df137a837093037f741ad8f4c90'/>
<id>urn:sha1:e45836fafe157df137a837093037f741ad8f4c90</id>
<content type='text'>
Pull workqueue changes from Tejun Heo:
 "This contains only one commit which cleans up UP allocation path a
  bit."

* 'for-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq:
  workqueue: use percpu allocator for cwq on UP
</content>
</entry>
<entry>
<title>workqueue: use percpu allocator for cwq on UP</title>
<updated>2012-03-12T16:21:17Z</updated>
<author>
<name>Lai Jiangshan</name>
</author>
<published>2012-03-09T10:03:20Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e06ffa1ede4146cbc261d90f5dff3d63fe2e9d7a'/>
<id>urn:sha1:e06ffa1ede4146cbc261d90f5dff3d63fe2e9d7a</id>
<content type='text'>
I notice that the commit bbddff makes percpu allocator can work on UP,
So we don't need the magic way for UP.

Signed-off-by: Lai Jiangshan &lt;laijs@cn.fujitsu.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
</feed>
