Merge branch 'for-3.9' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq
Pull workqueue changes from Tejun Heo:
"A lot of reorganization is going on mostly to prepare for worker pools
with custom attributes so that workqueue can replace custom pool
implementations in places including writeback and btrfs and make CPU
assignment in crypto more flexible.
workqueue evolved from purely per-cpu design and implementation, so
there are a lot of assumptions regarding being bound to CPUs and even
unbound workqueues are implemented as an extension of the model -
workqueues running on the special unbound CPU. Bulk of changes this
round are about promoting worker_pools as the top level abstraction
replacing global_cwq (global cpu workqueue). At this point, I'm
fairly confident about getting custom worker pools working pretty soon
and ready for the next merge window.
Lai's patches are replacing the convoluted mb() dancing workqueue has
been doing with much simpler mechanism which only depends on
assignment atomicity of long. For details, please read the commit
message of 0b3dae68ac
("workqueue: simplify is-work-item-queued-here
test"). While the change ends up adding one pointer to struct
delayed_work, the inflation in percentage is less than five percent
and it decouples delayed_work logic a lot more cleaner from usual work
handling, removes the unusual memory barrier dancing, and allows for
further simplification, so I think the trade-off is acceptable.
There will be two more workqueue related pull requests and there are
some shared commits among them. I'll write further pull requests
assuming this pull request is pulled first."
* 'for-3.9' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq: (37 commits)
workqueue: un-GPL function delayed_work_timer_fn()
workqueue: rename cpu_workqueue to pool_workqueue
workqueue: reimplement is_chained_work() using current_wq_worker()
workqueue: fix is_chained_work() regression
workqueue: pick cwq instead of pool in __queue_work()
workqueue: make get_work_pool_id() cheaper
workqueue: move nr_running into worker_pool
workqueue: cosmetic update in try_to_grab_pending()
workqueue: simplify is-work-item-queued-here test
workqueue: make work->data point to pool after try_to_grab_pending()
workqueue: add delayed_work->wq to simplify reentrancy handling
workqueue: make work_busy() test WORK_STRUCT_PENDING first
workqueue: replace WORK_CPU_NONE/LAST with WORK_CPU_END
workqueue: post global_cwq removal cleanups
workqueue: rename nr_running variables
workqueue: remove global_cwq
workqueue: remove worker_pool->gcwq
workqueue: replace for_each_worker_pool() with for_each_std_worker_pool()
workqueue: make freezing/thawing per-pool
workqueue: make hotplug processing per-pool
...
This commit is contained in:
@@ -57,6 +57,8 @@ asynchronous and synchronous parts of the kernel.
|
||||
#include <linux/slab.h>
|
||||
#include <linux/workqueue.h>
|
||||
|
||||
#include "workqueue_internal.h"
|
||||
|
||||
static async_cookie_t next_cookie = 1;
|
||||
|
||||
#define MAX_WORK 32768
|
||||
@@ -353,3 +355,15 @@ void async_synchronize_cookie(async_cookie_t cookie)
|
||||
async_synchronize_cookie_domain(cookie, &async_running);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(async_synchronize_cookie);
|
||||
|
||||
/**
|
||||
* current_is_async - is %current an async worker task?
|
||||
*
|
||||
* Returns %true if %current is an async worker task.
|
||||
*/
|
||||
bool current_is_async(void)
|
||||
{
|
||||
struct worker *worker = current_wq_worker();
|
||||
|
||||
return worker && worker->current_func == async_run_entry_fn;
|
||||
}
|
||||
|
@@ -83,7 +83,7 @@
|
||||
#endif
|
||||
|
||||
#include "sched.h"
|
||||
#include "../workqueue_sched.h"
|
||||
#include "../workqueue_internal.h"
|
||||
#include "../smpboot.h"
|
||||
|
||||
#define CREATE_TRACE_POINTS
|
||||
|
1538
kernel/workqueue.c
1538
kernel/workqueue.c
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
Load Diff
65
kernel/workqueue_internal.h
Normal file
65
kernel/workqueue_internal.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* kernel/workqueue_internal.h
|
||||
*
|
||||
* Workqueue internal header file. Only to be included by workqueue and
|
||||
* core kernel subsystems.
|
||||
*/
|
||||
#ifndef _KERNEL_WORKQUEUE_INTERNAL_H
|
||||
#define _KERNEL_WORKQUEUE_INTERNAL_H
|
||||
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/kthread.h>
|
||||
|
||||
struct worker_pool;
|
||||
|
||||
/*
|
||||
* The poor guys doing the actual heavy lifting. All on-duty workers are
|
||||
* either serving the manager role, on idle list or on busy hash. For
|
||||
* details on the locking annotation (L, I, X...), refer to workqueue.c.
|
||||
*
|
||||
* Only to be used in workqueue and async.
|
||||
*/
|
||||
struct worker {
|
||||
/* on idle list while idle, on busy hash table while busy */
|
||||
union {
|
||||
struct list_head entry; /* L: while idle */
|
||||
struct hlist_node hentry; /* L: while busy */
|
||||
};
|
||||
|
||||
struct work_struct *current_work; /* L: work being processed */
|
||||
work_func_t current_func; /* L: current_work's fn */
|
||||
struct pool_workqueue *current_pwq; /* L: current_work's pwq */
|
||||
struct list_head scheduled; /* L: scheduled works */
|
||||
struct task_struct *task; /* I: worker task */
|
||||
struct worker_pool *pool; /* I: the associated pool */
|
||||
/* 64 bytes boundary on 64bit, 32 on 32bit */
|
||||
unsigned long last_active; /* L: last active timestamp */
|
||||
unsigned int flags; /* X: flags */
|
||||
int id; /* I: worker id */
|
||||
|
||||
/* for rebinding worker to CPU */
|
||||
struct work_struct rebind_work; /* L: for busy worker */
|
||||
|
||||
/* used only by rescuers to point to the target workqueue */
|
||||
struct workqueue_struct *rescue_wq; /* I: the workqueue to rescue */
|
||||
};
|
||||
|
||||
/**
|
||||
* current_wq_worker - return struct worker if %current is a workqueue worker
|
||||
*/
|
||||
static inline struct worker *current_wq_worker(void)
|
||||
{
|
||||
if (current->flags & PF_WQ_WORKER)
|
||||
return kthread_data(current);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Scheduler hooks for concurrency managed workqueue. Only to be used from
|
||||
* sched.c and workqueue.c.
|
||||
*/
|
||||
void wq_worker_waking_up(struct task_struct *task, unsigned int cpu);
|
||||
struct task_struct *wq_worker_sleeping(struct task_struct *task,
|
||||
unsigned int cpu);
|
||||
|
||||
#endif /* _KERNEL_WORKQUEUE_INTERNAL_H */
|
@@ -1,9 +0,0 @@
|
||||
/*
|
||||
* kernel/workqueue_sched.h
|
||||
*
|
||||
* Scheduler hooks for concurrency managed workqueue. Only to be
|
||||
* included from sched.c and workqueue.c.
|
||||
*/
|
||||
void wq_worker_waking_up(struct task_struct *task, unsigned int cpu);
|
||||
struct task_struct *wq_worker_sleeping(struct task_struct *task,
|
||||
unsigned int cpu);
|
Reference in New Issue
Block a user