<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/include/linux/workqueue.h, branch v4.9.147</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.9.147</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.9.147'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2018-12-05T18:42:42Z</updated>
<entry>
<title>workqueue: avoid clang warning</title>
<updated>2018-12-05T18:42:42Z</updated>
<author>
<name>Arnd Bergmann</name>
<email>arnd@arndb.de</email>
</author>
<published>2017-02-01T17:01:17Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=6f35b5bd0c0ddda68b999084c5bb699e23c59efc'/>
<id>urn:sha1:6f35b5bd0c0ddda68b999084c5bb699e23c59efc</id>
<content type='text'>
(commit a45463cbf3f9dcdae683033c256f50bded513d6a upstream)

Building with clang shows lots of warning like:

drivers/amba/bus.c:447:8: warning: implicit conversion from 'long long' to 'int' changes value from 4294967248 to -48
      [-Wconstant-conversion]
static DECLARE_DELAYED_WORK(deferred_retry_work, amba_deferred_retry_func);
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/workqueue.h:187:26: note: expanded from macro 'DECLARE_DELAYED_WORK'
        struct delayed_work n = __DELAYED_WORK_INITIALIZER(n, f, 0)
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/workqueue.h:177:10: note: expanded from macro '__DELAYED_WORK_INITIALIZER'
        .work = __WORK_INITIALIZER((n).work, (f)),                      \
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/workqueue.h:170:10: note: expanded from macro '__WORK_INITIALIZER'
        .data = WORK_DATA_STATIC_INIT(),                                \
                ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/workqueue.h:111:39: note: expanded from macro 'WORK_DATA_STATIC_INIT'
        ATOMIC_LONG_INIT(WORK_STRUCT_NO_POOL | WORK_STRUCT_STATIC)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
include/asm-generic/atomic-long.h:32:41: note: expanded from macro 'ATOMIC_LONG_INIT'
 #define ATOMIC_LONG_INIT(i)     ATOMIC_INIT(i)
                                ~~~~~~~~~~~~^~
arch/arm/include/asm/atomic.h:21:27: note: expanded from macro 'ATOMIC_INIT'
 #define ATOMIC_INIT(i)  { (i) }
                        ~  ^

This makes the type cast explicit, which shuts up the warning.

Signed-off-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Nick Desaulniers &lt;ndesaulniers@google.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>workqueue: Allow retrieval of current task's work struct</title>
<updated>2018-03-18T10:18:48Z</updated>
<author>
<name>Lukas Wunner</name>
<email>lukas@wunner.de</email>
</author>
<published>2018-02-11T09:38:28Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=225ce6d7f2133071973c3fd5a006d58dd750a5a5'/>
<id>urn:sha1:225ce6d7f2133071973c3fd5a006d58dd750a5a5</id>
<content type='text'>
commit 27d4ee03078aba88c5e07dcc4917e8d01d046f38 upstream.

Introduce a helper to retrieve the current task's work struct if it is
a workqueue worker.

This allows us to fix a long-standing deadlock in several DRM drivers
wherein the -&gt;runtime_suspend callback waits for a specific worker to
finish and that worker in turn calls a function which waits for runtime
suspend to finish.  That function is invoked from multiple call sites
and waiting for runtime suspend to finish is the correct thing to do
except if it's executing in the context of the worker.

Cc: Lai Jiangshan &lt;jiangshanlai@gmail.com&gt;
Cc: Dave Airlie &lt;airlied@redhat.com&gt;
Cc: Ben Skeggs &lt;bskeggs@redhat.com&gt;
Cc: Alex Deucher &lt;alexander.deucher@amd.com&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
Reviewed-by: Lyude Paul &lt;lyude@redhat.com&gt;
Signed-off-by: Lukas Wunner &lt;lukas@wunner.de&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/2d8f603074131eb87e588d2b803a71765bd3a2fd.1518338788.git.lukas@wunner.de
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>workqueue: Fix flag collision</title>
<updated>2017-09-09T15:39:41Z</updated>
<author>
<name>Ben Hutchings</name>
<email>ben@decadent.org.uk</email>
</author>
<published>2017-09-03T00:18:41Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=ec552ece1f25e8ecadf0afafe87ce314d13dc3e7'/>
<id>urn:sha1:ec552ece1f25e8ecadf0afafe87ce314d13dc3e7</id>
<content type='text'>
commit fbf1c41fc0f4d3574ac2377245efd666c1fa3075 upstream.

