mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
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>
This commit is contained in:
parent
4e1a1f9a05
commit
7a4e344c56
2 changed files with 94 additions and 22 deletions
|
@ -11,6 +11,7 @@
|
|||
#include <linux/lockdep.h>
|
||||
#include <linux/threads.h>
|
||||
#include <linux/atomic.h>
|
||||
#include <linux/cpumask.h>
|
||||
|
||||
struct workqueue_struct;
|
||||
|
||||
|
@ -115,6 +116,15 @@ struct delayed_work {
|
|||
int cpu;
|
||||
};
|
||||
|
||||
/*
|
||||
* A struct for workqueue attributes. This can be used to change
|
||||
* attributes of an unbound workqueue.
|
||||
*/
|
||||
struct workqueue_attrs {
|
||||
int nice; /* nice level */
|
||||
cpumask_var_t cpumask; /* allowed CPUs */
|
||||
};
|
||||
|
||||
static inline struct delayed_work *to_delayed_work(struct work_struct *work)
|
||||
{
|
||||
return container_of(work, struct delayed_work, work);
|
||||
|
@ -399,6 +409,9 @@ __alloc_workqueue_key(const char *fmt, unsigned int flags, int max_active,
|
|||
|
||||
extern void destroy_workqueue(struct workqueue_struct *wq);
|
||||
|
||||
struct workqueue_attrs *alloc_workqueue_attrs(gfp_t gfp_mask);
|
||||
void free_workqueue_attrs(struct workqueue_attrs *attrs);
|
||||
|
||||
extern bool queue_work_on(int cpu, struct workqueue_struct *wq,
|
||||
struct work_struct *work);
|
||||
extern bool queue_work(struct workqueue_struct *wq, struct work_struct *work);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue