<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/workqueue.c, branch v4.5</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v4.5</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v4.5'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2016-02-10T17:13:05Z</updated>
<entry>
<title>workqueue: handle NUMA_NO_NODE for unbound pool_workqueue lookup</title>
<updated>2016-02-10T17:13:05Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2016-02-03T18:54:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d6e022f1d207a161cd88e08ef0371554680ffc46'/>
<id>urn:sha1:d6e022f1d207a161cd88e08ef0371554680ffc46</id>
<content type='text'>
When looking up the pool_workqueue to use for an unbound workqueue,
workqueue assumes that the target CPU is always bound to a valid NUMA
node.  However, currently, when a CPU goes offline, the mapping is
destroyed and cpu_to_node() returns NUMA_NO_NODE.

This has always been broken but hasn't triggered often enough before
874bbfe600a6 ("workqueue: make sure delayed work run in local cpu").
After the commit, workqueue forcifully assigns the local CPU for
delayed work items without explicit target CPU to fix a different
issue.  This widens the window where CPU can go offline while a
delayed work item is pending causing delayed work items dispatched
with target CPU set to an already offlined CPU.  The resulting
NUMA_NO_NODE mapping makes workqueue try to queue the work item on a
NULL pool_workqueue and thus crash.

While 874bbfe600a6 has been reverted for a different reason making the
bug less visible again, it can still happen.  Fix it by mapping
NUMA_NO_NODE to the default pool_workqueue from unbound_pwq_by_node().
This is a temporary workaround.  The long term solution is keeping CPU
-&gt; NODE mapping stable across CPU off/online cycles which is being
worked on.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Reported-by: Mike Galbraith &lt;umgwanakikbuti@gmail.com&gt;
Cc: Tang Chen &lt;tangchen@cn.fujitsu.com&gt;
Cc: Rafael J. Wysocki &lt;rafael@kernel.org&gt;
Cc: Len Brown &lt;len.brown@intel.com&gt;
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/g/1454424264.11183.46.camel@gmail.com
Link: http://lkml.kernel.org/g/1453702100-2597-1-git-send-email-tangchen@cn.fujitsu.com
</content>
</entry>
<entry>
<title>workqueue: implement "workqueue.debug_force_rr_cpu" debug feature</title>
<updated>2016-02-09T22:59:38Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2016-02-09T22:59:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f303fccb82928790ec58eea82722bd5c54d300b3'/>
<id>urn:sha1:f303fccb82928790ec58eea82722bd5c54d300b3</id>
<content type='text'>
Workqueue used to guarantee local execution for work items queued
without explicit target CPU.  The guarantee is gone now which can
break some usages in subtle ways.  To flush out those cases, this
patch implements a debug feature which forces round-robin CPU
selection for all such work items.

The debug feature defaults to off and can be enabled with a kernel
parameter.  The default can be flipped with a debug config option.

If you hit this commit during bisection, please refer to 041bd12e272c
("Revert "workqueue: make sure delayed work run in local cpu"") for
more information and ping me.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueue: schedule WORK_CPU_UNBOUND work on wq_unbound_cpumask CPUs</title>
<updated>2016-02-09T22:59:38Z</updated>
<author>
<name>Mike Galbraith</name>
<email>umgwanakikbuti@gmail.com</email>
</author>
<published>2016-02-09T22:59:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ef557180447fa9a7a0affd3abb21ecceb4b5e125'/>
<id>urn:sha1:ef557180447fa9a7a0affd3abb21ecceb4b5e125</id>
<content type='text'>
WORK_CPU_UNBOUND work items queued to a bound workqueue always run
locally.  This is a good thing normally, but not when the user has
asked us to keep unbound work away from certain CPUs.  Round robin
these to wq_unbound_cpumask CPUs instead, as perturbation avoidance
trumps performance.

tj: Cosmetic and comment changes.  WARN_ON_ONCE() dropped from empty
    (wq_unbound_cpumask AND cpu_online_mask).  If we want that, it
    should be done when config changes.

Signed-off-by: Mike Galbraith &lt;umgwanakikbuti@gmail.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>Revert "workqueue: make sure delayed work run in local cpu"</title>
<updated>2016-02-09T21:11:26Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2016-02-09T21:11:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=041bd12e272c53a35c54c13875839bcb98c999ce'/>
<id>urn:sha1:041bd12e272c53a35c54c13875839bcb98c999ce</id>
<content type='text'>
This reverts commit 874bbfe600a660cba9c776b3957b1ce393151b76.