Commit 0a94efb5acbb ("workqueue: implicit ordered attribute should be
overridable") introduced a __WQ_ORDERED_EXPLICIT flag but gave it the
same value as __WQ_LEGACY.  I don't believe these were intended to
mean the same thing, so renumber __WQ_ORDERED_EXPLICIT.

Fixes: 0a94efb5acbb ("workqueue: implicit ordered attribute should be ...")
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&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: implicit ordered attribute should be overridable</title>
<updated>2017-08-11T15:49:37Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2017-07-23T12:36:15Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=f9636c9bdd5828f29cdfaf620e3a424a5f8cc221'/>
<id>urn:sha1:f9636c9bdd5828f29cdfaf620e3a424a5f8cc221</id>
<content type='text'>
commit 0a94efb5acbb6980d7c9ab604372d93cd507e4d8 upstream.

5c0338c68706 ("workqueue: restore WQ_UNBOUND/max_active==1 to be
ordered") automatically enabled ordered attribute for unbound
workqueues w/ max_active == 1.  Because ordered workqueues reject
max_active and some attribute changes, this implicit ordered mode
broke cases where the user creates an unbound workqueue w/ max_active
== 1 and later explicitly changes the related attributes.

This patch distinguishes explicit and implicit ordered setting and
overrides from attribute changes if implict.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Fixes: 5c0338c68706 ("workqueue: restore WQ_UNBOUND/max_active==1 to be ordered")
Cc: Holger Hoffstätte &lt;holger@applied-asynchrony.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>workqueue: add cancel_work()</title>
<updated>2016-08-29T14:13:21Z</updated>
<author>
<name>Jens Axboe</name>
<email>axboe@fb.com</email>
</author>
<published>2016-08-24T21:51:50Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=f72b8792d180948b4b3898374998f5ac8c02e539'/>
<id>urn:sha1:f72b8792d180948b4b3898374998f5ac8c02e539</id>
<content type='text'>
Like cancel_delayed_work(), but for regular work.

Signed-off-by: Jens Axboe &lt;axboe@fb.com&gt;
Mehed-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueue: Convert to state machine callbacks</title>
<updated>2016-07-14T07:34:43Z</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2016-07-13T17:16:29Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=7ee681b25284782ecf380bf5ccf55f13c52fd0ce'/>
<id>urn:sha1:7ee681b25284782ecf380bf5ccf55f13c52fd0ce</id>
<content type='text'>
Get rid of the prio ordering of the separate notifiers and use a proper state
callback pair.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Anna-Maria Gleixner &lt;anna-maria@linutronix.de&gt;
Reviewed-by: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: Lai Jiangshan &lt;jiangshanlai@gmail.com&gt;
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Nicolas Iooss &lt;nicolas.iooss_linux@m4x.org&gt;
Cc: Oleg Nesterov &lt;oleg@redhat.com&gt;
Cc: Paul E. McKenney &lt;paulmck@linux.vnet.ibm.com&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Rasmus Villemoes &lt;linux@rasmusvillemoes.dk&gt;
Cc: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160713153335.197083890@linutronix.de
Signed-off-by: Ingo Molnar &lt;mingo@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.stealer.net/cgit.cgi/user/sven/linux.git/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: 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.stealer.net/cgit.cgi/user/sven/linux.git/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: fix some docbook warnings</title>
<updated>2015-08-17T19:48:24Z</updated>
<author>
<name>Jonathan Corbet</name>
<email>corbet@lwn.net</email>
</author>
<published>2015-08-13T23:52:02Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=355c06633e233a57155b827ebe99b91c35bc1f5c'/>
<id>urn:sha1:355c06633e233a57155b827ebe99b91c35bc1f5c</id>
<content type='text'>
There are some errors in the docbook comments in workqueue.h that cause
warnings when the docs are built; this only recently came to light because
these comments were not used until now.  Fix the comments to make the
warnings go away.

The "args..." "fix" is a hack.  kerneldoc doesn't deal properly with named
variadic arguments in macros, so all I've really achieved here is to make
it shut up.  Fixing kerneldoc will have to wait for more time.

Signed-off-by: Jonathan Corbet &lt;corbet@lwn.net&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueue: move flush_scheduled_work() to workqueue.h</title>
<updated>2015-05-21T21:26:22Z</updated>
<author>
<name>Lai Jiangshan</name>
<email>laijs@cn.fujitsu.com</email>
</author>
<published>2015-05-20T06:41:19Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=37b1ef31a568fc02e53587620226e5f3c66454c8'/>
<id>urn:sha1:37b1ef31a568fc02e53587620226e5f3c66454c8</id>
<content type='text'>
flush_scheduled_work() is just a simple call to flush_work().

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