<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/workqueue.c, branch v2.6.37</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=v2.6.37</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v2.6.37'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2010-12-14T14:05:54Z</updated>
<entry>
<title>workqueue: It is likely that WORKER_NOT_RUNNING is true</title>
<updated>2010-12-14T14:05:54Z</updated>
<author>
<name>Steven Rostedt</name>
<email>srostedt@redhat.com</email>
</author>
<published>2010-12-04T04:12:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2d64672ed38721b7a3815009d79bfb90a1f34a17'/>
<id>urn:sha1:2d64672ed38721b7a3815009d79bfb90a1f34a17</id>
<content type='text'>
Running the annotate branch profiler on three boxes, including my
main box that runs firefox, evolution, xchat, and is part of the distcc farm,
showed this with the likelys in the workqueue code:

 correct incorrect  %        Function                  File              Line
 ------- ---------  -        --------                  ----              ----
      96   996253  99 wq_worker_sleeping             workqueue.c          703
      96   996247  99 wq_worker_waking_up            workqueue.c          677

The likely()s in this case were assuming that WORKER_NOT_RUNNING will
most likely be false. But this is not the case. The reason is
(and shown by adding trace_printks and testing it) that most of the time
WORKER_PREP is set.

In worker_thread() we have:

	worker_clr_flags(worker, WORKER_PREP);

	[ do work stuff ]

	worker_set_flags(worker, WORKER_PREP, false);

(that 'false' means not to wake up an idle worker)

The wq_worker_sleeping() is called from schedule when a worker thread
is putting itself to sleep. Which happens most of the time outside
of that [ do work stuff ].

The wq_worker_waking_up is called by the wakeup worker code, which
is also callod outside that [ do work stuff ].

Thus, the likely and unlikely used by those two functions are actually
backwards.

Remove the annotation and let gcc figure it out.

Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueue: check the allocation of system_unbound_wq</title>
<updated>2010-11-26T11:06:44Z</updated>
<author>
<name>Hitoshi Mitake</name>
<email>mitake@dcl.info.waseda.ac.jp</email>
</author>
<published>2010-11-26T11:06:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e5cba24e3f018d4beb6acd101a82483c98f91ce7'/>
<id>urn:sha1:e5cba24e3f018d4beb6acd101a82483c98f91ce7</id>
<content type='text'>
I found a trivial bug on initialization of workqueue.
Current init_workqueues doesn't check the result of
allocation of system_unbound_wq, this should be checked
like other queues.

Signed-off-by: Hitoshi Mitake &lt;mitake@dcl.info.waseda.ac.jp&gt;
Cc: Arjan van de Ven &lt;arjan@linux.intel.com&gt;
Cc: David Howells &lt;dhowells@redhat.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueues: s/ON_STACK/ONSTACK/</title>
<updated>2010-10-26T23:52:14Z</updated>
<author>
<name>Andrew Morton</name>
<email>akpm@linux-foundation.org</email>
</author>
<published>2010-10-26T21:22:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ca1cab37d91cbe8a8333732540d43cabb54cfa85'/>
<id>urn:sha1:ca1cab37d91cbe8a8333732540d43cabb54cfa85</id>
<content type='text'>
Silly though it is, completions and wait_queue_heads use foo_ONSTACK
(COMPLETION_INITIALIZER_ONSTACK, DECLARE_COMPLETION_ONSTACK,
__WAIT_QUEUE_HEAD_INIT_ONSTACK and DECLARE_WAIT_QUEUE_HEAD_ONSTACK) so I
guess workqueues should do the same thing.

s/INIT_WORK_ON_STACK/INIT_WORK_ONSTACK/
s/INIT_DELAYED_WORK_ON_STACK/INIT_DELAYED_WORK_ONSTACK/

Cc: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>MN10300: Fix the PERCPU() alignment to allow for workqueues</title>
<updated>2010-10-25T23:24:06Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2010-10-25T22:41:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5260562754c0aa4b95eebb1f851eaccce7286365'/>
<id>urn:sha1:5260562754c0aa4b95eebb1f851eaccce7286365</id>
<content type='text'>
In the MN10300 arch, we occasionally see an assertion being tripped in
alloc_cwqs() at the following line:

        /* just in case, make sure it's actually aligned */
  ---&gt;  BUG_ON(!IS_ALIGNED(wq-&gt;cpu_wq.v, align));
        return wq-&gt;cpu_wq.v ? 0 : -ENOMEM;

The values are:

        wa-&gt;cpu_wq.v =&gt; 0x902776e0
        align =&gt; 0x100

and align is calculated by the following:

        const size_t align = max_t(size_t, 1 &lt;&lt; WORK_STRUCT_FLAG_BITS,
                                   __alignof__(unsigned long long));

This is because the pointer in question (wq-&gt;cpu_wq.v) loses some of its
lower bits to control flags, and so the object it points to must be
sufficiently aligned to avoid the need to use those bits for pointing to
things.

Currently, 4 control bits and 4 colour bits are used in normal
circumstances, plus a debugging bit if debugging is set.  This requires
the cpu_workqueue_struct struct to be at least 256 bytes aligned (or 512
bytes aligned with debugging).