Workqueue used to implicity guarantee that work items queued without
explicit CPU specified are put on the local CPU.  Recent changes in
timer broke the guarantee and led to vmstat breakage which was fixed
by 176bed1de5bf ("vmstat: explicitly schedule per-cpu work on the CPU
we need it to run on").

vmstat is the most likely to expose the issue and it's quite possible
that there are other similar problems which are a lot more difficult
to trigger.  As a preventive measure, 874bbfe600a6 ("workqueue: make
sure delayed work run in local cpu") was applied to restore the local
CPU guarnatee.  Unfortunately, the change exposed a bug in timer code
which got fixed by 22b886dd1018 ("timers: Use proper base migration in
add_timer_on()").  Due to code restructuring, the commit couldn't be
backported beyond certain point and stable kernels which only had
874bbfe600a6 started crashing.

The local CPU guarantee was accidental more than anything else and we
want to get rid of it anyway.  As, with the vmstat case fixed,
874bbfe600a6 is causing more problems than it's fixing, it has been
decided to take the chance and officially break the guarantee by
reverting the commit.  A debug feature will be added to force foreign
CPU assignment to expose cases relying on the guarantee and fixes for
the individual cases will be backported to stable as necessary.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Fixes: 874bbfe600a6 ("workqueue: make sure delayed work run in local cpu")
Link: http://lkml.kernel.org/g/20160120211926.GJ10810@quack.suse.cz
Cc: stable@vger.kernel.org
Cc: Mike Galbraith &lt;umgwanakikbuti@gmail.com&gt;
Cc: Henrique de Moraes Holschuh &lt;hmh@hmh.eng.br&gt;
Cc: Daniel Bilik &lt;daniel.bilik@neosystem.cz&gt;
Cc: Jan Kara &lt;jack@suse.cz&gt;
Cc: Shaohua Li &lt;shli@fb.com&gt;
Cc: Sasha Levin &lt;sasha.levin@oracle.com&gt;
Cc: Ben Hutchings &lt;ben@decadent.org.uk&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Daniel Bilik &lt;daniel.bilik@neosystem.cz&gt;
Cc: Jiri Slaby &lt;jslaby@suse.cz&gt;
Cc: Michal Hocko &lt;mhocko@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueue: skip flush dependency checks for legacy workqueues</title>
<updated>2016-01-29T18:31:10Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2016-01-29T10:59:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=23d11a58a9a60dcb52c8fc6494efce908b24c295'/>
<id>urn:sha1:23d11a58a9a60dcb52c8fc6494efce908b24c295</id>
<content type='text'>
fca839c00a12 ("workqueue: warn if memory reclaim tries to flush
!WQ_MEM_RECLAIM workqueue") implemented flush dependency warning which
triggers if a PF_MEMALLOC task or WQ_MEM_RECLAIM workqueue tries to
flush a !WQ_MEM_RECLAIM workquee.

This assumes that workqueues marked with WQ_MEM_RECLAIM sit in memory
reclaim path and making it depend on something which may need more
memory to make forward progress can lead to deadlocks.  Unfortunately,
workqueues created with the legacy create*_workqueue() interface
always have WQ_MEM_RECLAIM regardless of whether they are depended
upon memory reclaim or not.  These spurious WQ_MEM_RECLAIM markings
cause spurious triggering of the flush dependency checks.

  WARNING: CPU: 0 PID: 6 at kernel/workqueue.c:2361 check_flush_dependency+0x138/0x144()
  workqueue: WQ_MEM_RECLAIM deferwq:deferred_probe_work_func is flushing !WQ_MEM_RECLAIM events:lru_add_drain_per_cpu
  ...
  Workqueue: deferwq deferred_probe_work_func
  [&lt;c0017acc&gt;] (unwind_backtrace) from [&lt;c0013134&gt;] (show_stack+0x10/0x14)
  [&lt;c0013134&gt;] (show_stack) from [&lt;c0245f18&gt;] (dump_stack+0x94/0xd4)
  [&lt;c0245f18&gt;] (dump_stack) from [&lt;c0026f9c&gt;] (warn_slowpath_common+0x80/0xb0)
  [&lt;c0026f9c&gt;] (warn_slowpath_common) from [&lt;c0026ffc&gt;] (warn_slowpath_fmt+0x30/0x40)
  [&lt;c0026ffc&gt;] (warn_slowpath_fmt) from [&lt;c00390b8&gt;] (check_flush_dependency+0x138/0x144)
  [&lt;c00390b8&gt;] (check_flush_dependency) from [&lt;c0039ca0&gt;] (flush_work+0x50/0x15c)
  [&lt;c0039ca0&gt;] (flush_work) from [&lt;c00c51b0&gt;] (lru_add_drain_all+0x130/0x180)
  [&lt;c00c51b0&gt;] (lru_add_drain_all) from [&lt;c00f728c&gt;] (migrate_prep+0x8/0x10)
  [&lt;c00f728c&gt;] (migrate_prep) from [&lt;c00bfbc4&gt;] (alloc_contig_range+0xd8/0x338)
  [&lt;c00bfbc4&gt;] (alloc_contig_range) from [&lt;c00f8f18&gt;] (cma_alloc+0xe0/0x1ac)
  [&lt;c00f8f18&gt;] (cma_alloc) from [&lt;c001cac4&gt;] (__alloc_from_contiguous+0x38/0xd8)
  [&lt;c001cac4&gt;] (__alloc_from_contiguous) from [&lt;c001ceb4&gt;] (__dma_alloc+0x240/0x278)
  [&lt;c001ceb4&gt;] (__dma_alloc) from [&lt;c001cf78&gt;] (arm_dma_alloc+0x54/0x5c)
  [&lt;c001cf78&gt;] (arm_dma_alloc) from [&lt;c0355ea4&gt;] (dmam_alloc_coherent+0xc0/0xec)
  [&lt;c0355ea4&gt;] (dmam_alloc_coherent) from [&lt;c039cc4c&gt;] (ahci_port_start+0x150/0x1dc)
  [&lt;c039cc4c&gt;] (ahci_port_start) from [&lt;c0384734&gt;] (ata_host_start.part.3+0xc8/0x1c8)
  [&lt;c0384734&gt;] (ata_host_start.part.3) from [&lt;c03898dc&gt;] (ata_host_activate+0x50/0x148)
  [&lt;c03898dc&gt;] (ata_host_activate) from [&lt;c039d558&gt;] (ahci_host_activate+0x44/0x114)
  [&lt;c039d558&gt;] (ahci_host_activate) from [&lt;c039f05c&gt;] (ahci_platform_init_host+0x1d8/0x3c8)
  [&lt;c039f05c&gt;] (ahci_platform_init_host) from [&lt;c039e6bc&gt;] (tegra_ahci_probe+0x448/0x4e8)
  [&lt;c039e6bc&gt;] (tegra_ahci_probe) from [&lt;c0347058&gt;] (platform_drv_probe+0x50/0xac)
  [&lt;c0347058&gt;] (platform_drv_probe) from [&lt;c03458cc&gt;] (driver_probe_device+0x214/0x2c0)
  [&lt;c03458cc&gt;] (driver_probe_device) from [&lt;c0343cc0&gt;] (bus_for_each_drv+0x60/0x94)
  [&lt;c0343cc0&gt;] (bus_for_each_drv) from [&lt;c03455d8&gt;] (__device_attach+0xb0/0x114)
  [&lt;c03455d8&gt;] (__device_attach) from [&lt;c0344ab8&gt;] (bus_probe_device+0x84/0x8c)
  [&lt;c0344ab8&gt;] (bus_probe_device) from [&lt;c0344f48&gt;] (deferred_probe_work_func+0x68/0x98)
  [&lt;c0344f48&gt;] (deferred_probe_work_func) from [&lt;c003b738&gt;] (process_one_work+0x120/0x3f8)
  [&lt;c003b738&gt;] (process_one_work) from [&lt;c003ba48&gt;] (worker_thread+0x38/0x55c)
  [&lt;c003ba48&gt;] (worker_thread) from [&lt;c0040f14&gt;] (kthread+0xdc/0xf4)
  [&lt;c0040f14&gt;] (kthread) from [&lt;c000f778&gt;] (ret_from_fork+0x14/0x3c)

Fix it by marking workqueues created via create*_workqueue() with
__WQ_LEGACY and disabling flush dependency checks on them.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Reported-and-tested-by: Thierry Reding &lt;thierry.reding@gmail.com&gt;
Link: http://lkml.kernel.org/g/20160126173843.GA11115@ulmo.nvidia.com
Fixes: fca839c00a12 ("workqueue: warn if memory reclaim tries to flush !WQ_MEM_RECLAIM workqueue")
</content>
</entry>
<entry>
<title>workqueue: simplify the apply_workqueue_attrs_locked()</title>
<updated>2016-01-07T16:04:34Z</updated>
<author>
<name>wanghaibin</name>
<email>wanghaibin.wang@huawei.com</email>
</author>
<published>2016-01-07T12:38:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=6201171e3b2c02992e62448636631a0dfe4e9d20'/>
<id>urn:sha1:6201171e3b2c02992e62448636631a0dfe4e9d20</id>
<content type='text'>
If the apply_wqattrs_prepare() returns NULL, it has already cleaned up
the related resources, so it can return directly and avoid calling the
clean up function again.

This doesn't introduce any functional changes.

Signed-off-by: wanghaibin &lt;wanghaibin.wang@huawei.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueue: implement lockup detector</title>
<updated>2015-12-08T16:29:47Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2015-12-08T16:28:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=82607adcf9cdf40fb7b5331269780c8f70ec6e35'/>
<id>urn:sha1:82607adcf9cdf40fb7b5331269780c8f70ec6e35</id>
<content type='text'>
Workqueue stalls can happen from a variety of usage bugs such as
missing WQ_MEM_RECLAIM flag or concurrency managed work item
indefinitely staying RUNNING.  These stalls can be extremely difficult
to hunt down because the usual warning mechanisms can't detect
workqueue stalls and the internal state is pretty opaque.

To alleviate the situation, this patch implements workqueue lockup
detector.  It periodically monitors all worker_pools periodically and,
if any pool failed to make forward progress longer than the threshold
duration, triggers warning and dumps workqueue state as follows.

 BUG: workqueue lockup - pool cpus=0 node=0 flags=0x0 nice=0 stuck for 31s!
 Showing busy workqueues and worker pools:
 workqueue events: flags=0x0
   pwq 0: cpus=0 node=0 flags=0x0 nice=0 active=17/256
     pending: monkey_wrench_fn, e1000_watchdog, cache_reap, vmstat_shepherd, release_one_tty, release_one_tty, release_one_tty, release_one_tty, release_one_tty, release_one_tty, release_one_tty, release_one_tty, release_one_tty, release_one_tty, release_one_tty, release_one_tty, cgroup_release_agent
 workqueue events_power_efficient: flags=0x80
   pwq 0: cpus=0 node=0 flags=0x0 nice=0 active=2/256
     pending: check_lifetime, neigh_periodic_work
 workqueue cgroup_pidlist_destroy: flags=0x0
   pwq 0: cpus=0 node=0 flags=0x0 nice=0 active=1/1
     pending: cgroup_pidlist_destroy_work_fn
 ...

The detection mechanism is controller through kernel parameter
workqueue.watchdog_thresh and can be updated at runtime through the
sysfs module parameter file.

v2: Decoupled from softlockup control knobs.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: Don Zickus &lt;dzickus@redhat.com&gt;
Cc: Ulrich Obergfell &lt;uobergfe@redhat.com&gt;
Cc: Michal Hocko &lt;mhocko@suse.com&gt;
Cc: Chris Mason &lt;clm@fb.com&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>workqueue: warn if memory reclaim tries to flush !WQ_MEM_RECLAIM workqueue</title>
<updated>2015-12-08T16:29:36Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2015-12-07T15:58:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=fca839c00a12d682cb59b3b620d109a1d850b262'/>
<id>urn:sha1:fca839c00a12d682cb59b3b620d109a1d850b262</id>
<content type='text'>
Task or work item involved in memory reclaim trying to flush a
non-WQ_MEM_RECLAIM workqueue or one of its work items can lead to
deadlock.  Trigger WARN_ONCE() if such conditions are detected.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
</content>
</entry>
<entry>
<title>Merge branch 'for-4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq</title>
<updated>2015-11-05T22:16:27Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2015-11-05T22:16:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e25ac7ddaae0e798f794cdaf9109bc71246110cd'/>
<id>urn:sha1:e25ac7ddaae0e798f794cdaf9109bc71246110cd</id>
<content type='text'>
Pull workqueue update from Tejun Heo:
 "This pull request contains one patch to make an unbound worker pool
  allocated from the NUMA node containing it if such node exists.  As
  unbound worker pools are node-affine by default, this makes most pools
  allocated on the right node"

* 'for-4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq:
  workqueue: Allocate the unbound pool using local node memory
</content>
</entry>
<entry>
<title>workqueue: Allocate the unbound pool using local node memory</title>
<updated>2015-10-12T16:17:31Z</updated>
<author>
<name>Xunlei Pang</name>
<email>pang.xunlei@linaro.org</email>
</author>
<published>2015-10-09T03:53:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e2273584d3f33f7f2cfe6d7aaade0fa2f1cb3db5'/>
<id>urn:sha1:e2273584d3f33f7f2cfe6d7aaade0fa2f1cb3db5</id>
<content type='text'>
Currently, get_unbound_pool() uses kzalloc() to allocate the
worker pool. Actually, we can use the right node to do the
allocation, achieving local memory access.

This patch selects target node first, and uses kzalloc_node()
instead.

Signed-off-by: Xunlei Pang &lt;pang.xunlei@linaro.org&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
</feed>
