<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/include/linux/workqueue.h, branch v4.11-rc3</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>workqueue: avoid clang warning</title>
<updated>2017-02-02T20:22:18+00:00</updated>
<author>
<name>Arnd Bergmann</name>
<email>arnd@arndb.de</email>
</author>
<published>2017-02-01T17:01:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a45463cbf3f9dcdae683033c256f50bded513d6a'/>
<id>a45463cbf3f9dcdae683033c256f50bded513d6a</id>
<content type='text'>
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;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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;
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'for-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq</title>
<updated>2016-12-13T20:59:57+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2016-12-13T20:59:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=c11a6cfb0103d5d831e20bd9b75d10d13519fec5'/>
<id>c11a6cfb0103d5d831e20bd9b75d10d13519fec5</id>
<content type='text'>
Pull workqueue updates from Tejun Heo:
 "Mostly patches to initialize workqueue subsystem earlier and get rid
  of keventd_up().

  The patches were headed for the last merge cycle but got delayed due
  to a bug found late minute, which is fixed now.

  Also, to help debugging, destroy_workqueue() is more chatty now on a
  sanity check failure."

* 'for-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq:
  workqueue: move wq_numa_init() to workqueue_init()
  workqueue: remove keventd_up()
  debugobj, workqueue: remove keventd_up() usage
  slab, workqueue: remove keventd_up() usage
  power, workqueue: remove keventd_up() usage
  tty, workqueue: remove keventd_up() usage
  mce, workqueue: remove keventd_up() usage
  workqueue: make workqueue available early during boot
  workqueue: dump workqueue state on sanity check failures in destroy_workqueue()
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pull workqueue updates from Tejun Heo:
 "Mostly patches to initialize workqueue subsystem earlier and get rid
  of keventd_up().

  The patches were headed for the last merge cycle but got delayed due
  to a bug found late minute, which is fixed now.

  Also, to help debugging, destroy_workqueue() is more chatty now on a
  sanity check failure."

* 'for-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq:
  workqueue: move wq_numa_init() to workqueue_init()
  workqueue: remove keventd_up()
  debugobj, workqueue: remove keventd_up() usage
  slab, workqueue: remove keventd_up() usage
  power, workqueue: remove keventd_up() usage
  tty, workqueue: remove keventd_up() usage
  mce, workqueue: remove keventd_up() usage
  workqueue: make workqueue available early during boot
  workqueue: dump workqueue state on sanity check failures in destroy_workqueue()
</pre>
</div>
</content>
</entry>
<entry>
<title>workqueue: kerneldocify workqueue_attrs</title>
<updated>2016-10-28T16:54:32+00:00</updated>
<author>
<name>Silvio Fricke</name>
<email>silvio.fricke@gmail.com</email>
</author>
<published>2016-10-28T08:14:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=42412c3aae5d8ea57a46b8ff86bb67bc1a270d9c'/>
<id>42412c3aae5d8ea57a46b8ff86bb67bc1a270d9c</id>
<content type='text'>
Only formating changes.

Signed-off-by: Silvio Fricke &lt;silvio.fricke@gmail.com&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Jonathan Corbet &lt;corbet@lwn.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Only formating changes.

Signed-off-by: Silvio Fricke &lt;silvio.fricke@gmail.com&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Jonathan Corbet &lt;corbet@lwn.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'for-4.9' into for-4.10</title>
<updated>2016-10-19T16:12:40+00:00</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2016-10-19T16:12:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=8bc4a04455969c36bf54a942ad9d28d80969ed51'/>
<id>8bc4a04455969c36bf54a942ad9d28d80969ed51</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>workqueue: remove keventd_up()</title>
<updated>2016-09-17T17:18:21+00:00</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2016-09-16T19:49:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=863b710b664bdcb90c0c682ee24adb368f497a5b'/>
<id>863b710b664bdcb90c0c682ee24adb368f497a5b</id>
<content type='text'>
keventd_up() no longer has in-kernel users.  Remove it and make
wq_online static.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
keventd_up() no longer has in-kernel users.  Remove it and make
wq_online static.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>workqueue: make workqueue available early during boot</title>
<updated>2016-09-17T17:18:21+00:00</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2016-09-16T19:49:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=3347fa0928210d96aaa2bd6cd5a8391d5e630873'/>
<id>3347fa0928210d96aaa2bd6cd5a8391d5e630873</id>
<content type='text'>
Workqueue is currently initialized in an early init call; however,
there are cases where early boot code has to be split and reordered to
come after workqueue initialization or the same code path which makes
use of workqueues is used both before workqueue initailization and
after.  The latter cases have to gate workqueue usages with
keventd_up() tests, which is nasty and easy to get wrong.