PERCPU() alignment on MN13000, however, is only 32 bytes as set in
vmlinux.lds.S.  So we set this to PAGE_SIZE (4096) to match most other
arches and stick a comment in alloc_cwqs() for anyone else who triggers
the assertion.

Reported-by: Akira Takeuchi &lt;takeuchi.akr@jp.panasonic.com&gt;
Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Acked-by: Mark Salter &lt;msalter@redhat.com&gt;
Cc: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>workqueue: remove in_workqueue_context()</title>
<updated>2010-10-19T09:28:15Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2010-10-19T09:28:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=daaae6b010ac0f60c9c35e481589966f9f1fcc22'/>
<id>urn:sha1:daaae6b010ac0f60c9c35e481589966f9f1fcc22</id>
<content type='text'>
Commit a25909a4 (lockdep: Add an in_workqueue_context() lockdep-based
test function) added in_workqueue_context() but there hasn't been any
in-kernel user and the lockdep annotation in workqueue is scheduled to
change.  Remove the unused function.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Paul E. McKenney &lt;paulmck@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>workqueue: Clarify that schedule_on_each_cpu is synchronous</title>
<updated>2010-10-19T09:14:49Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2010-10-19T09:14:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=31ddd871fc3db73e2024cb3eb3ee5051edf5a80f'/>
<id>urn:sha1:31ddd871fc3db73e2024cb3eb3ee5051edf5a80f</id>
<content type='text'>
The documentation for schedule_on_each_cpu() states that it calls a
function on each online CPU from keventd.  This can easily be
interpreted as an asyncronous call because the description does not
mention that flush_work is called.  Clarify that it is synchronous.

tj: rephrased a bit

Signed-off-by: Mel Gorman &lt;mel@csn.ul.ie&gt;
Reviewed-by: KOSAKI Motohiro &lt;kosaki.motohiro@jp.fujitsu.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueue: add and use WQ_MEM_RECLAIM flag</title>
<updated>2010-10-11T13:20:26Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2010-10-11T13:12:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=6370a6ad3b53df90b4700977f7718118a2cd524a'/>
<id>urn:sha1:6370a6ad3b53df90b4700977f7718118a2cd524a</id>
<content type='text'>
Add WQ_MEM_RECLAIM flag which currently maps to WQ_RESCUER, mark
WQ_RESCUER as internal and replace all external WQ_RESCUER usages to
WQ_MEM_RECLAIM.

This makes the API users express the intent of the workqueue instead
of indicating the internal mechanism used to guarantee forward
progress.  This is also to make it cleaner to add more semantics to
WQ_MEM_RECLAIM.  For example, if deemed necessary, memory reclaim
workqueues can be made highpri.

This patch doesn't introduce any functional change.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Jeff Garzik &lt;jgarzik@pobox.com&gt;
Cc: Dave Chinner &lt;david@fromorbit.com&gt;
Cc: Steven Whitehouse &lt;swhiteho@redhat.com&gt;
</content>
</entry>
<entry>
<title>workqueue: fix HIGHPRI handling in keep_working()</title>
<updated>2010-10-11T10:09:30Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2010-10-11T09:51:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=30310045dd20a286cf3800f063f79b468e132fb1'/>
<id>urn:sha1:30310045dd20a286cf3800f063f79b468e132fb1</id>
<content type='text'>
The policy function keep_working() didn't check GCWQ_HIGHPRI_PENDING
and could return %false with highpri work pending.  This could lead to
late execution of a highpri work which was delayed due to @max_active
throttling if other works are actively consuming CPU cycles.

For example, the following could happen.

1. Work W0 which burns CPU cycles.

2. Two works W1 and W2 are queued to a highpri wq w/ @max_active of 1.

3. W1 starts executing and W2 is put to delayed queue.  W0 and W1 are
   both runnable.

4. W1 finishes which puts W2 to pending queue but keep_working()
   incorrectly returns %false and the worker goes to sleep.

5. W0 finishes and W2 starts execution.

With this patch applied, W2 starts execution as soon as W1 finishes.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueue: add queue_work and activate_work trace points</title>
<updated>2010-10-05T08:49:55Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2010-10-05T08:49:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=cdadf0097cdca06c497ffaeb5982e028c6e4ed38'/>
<id>urn:sha1:cdadf0097cdca06c497ffaeb5982e028c6e4ed38</id>
<content type='text'>
These two tracepoints allow tracking when and how a work is queued and
activated.  This patch is based on Frederic's patch to add queue_work
trace point.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Frederic Weisbecker &lt;fweisbec@gmail.com&gt;
</content>
</entry>
<entry>
<title>workqueue: prepare for more tracepoints</title>
<updated>2010-10-05T08:41:14Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2010-10-05T08:41:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=97bd234701b2b39a0e749c1fe0e44f1d14c94292'/>
<id>urn:sha1:97bd234701b2b39a0e749c1fe0e44f1d14c94292</id>
<content type='text'>
Define workqueue_work event class and use it for workqueue_execute_end
trace point.  Also, move trace/events/workqueue.h include downwards
such that all struct definitions are visible to it.  This is to
prepare for more tracepoints and doesn't cause any functional change.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Frederic Weisbecker &lt;fweisbec@gmail.com&gt;
</content>
</entry>
</feed>
