diff options
| author | Andrew Morton <akpm@osdl.org> | 2004-04-26 08:55:21 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-04-26 08:55:21 -0700 |
| commit | bf9e688d76438678a6d5a902a2a57f7d866e2b51 (patch) | |
| tree | 9fb65d555f4fc41ac926eb563bbf7ddb576cdb5d /include | |
| parent | 18d0f1510dde10149ba59cc3b97083c99fb3e3b5 (diff) | |
[PATCH] create singlethread_workqueue()
From: Rusty Russell <rusty@rustcorp.com.au>
Workqueues are a great primitive for running things from user context from
a completely clean environment. Unfortunately, they currently insist on
creating one thread per CPU, which is overkill for many situations, so the
more generic keventd workqueue is used for these. Recently deadlocks using
keventd were demonstrated, showing that it is not suitable for all uses.
1) Clean up CPU iterators. Always a nice touch.
2) Add __create_workqueue() and create_singlethread_workqueue(),
keeping source compatibility.
3) Put workqueues in workqueue list even if !CONFIG_HOTPLUG_CPU (means
we need a lock to protect that list). Now we can tell if a wq is
single-threaded using list_empty(&wq->list).
4) For single-threaded workqueues, override CPU in queue_work,
delayed_work_timer_fn and flush_workqueue to be 0. flush_workqueue
now does redundant passes for single-threaded workqueues, but the
code remains simple.
5) Make create_workqueue_thread return the thread, so we can easily
kthread_bind for multi-threaded workqueues.
akpm fixes:
- Fix up is_single_threaded() handling
- single-threaded wq thread does not have "/0" appended.
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/workqueue.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index 435d9755e7c8..d9ee0fc9e84f 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -49,7 +49,11 @@ struct work_struct { init_timer(&(_work)->timer); \ } while (0) -extern struct workqueue_struct *create_workqueue(const char *name); +extern struct workqueue_struct *__create_workqueue(const char *name, + int singlethread); +#define create_workqueue(name) __create_workqueue((name), 0) +#define create_singlethread_workqueue(name) __create_workqueue((name), 1) + extern void destroy_workqueue(struct workqueue_struct *wq); extern int FASTCALL(queue_work(struct workqueue_struct *wq, struct work_struct *work)); |