Workqueue usages have become widespread and it'd be a lot more
convenient if it can be used very early from boot.  This patch splits
workqueue initialization into two steps.  workqueue_init_early() which
sets up the basic data structures so that workqueues can be created
and work items queued, and workqueue_init() which actually brings up
workqueues online and starts executing queued work items.  The former
step can be done very early during boot once memory allocation,
cpumasks and idr are initialized.  The latter right after kthreads
become available.

This allows work item queueing and canceling from very early boot
which is what most of these use cases want.

* As systemd_wq being initialized doesn't indicate that workqueue is
  fully online anymore, update keventd_up() to test wq_online instead.
  The follow-up patches will get rid of all its usages and the
  function itself.

* Flushing doesn't make sense before workqueue is fully initialized.
  The flush functions trigger WARN and return immediately before fully
  online.

* Work items are never in-flight before fully online.  Canceling can
  always succeed by skipping the flush step.

* Some code paths can no longer assume to be called with irq enabled
  as irq is disabled during early boot.  Use irqsave/restore
  operations instead.

v2: Watchdog init, which requires timer to be running, moved from
    workqueue_init_early() to workqueue_init().

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Suggested-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Link: http://lkml.kernel.org/r/CA+55aFx0vPuMuxn00rBSM192n-Du5uxy+4AvKa0SBSOVJeuCGg@mail.gmail.com
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Workqueue is currently initialized in an early init call; however,
there are cases where early boot code has to be split and reordered to
come after workqueue initialization or the same code path which makes
use of workqueues is used both before workqueue initailization and
after.  The latter cases have to gate workqueue usages with
keventd_up() tests, which is nasty and easy to get wrong.

Workqueue usages have become widespread and it'd be a lot more
convenient if it can be used very early from boot.  This patch splits
workqueue initialization into two steps.  workqueue_init_early() which
sets up the basic data structures so that workqueues can be created
and work items queued, and workqueue_init() which actually brings up
workqueues online and starts executing queued work items.  The former
step can be done very early during boot once memory allocation,
cpumasks and idr are initialized.  The latter right after kthreads
become available.

This allows work item queueing and canceling from very early boot
which is what most of these use cases want.

* As systemd_wq being initialized doesn't indicate that workqueue is
  fully online anymore, update keventd_up() to test wq_online instead.
  The follow-up patches will get rid of all its usages and the
  function itself.

* Flushing doesn't make sense before workqueue is fully initialized.
  The flush functions trigger WARN and return immediately before fully
  online.

* Work items are never in-flight before fully online.  Canceling can
  always succeed by skipping the flush step.

* Some code paths can no longer assume to be called with irq enabled
  as irq is disabled during early boot.  Use irqsave/restore
  operations instead.

v2: Watchdog init, which requires timer to be running, moved from
    workqueue_init_early() to workqueue_init().

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Suggested-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Link: http://lkml.kernel.org/r/CA+55aFx0vPuMuxn00rBSM192n-Du5uxy+4AvKa0SBSOVJeuCGg@mail.gmail.com
</pre>
</div>
</content>
</entry>
<entry>
<title>workqueue: add cancel_work()</title>
<updated>2016-08-29T14:13:21+00:00</updated>
<author>
<name>Jens Axboe</name>
<email>axboe@fb.com</email>
</author>
<published>2016-08-24T21:51:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f72b8792d180948b4b3898374998f5ac8c02e539'/>
<id>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>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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;
</pre>
</div>
</content>
</entry>
<entry>
<title>workqueue: Convert to state machine callbacks</title>
<updated>2016-07-14T07:34:43+00:00</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2016-07-13T17:16:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=7ee681b25284782ecf380bf5ccf55f13c52fd0ce'/>
<id>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>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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;
</pre>
</div>
</content>
</entry>
<entry>
<title>workqueue: skip flush dependency checks for legacy workqueues</title>
<updated>2016-01-29T18:31:10+00:00</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2016-01-29T10:59:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=23d11a58a9a60dcb52c8fc6494efce908b24c295'/>
<id>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>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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")
</pre>
</div>
</content>
</entry>
<entry>
<title>workqueue: implement lockup detector</title>
<updated>2015-12-08T16:29:47+00:00</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2015-12-08T16:28:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=82607adcf9cdf40fb7b5331269780c8f70ec6e35'/>
<id>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>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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;
</pre>
</div>
</content>
</entry>
</feed>
