aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/workqueue.txt
diff options
context:
space:
mode:
authorLibin <huawei.libin@huawei.com>2013-08-20 20:50:41 -0400
committerTejun Heo <tj@kernel.org>2013-08-21 10:32:09 -0400
commit546d30c4a2e61a53d408e5f40d01278f144bb0f5 (patch)
tree02df688080614302ba049dfd9efc22ce692440df /Documentation/workqueue.txt
parent2d498db9814c6f3a79b708c8867c7ffcf7b5e2fc (diff)
workqueue: Correct/Drop references to gcwq in Documentation
No functional changes. This patch fixes the post gcwq comments in Documentation/workqueue.txt. tj: Whitespace adjustments. Minor updates. Signed-off-by: Libin <huawei.libin@huawei.com> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'Documentation/workqueue.txt')
-rw-r--r--Documentation/workqueue.txt72
1 files changed, 36 insertions, 36 deletions
diff --git a/Documentation/workqueue.txt b/Documentation/workqueue.txt
index 67113f622880..f81a65b54c29 100644
--- a/Documentation/workqueue.txt
+++ b/Documentation/workqueue.txt
@@ -85,16 +85,16 @@ workqueue.
85Special purpose threads, called worker threads, execute the functions 85Special purpose threads, called worker threads, execute the functions
86off of the queue, one after the other. If no work is queued, the 86off of the queue, one after the other. If no work is queued, the
87worker threads become idle. These worker threads are managed in so 87worker threads become idle. These worker threads are managed in so
88called thread-pools. 88called worker-pools.
89 89
90The cmwq design differentiates between the user-facing workqueues that 90The cmwq design differentiates between the user-facing workqueues that
91subsystems and drivers queue work items on and the backend mechanism 91subsystems and drivers queue work items on and the backend mechanism
92which manages thread-pools and processes the queued work items. 92which manages worker-pools and processes the queued work items.
93 93
94The backend is called gcwq. There is one gcwq for each possible CPU 94There are two worker-pools, one for normal work items and the other
95and one gcwq to serve work items queued on unbound workqueues. Each 95for high priority ones, for each possible CPU and some extra
96gcwq has two thread-pools - one for normal work items and the other 96worker-pools to serve work items queued on unbound workqueues - the
97for high priority ones. 97number of these backing pools is dynamic.
98 98
99Subsystems and drivers can create and queue work items through special 99Subsystems and drivers can create and queue work items through special
100workqueue API functions as they see fit. They can influence some 100workqueue API functions as they see fit. They can influence some
@@ -104,13 +104,12 @@ things like CPU locality, concurrency limits, priority and more. To
104get a detailed overview refer to the API description of 104get a detailed overview refer to the API description of
105alloc_workqueue() below. 105alloc_workqueue() below.
106 106
107When a work item is queued to a workqueue, the target gcwq and 107When a work item is queued to a workqueue, the target worker-pool is
108thread-pool is determined according to the queue parameters and 108determined according to the queue parameters and workqueue attributes
109workqueue attributes and appended on the shared worklist of the 109and appended on the shared worklist of the worker-pool. For example,
110thread-pool. For example, unless specifically overridden, a work item 110unless specifically overridden, a work item of a bound workqueue will
111of a bound workqueue will be queued on the worklist of either normal 111be queued on the worklist of either normal or highpri worker-pool that
112or highpri thread-pool of the gcwq that is associated to the CPU the 112is associated to the CPU the issuer is running on.
113issuer is running on.
114 113
115For any worker pool implementation, managing the concurrency level 114For any worker pool implementation, managing the concurrency level
116(how many execution contexts are active) is an important issue. cmwq 115(how many execution contexts are active) is an important issue. cmwq
@@ -118,14 +117,14 @@ tries to keep the concurrency at a minimal but sufficient level.
118Minimal to save resources and sufficient in that the system is used at 117Minimal to save resources and sufficient in that the system is used at
119its full capacity. 118its full capacity.
120 119
121Each thread-pool bound to an actual CPU implements concurrency 120Each worker-pool bound to an actual CPU implements concurrency
122management by hooking into the scheduler. The thread-pool is notified 121management by hooking into the scheduler. The worker-pool is notified
123whenever an active worker wakes up or sleeps and keeps track of the 122whenever an active worker wakes up or sleeps and keeps track of the
124number of the currently runnable workers. Generally, work items are 123number of the currently runnable workers. Generally, work items are
125not expected to hog a CPU and consume many cycles. That means 124not expected to hog a CPU and consume many cycles. That means
126maintaining just enough concurrency to prevent work processing from 125maintaining just enough concurrency to prevent work processing from
127stalling should be optimal. As long as there are one or more runnable 126stalling should be optimal. As long as there are one or more runnable
128workers on the CPU, the thread-pool doesn't start execution of a new 127workers on the CPU, the worker-pool doesn't start execution of a new
129work, but, when the last running worker goes to sleep, it immediately 128work, but, when the last running worker goes to sleep, it immediately
130schedules a new worker so that the CPU doesn't sit idle while there 129schedules a new worker so that the CPU doesn't sit idle while there
131are pending work items. This allows using a minimal number of workers 130are pending work items. This allows using a minimal number of workers
@@ -135,19 +134,20 @@ Keeping idle workers around doesn't cost other than the memory space
135for kthreads, so cmwq holds onto idle ones for a while before killing 134for kthreads, so cmwq holds onto idle ones for a while before killing
136them. 135them.
137 136
138For an unbound wq, the above concurrency management doesn't apply and 137For unbound workqueues, the number of backing pools is dynamic.
139the thread-pools for the pseudo unbound CPU try to start executing all 138Unbound workqueue can be assigned custom attributes using
140work items as soon as possible. The responsibility of regulating 139apply_workqueue_attrs() and workqueue will automatically create
141concurrency level is on the users. There is also a flag to mark a 140backing worker pools matching the attributes. The responsibility of
142bound wq to ignore the concurrency management. Please refer to the 141regulating concurrency level is on the users. There is also a flag to
143API section for details. 142mark a bound wq to ignore the concurrency management. Please refer to
143the API section for details.
144 144
145Forward progress guarantee relies on that workers can be created when 145Forward progress guarantee relies on that workers can be created when
146more execution contexts are necessary, which in turn is guaranteed 146more execution contexts are necessary, which in turn is guaranteed
147through the use of rescue workers. All work items which might be used 147through the use of rescue workers. All work items which might be used
148on code paths that handle memory reclaim are required to be queued on 148on code paths that handle memory reclaim are required to be queued on
149wq's that have a rescue-worker reserved for execution under memory 149wq's that have a rescue-worker reserved for execution under memory
150pressure. Else it is possible that the thread-pool deadlocks waiting 150pressure. Else it is possible that the worker-pool deadlocks waiting
151for execution contexts to free up. 151for execution contexts to free up.
152 152
153 153
@@ -168,13 +168,13 @@ resources, scheduled and executed.
168 168
169 WQ_UNBOUND 169 WQ_UNBOUND
170 170
171 Work items queued to an unbound wq are served by a special 171 Work items queued to an unbound wq are served by the special
172 gcwq which hosts workers which are not bound to any specific 172 woker-pools which host workers which are not bound to any
173 CPU. This makes the wq behave as a simple execution context 173 specific CPU. This makes the wq behave as a simple execution
174 provider without concurrency management. The unbound gcwq 174 context provider without concurrency management. The unbound
175 tries to start execution of work items as soon as possible. 175 worker-pools try to start execution of work items as soon as
176 Unbound wq sacrifices locality but is useful for the following 176 possible. Unbound wq sacrifices locality but is useful for
177 cases. 177 the following cases.
178 178
179 * Wide fluctuation in the concurrency level requirement is 179 * Wide fluctuation in the concurrency level requirement is
180 expected and using bound wq may end up creating large number 180 expected and using bound wq may end up creating large number
@@ -199,10 +199,10 @@ resources, scheduled and executed.
199 WQ_HIGHPRI 199 WQ_HIGHPRI
200 200
201 Work items of a highpri wq are queued to the highpri 201 Work items of a highpri wq are queued to the highpri
202 thread-pool of the target gcwq. Highpri thread-pools are 202 worker-pool of the target cpu. Highpri worker-pools are
203 served by worker threads with elevated nice level. 203 served by worker threads with elevated nice level.
204 204
205 Note that normal and highpri thread-pools don't interact with 205 Note that normal and highpri worker-pools don't interact with
206 each other. Each maintain its separate pool of workers and 206 each other. Each maintain its separate pool of workers and
207 implements concurrency management among its workers. 207 implements concurrency management among its workers.
208 208
@@ -211,7 +211,7 @@ resources, scheduled and executed.
211 Work items of a CPU intensive wq do not contribute to the 211 Work items of a CPU intensive wq do not contribute to the
212 concurrency level. In other words, runnable CPU intensive 212 concurrency level. In other words, runnable CPU intensive
213 work items will not prevent other work items in the same 213 work items will not prevent other work items in the same
214 thread-pool from starting execution. This is useful for bound 214 worker-pool from starting execution. This is useful for bound
215 work items which are expected to hog CPU cycles so that their 215 work items which are expected to hog CPU cycles so that their
216 execution is regulated by the system scheduler. 216 execution is regulated by the system scheduler.
217 217
@@ -248,9 +248,9 @@ recommended.
248 248
249Some users depend on the strict execution ordering of ST wq. The 249Some users depend on the strict execution ordering of ST wq. The
250combination of @max_active of 1 and WQ_UNBOUND is used to achieve this 250combination of @max_active of 1 and WQ_UNBOUND is used to achieve this
251behavior. Work items on such wq are always queued to the unbound gcwq 251behavior. Work items on such wq are always queued to the unbound
252and only one work item can be active at any given time thus achieving 252worker-pools and only one work item can be active at any given time thus
253the same ordering property as ST wq. 253achieving the same ordering property as ST wq.
254 254
255 255
2565. Example Execution Scenarios 2565. Example Execution Scenarios