diff options
Diffstat (limited to 'include/linux/workqueue.h')
-rw-r--r-- | include/linux/workqueue.h | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index 0d556deb497b..eb8b9f15f2e0 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h | |||
@@ -297,32 +297,50 @@ extern struct workqueue_struct *system_unbound_wq; | |||
297 | extern struct workqueue_struct *system_freezable_wq; | 297 | extern struct workqueue_struct *system_freezable_wq; |
298 | 298 | ||
299 | extern struct workqueue_struct * | 299 | extern struct workqueue_struct * |
300 | __alloc_workqueue_key(const char *name, unsigned int flags, int max_active, | 300 | __alloc_workqueue_key(const char *fmt, unsigned int flags, int max_active, |
301 | struct lock_class_key *key, const char *lock_name); | 301 | struct lock_class_key *key, const char *lock_name, ...) __printf(1, 6); |
302 | 302 | ||
303 | /** | ||
304 | * alloc_workqueue - allocate a workqueue | ||
305 | * @fmt: printf format for the name of the workqueue | ||
306 | * @flags: WQ_* flags | ||
307 | * @max_active: max in-flight work items, 0 for default | ||
308 | * @args: args for @fmt | ||
309 | * | ||
310 | * Allocate a workqueue with the specified parameters. For detailed | ||
311 | * information on WQ_* flags, please refer to Documentation/workqueue.txt. | ||
312 | * | ||
313 | * The __lock_name macro dance is to guarantee that single lock_class_key | ||
314 | * doesn't end up with different namesm, which isn't allowed by lockdep. | ||
315 | * | ||
316 | * RETURNS: | ||
317 | * Pointer to the allocated workqueue on success, %NULL on failure. | ||
318 | */ | ||
303 | #ifdef CONFIG_LOCKDEP | 319 | #ifdef CONFIG_LOCKDEP |
304 | #define alloc_workqueue(name, flags, max_active) \ | 320 | #define alloc_workqueue(fmt, flags, max_active, args...) \ |
305 | ({ \ | 321 | ({ \ |
306 | static struct lock_class_key __key; \ | 322 | static struct lock_class_key __key; \ |
307 | const char *__lock_name; \ | 323 | const char *__lock_name; \ |
308 | \ | 324 | \ |
309 | if (__builtin_constant_p(name)) \ | 325 | if (__builtin_constant_p(fmt)) \ |
310 | __lock_name = (name); \ | 326 | __lock_name = (fmt); \ |
311 | else \ | 327 | else \ |
312 | __lock_name = #name; \ | 328 | __lock_name = #fmt; \ |
313 | \ | 329 | \ |
314 | __alloc_workqueue_key((name), (flags), (max_active), \ | 330 | __alloc_workqueue_key((fmt), (flags), (max_active), \ |
315 | &__key, __lock_name); \ | 331 | &__key, __lock_name, ##args); \ |
316 | }) | 332 | }) |
317 | #else | 333 | #else |
318 | #define alloc_workqueue(name, flags, max_active) \ | 334 | #define alloc_workqueue(fmt, flags, max_active, args...) \ |
319 | __alloc_workqueue_key((name), (flags), (max_active), NULL, NULL) | 335 | __alloc_workqueue_key((fmt), (flags), (max_active), \ |
336 | NULL, NULL, ##args) | ||
320 | #endif | 337 | #endif |
321 | 338 | ||
322 | /** | 339 | /** |
323 | * alloc_ordered_workqueue - allocate an ordered workqueue | 340 | * alloc_ordered_workqueue - allocate an ordered workqueue |
324 | * @name: name of the workqueue | 341 | * @fmt: printf format for the name of the workqueue |
325 | * @flags: WQ_* flags (only WQ_FREEZABLE and WQ_MEM_RECLAIM are meaningful) | 342 | * @flags: WQ_* flags (only WQ_FREEZABLE and WQ_MEM_RECLAIM are meaningful) |
343 | * @args: args for @fmt | ||
326 | * | 344 | * |
327 | * Allocate an ordered workqueue. An ordered workqueue executes at | 345 | * Allocate an ordered workqueue. An ordered workqueue executes at |
328 | * most one work item at any given time in the queued order. They are | 346 | * most one work item at any given time in the queued order. They are |
@@ -331,11 +349,8 @@ __alloc_workqueue_key(const char *name, unsigned int flags, int max_active, | |||
331 | * RETURNS: | 349 | * RETURNS: |
332 | * Pointer to the allocated workqueue on success, %NULL on failure. | 350 | * Pointer to the allocated workqueue on success, %NULL on failure. |
333 | */ | 351 | */ |
334 | static inline struct workqueue_struct * | 352 | #define alloc_ordered_workqueue(fmt, flags, args...) \ |
335 | alloc_ordered_workqueue(const char *name, unsigned int flags) | 353 | alloc_workqueue(fmt, WQ_UNBOUND | (flags), 1, ##args) |
336 | { | ||
337 | return alloc_workqueue(name, WQ_UNBOUND | flags, 1); | ||
338 | } | ||
339 | 354 | ||
340 | #define create_workqueue(name) \ | 355 | #define create_workqueue(name) \ |
341 | alloc_workqueue((name), WQ_MEM_RECLAIM, 1) | 356 | alloc_workqueue((name), WQ_MEM_RECLAIM, 1) |