diff options
author | Tejun Heo <tj@kernel.org> | 2013-03-12 14:30:00 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-03-12 14:30:00 -0400 |
commit | 7a4e344c5675eefbde93ed9a98ef45e0e4957bc2 (patch) | |
tree | 7a4383063512328184db9d20e27164824c44dc2c /include/linux/workqueue.h | |
parent | 4e1a1f9a051b4c9a2821a2a0f7f4a27c701fba51 (diff) |
workqueue: introduce workqueue_attrs
Introduce struct workqueue_attrs which carries worker attributes -
currently the nice level and allowed cpumask along with helper
routines alloc_workqueue_attrs() and free_workqueue_attrs().
Each worker_pool now carries ->attrs describing the attributes of its
workers. All functions dealing with cpumask and nice level of workers
are updated to follow worker_pool->attrs instead of determining them
from other characteristics of the worker_pool, and init_workqueues()
is updated to set worker_pool->attrs appropriately for all standard
pools.
Note that create_worker() is updated to always perform set_user_nice()
and use set_cpus_allowed_ptr() combined with manual assertion of
PF_THREAD_BOUND instead of kthread_bind(). This simplifies handling
random attributes without affecting the outcome.
This patch doesn't introduce any behavior changes.
v2: Missing cpumask_var_t definition caused build failure on some
archs. linux/cpumask.h included.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Reviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Diffstat (limited to 'include/linux/workqueue.h')
-rw-r--r-- | include/linux/workqueue.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index 899be6636d20..00c1b9ba8252 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/lockdep.h> | 11 | #include <linux/lockdep.h> |
12 | #include <linux/threads.h> | 12 | #include <linux/threads.h> |
13 | #include <linux/atomic.h> | 13 | #include <linux/atomic.h> |
14 | #include <linux/cpumask.h> | ||
14 | 15 | ||
15 | struct workqueue_struct; | 16 | struct workqueue_struct; |
16 | 17 | ||
@@ -115,6 +116,15 @@ struct delayed_work { | |||
115 | int cpu; | 116 | int cpu; |
116 | }; | 117 | }; |
117 | 118 | ||
119 | /* | ||
120 | * A struct for workqueue attributes. This can be used to change | ||
121 | * attributes of an unbound workqueue. | ||
122 | */ | ||
123 | struct workqueue_attrs { | ||
124 | int nice; /* nice level */ | ||
125 | cpumask_var_t cpumask; /* allowed CPUs */ | ||
126 | }; | ||
127 | |||
118 | static inline struct delayed_work *to_delayed_work(struct work_struct *work) | 128 | static inline struct delayed_work *to_delayed_work(struct work_struct *work) |
119 | { | 129 | { |
120 | return container_of(work, struct delayed_work, work); | 130 | return container_of(work, struct delayed_work, work); |
@@ -399,6 +409,9 @@ __alloc_workqueue_key(const char *fmt, unsigned int flags, int max_active, | |||
399 | 409 | ||
400 | extern void destroy_workqueue(struct workqueue_struct *wq); | 410 | extern void destroy_workqueue(struct workqueue_struct *wq); |
401 | 411 | ||
412 | struct workqueue_attrs *alloc_workqueue_attrs(gfp_t gfp_mask); | ||
413 | void free_workqueue_attrs(struct workqueue_attrs *attrs); | ||
414 | |||
402 | extern bool queue_work_on(int cpu, struct workqueue_struct *wq, | 415 | extern bool queue_work_on(int cpu, struct workqueue_struct *wq, |
403 | struct work_struct *work); | 416 | struct work_struct *work); |
404 | extern bool queue_work(struct workqueue_struct *wq, struct work_struct *work); | 417 | extern bool queue_work(struct workqueue_struct *wq, struct work_struct *work); |