aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/workqueue.txt29
-rw-r--r--drivers/ata/libata-sff.c2
-rw-r--r--fs/gfs2/main.c2
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c2
-rw-r--r--include/linux/workqueue.h11
-rw-r--r--kernel/workqueue.c7
6 files changed, 31 insertions, 22 deletions
diff --git a/Documentation/workqueue.txt b/Documentation/workqueue.txt
index e4498a2872c3..996a27d9b8db 100644
--- a/Documentation/workqueue.txt
+++ b/Documentation/workqueue.txt
@@ -196,11 +196,11 @@ resources, scheduled and executed.
196 suspend operations. Work items on the wq are drained and no 196 suspend operations. Work items on the wq are drained and no
197 new work item starts execution until thawed. 197 new work item starts execution until thawed.
198 198
199 WQ_RESCUER 199 WQ_MEM_RECLAIM
200 200
201 All wq which might be used in the memory reclaim paths _MUST_ 201 All wq which might be used in the memory reclaim paths _MUST_
202 have this flag set. This reserves one worker exclusively for 202 have this flag set. The wq is guaranteed to have at least one
203 the execution of this wq under memory pressure. 203 execution context regardless of memory pressure.
204 204
205 WQ_HIGHPRI 205 WQ_HIGHPRI
206 206
@@ -356,11 +356,11 @@ If q1 has WQ_CPU_INTENSIVE set,
356 356
3576. Guidelines 3576. Guidelines
358 358
359* Do not forget to use WQ_RESCUER if a wq may process work items which 359* Do not forget to use WQ_MEM_RECLAIM if a wq may process work items
360 are used during memory reclaim. Each wq with WQ_RESCUER set has one 360 which are used during memory reclaim. Each wq with WQ_MEM_RECLAIM
361 rescuer thread reserved for it. If there is dependency among 361 set has an execution context reserved for it. If there is
362 multiple work items used during memory reclaim, they should be 362 dependency among multiple work items used during memory reclaim,
363 queued to separate wq each with WQ_RESCUER. 363 they should be queued to separate wq each with WQ_MEM_RECLAIM.
364 364
365* Unless strict ordering is required, there is no need to use ST wq. 365* Unless strict ordering is required, there is no need to use ST wq.
366 366
@@ -368,12 +368,13 @@ If q1 has WQ_CPU_INTENSIVE set,
368 recommended. In most use cases, concurrency level usually stays 368 recommended. In most use cases, concurrency level usually stays
369 well under the default limit. 369 well under the default limit.
370 370
371* A wq serves as a domain for forward progress guarantee (WQ_RESCUER), 371* A wq serves as a domain for forward progress guarantee
372 flush and work item attributes. Work items which are not involved 372 (WQ_MEM_RECLAIM, flush and work item attributes. Work items which
373 in memory reclaim and don't need to be flushed as a part of a group 373 are not involved in memory reclaim and don't need to be flushed as a
374 of work items, and don't require any special attribute, can use one 374 part of a group of work items, and don't require any special
375 of the system wq. There is no difference in execution 375 attribute, can use one of the system wq. There is no difference in
376 characteristics between using a dedicated wq and a system wq. 376 execution characteristics between using a dedicated wq and a system
377 wq.
377 378
378* Unless work items are expected to consume a huge amount of CPU 379* Unless work items are expected to consume a huge amount of CPU
379 cycles, using a bound wq is usually beneficial due to the increased 380 cycles, using a bound wq is usually beneficial due to the increased
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index e30c537cce32..f5296bb19ec0 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -3335,7 +3335,7 @@ void ata_sff_port_init(struct ata_port *ap)
3335 3335
3336int __init ata_sff_init(void) 3336int __init ata_sff_init(void)
3337{ 3337{
3338 ata_sff_wq = alloc_workqueue("ata_sff", WQ_RESCUER, WQ_MAX_ACTIVE); 3338 ata_sff_wq = alloc_workqueue("ata_sff", WQ_MEM_RECLAIM, WQ_MAX_ACTIVE);
3339 if (!ata_sff_wq) 3339 if (!ata_sff_wq)
3340 return -ENOMEM; 3340 return -ENOMEM;
3341 3341
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c
index b1e9630eb46a..1c5f46075d52 100644
--- a/fs/gfs2/main.c
+++ b/fs/gfs2/main.c
@@ -140,7 +140,7 @@ static int __init init_gfs2_fs(void)
140 140
141 error = -ENOMEM; 141 error = -ENOMEM;
142 gfs_recovery_wq = alloc_workqueue("gfs_recovery", 142 gfs_recovery_wq = alloc_workqueue("gfs_recovery",
143 WQ_NON_REENTRANT | WQ_RESCUER, 0); 143 WQ_NON_REENTRANT | WQ_MEM_RECLAIM, 0);
144 if (!gfs_recovery_wq) 144 if (!gfs_recovery_wq)
145 goto fail_wq; 145 goto fail_wq;
146 146
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index 286e36e21dae..6838aefca71f 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -1933,7 +1933,7 @@ xfs_buf_init(void)
1933 goto out; 1933 goto out;
1934 1934
1935 xfslogd_workqueue = alloc_workqueue("xfslogd", 1935 xfslogd_workqueue = alloc_workqueue("xfslogd",
1936 WQ_RESCUER | WQ_HIGHPRI, 1); 1936 WQ_MEM_RECLAIM | WQ_HIGHPRI, 1);
1937 if (!xfslogd_workqueue) 1937 if (!xfslogd_workqueue)
1938 goto out_free_buf_zone; 1938 goto out_free_buf_zone;
1939 1939
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index e33ff4a91703..03bbe903e5ce 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -243,11 +243,12 @@ enum {
243 WQ_NON_REENTRANT = 1 << 0, /* guarantee non-reentrance */ 243 WQ_NON_REENTRANT = 1 << 0, /* guarantee non-reentrance */
244 WQ_UNBOUND = 1 << 1, /* not bound to any cpu */ 244 WQ_UNBOUND = 1 << 1, /* not bound to any cpu */
245 WQ_FREEZEABLE = 1 << 2, /* freeze during suspend */ 245 WQ_FREEZEABLE = 1 << 2, /* freeze during suspend */
246 WQ_RESCUER = 1 << 3, /* has an rescue worker */ 246 WQ_MEM_RECLAIM = 1 << 3, /* may be used for memory reclaim */
247 WQ_HIGHPRI = 1 << 4, /* high priority */ 247 WQ_HIGHPRI = 1 << 4, /* high priority */
248 WQ_CPU_INTENSIVE = 1 << 5, /* cpu instensive workqueue */ 248 WQ_CPU_INTENSIVE = 1 << 5, /* cpu instensive workqueue */
249 249
250 WQ_DYING = 1 << 6, /* internal: workqueue is dying */ 250 WQ_DYING = 1 << 6, /* internal: workqueue is dying */
251 WQ_RESCUER = 1 << 7, /* internal: workqueue has rescuer */
251 252
252 WQ_MAX_ACTIVE = 512, /* I like 512, better ideas? */ 253 WQ_MAX_ACTIVE = 512, /* I like 512, better ideas? */
253 WQ_MAX_UNBOUND_PER_CPU = 4, /* 4 * #cpus for unbound wq */ 254 WQ_MAX_UNBOUND_PER_CPU = 4, /* 4 * #cpus for unbound wq */
@@ -309,7 +310,7 @@ __alloc_workqueue_key(const char *name, unsigned int flags, int max_active,
309/** 310/**
310 * alloc_ordered_workqueue - allocate an ordered workqueue 311 * alloc_ordered_workqueue - allocate an ordered workqueue
311 * @name: name of the workqueue 312 * @name: name of the workqueue
312 * @flags: WQ_* flags (only WQ_FREEZEABLE and WQ_RESCUER are meaningful) 313 * @flags: WQ_* flags (only WQ_FREEZEABLE and WQ_MEM_RECLAIM are meaningful)
313 * 314 *
314 * Allocate an ordered workqueue. An ordered workqueue executes at 315 * Allocate an ordered workqueue. An ordered workqueue executes at
315 * most one work item at any given time in the queued order. They are 316 * most one work item at any given time in the queued order. They are
@@ -325,11 +326,11 @@ alloc_ordered_workqueue(const char *name, unsigned int flags)
325} 326}
326 327
327#define create_workqueue(name) \ 328#define create_workqueue(name) \
328 alloc_workqueue((name), WQ_RESCUER, 1) 329 alloc_workqueue((name), WQ_MEM_RECLAIM, 1)
329#define create_freezeable_workqueue(name) \ 330#define create_freezeable_workqueue(name) \
330 alloc_workqueue((name), WQ_FREEZEABLE | WQ_UNBOUND | WQ_RESCUER, 1) 331 alloc_workqueue((name), WQ_FREEZEABLE | WQ_UNBOUND | WQ_MEM_RECLAIM, 1)
331#define create_singlethread_workqueue(name) \ 332#define create_singlethread_workqueue(name) \
332 alloc_workqueue((name), WQ_UNBOUND | WQ_RESCUER, 1) 333 alloc_workqueue((name), WQ_UNBOUND | WQ_MEM_RECLAIM, 1)
333 334
334extern void destroy_workqueue(struct workqueue_struct *wq); 335extern void destroy_workqueue(struct workqueue_struct *wq);
335 336
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index b57a8babdec3..2c6871cbcbee 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2848,6 +2848,13 @@ struct workqueue_struct *__alloc_workqueue_key(const char *name,
2848 unsigned int cpu; 2848 unsigned int cpu;
2849 2849
2850 /* 2850 /*
2851 * Workqueues which may be used during memory reclaim should
2852 * have a rescuer to guarantee forward progress.
2853 */
2854 if (flags & WQ_MEM_RECLAIM)
2855 flags |= WQ_RESCUER;
2856
2857 /*
2851 * Unbound workqueues aren't concurrency managed and should be 2858 * Unbound workqueues aren't concurrency managed and should be
2852 * dispatched to workers immediately. 2859 * dispatched to workers immediately.
2853 */ 2860 */