mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-03 21:01:50 +00:00
workqueue: replace for_each_worker_pool() with for_each_std_worker_pool()
for_each_std_worker_pool() takes @cpu instead of @gcwq. This is part of an effort to remove global_cwq and make worker_pool the top level abstraction, which in turn will help implementing worker pools with user-specified attributes. Signed-off-by: Tejun Heo <tj@kernel.org> Reviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>
This commit is contained in:
parent
a1056305fa
commit
38db41d984
1 changed files with 17 additions and 22 deletions
|
@ -250,9 +250,9 @@ EXPORT_SYMBOL_GPL(system_freezable_wq);
|
||||||
#define CREATE_TRACE_POINTS
|
#define CREATE_TRACE_POINTS
|
||||||
#include <trace/events/workqueue.h>
|
#include <trace/events/workqueue.h>
|
||||||
|
|
||||||
#define for_each_worker_pool(pool, gcwq) \
|
#define for_each_std_worker_pool(pool, cpu) \
|
||||||
for ((pool) = &(gcwq)->pools[0]; \
|
for ((pool) = &get_gcwq((cpu))->pools[0]; \
|
||||||
(pool) < &(gcwq)->pools[NR_STD_WORKER_POOLS]; (pool)++)
|
(pool) < &get_gcwq((cpu))->pools[NR_STD_WORKER_POOLS]; (pool)++)
|
||||||
|
|
||||||
#define for_each_busy_worker(worker, i, pos, pool) \
|
#define for_each_busy_worker(worker, i, pos, pool) \
|
||||||
hash_for_each(pool->busy_hash, i, pos, worker, hentry)
|
hash_for_each(pool->busy_hash, i, pos, worker, hentry)
|
||||||
|
@ -3500,14 +3500,14 @@ EXPORT_SYMBOL_GPL(work_busy);
|
||||||
|
|
||||||
static void gcwq_unbind_fn(struct work_struct *work)
|
static void gcwq_unbind_fn(struct work_struct *work)
|
||||||
{
|
{
|
||||||
struct global_cwq *gcwq = get_gcwq(smp_processor_id());
|
int cpu = smp_processor_id();
|
||||||
struct worker_pool *pool;
|
struct worker_pool *pool;
|
||||||
struct worker *worker;
|
struct worker *worker;
|
||||||
struct hlist_node *pos;
|
struct hlist_node *pos;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for_each_worker_pool(pool, gcwq) {
|
for_each_std_worker_pool(pool, cpu) {
|
||||||
BUG_ON(pool->cpu != smp_processor_id());
|
BUG_ON(cpu != smp_processor_id());
|
||||||
|
|
||||||
mutex_lock(&pool->assoc_mutex);
|
mutex_lock(&pool->assoc_mutex);
|
||||||
spin_lock_irq(&pool->lock);
|
spin_lock_irq(&pool->lock);
|
||||||
|
@ -3541,15 +3541,15 @@ static void gcwq_unbind_fn(struct work_struct *work)
|
||||||
/*
|
/*
|
||||||
* Sched callbacks are disabled now. Zap nr_running. After this,
|
* Sched callbacks are disabled now. Zap nr_running. After this,
|
||||||
* nr_running stays zero and need_more_worker() and keep_working()
|
* nr_running stays zero and need_more_worker() and keep_working()
|
||||||
* are always true as long as the worklist is not empty. @gcwq now
|
* are always true as long as the worklist is not empty. Pools on
|
||||||
* behaves as unbound (in terms of concurrency management) gcwq
|
* @cpu now behave as unbound (in terms of concurrency management)
|
||||||
* which is served by workers tied to the CPU.
|
* pools which are served by workers tied to the CPU.
|
||||||
*
|
*
|
||||||
* On return from this function, the current worker would trigger
|
* On return from this function, the current worker would trigger
|
||||||
* unbound chain execution of pending work items if other workers
|
* unbound chain execution of pending work items if other workers
|
||||||
* didn't already.
|
* didn't already.
|
||||||
*/
|
*/
|
||||||
for_each_worker_pool(pool, gcwq)
|
for_each_std_worker_pool(pool, cpu)
|
||||||
atomic_set(get_pool_nr_running(pool), 0);
|
atomic_set(get_pool_nr_running(pool), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3562,12 +3562,11 @@ static int __cpuinit workqueue_cpu_up_callback(struct notifier_block *nfb,
|
||||||
void *hcpu)
|
void *hcpu)
|
||||||
{
|
{
|
||||||
unsigned int cpu = (unsigned long)hcpu;
|
unsigned int cpu = (unsigned long)hcpu;
|
||||||
struct global_cwq *gcwq = get_gcwq(cpu);
|
|
||||||
struct worker_pool *pool;
|
struct worker_pool *pool;
|
||||||
|
|
||||||
switch (action & ~CPU_TASKS_FROZEN) {
|
switch (action & ~CPU_TASKS_FROZEN) {
|
||||||
case CPU_UP_PREPARE:
|
case CPU_UP_PREPARE:
|
||||||
for_each_worker_pool(pool, gcwq) {
|
for_each_std_worker_pool(pool, cpu) {
|
||||||
struct worker *worker;
|
struct worker *worker;
|
||||||
|
|
||||||
if (pool->nr_workers)
|
if (pool->nr_workers)
|
||||||
|
@ -3585,7 +3584,7 @@ static int __cpuinit workqueue_cpu_up_callback(struct notifier_block *nfb,
|
||||||
|
|
||||||
case CPU_DOWN_FAILED:
|
case CPU_DOWN_FAILED:
|
||||||
case CPU_ONLINE:
|
case CPU_ONLINE:
|
||||||
for_each_worker_pool(pool, gcwq) {
|
for_each_std_worker_pool(pool, cpu) {
|
||||||
mutex_lock(&pool->assoc_mutex);
|
mutex_lock(&pool->assoc_mutex);
|
||||||
spin_lock_irq(&pool->lock);
|
spin_lock_irq(&pool->lock);
|
||||||
|
|
||||||
|
@ -3682,11 +3681,10 @@ void freeze_workqueues_begin(void)
|
||||||
workqueue_freezing = true;
|
workqueue_freezing = true;
|
||||||
|
|
||||||
for_each_gcwq_cpu(cpu) {
|
for_each_gcwq_cpu(cpu) {
|
||||||
struct global_cwq *gcwq = get_gcwq(cpu);
|
|
||||||
struct worker_pool *pool;
|
struct worker_pool *pool;
|
||||||
struct workqueue_struct *wq;
|
struct workqueue_struct *wq;
|
||||||
|
|
||||||
for_each_worker_pool(pool, gcwq) {
|
for_each_std_worker_pool(pool, cpu) {
|
||||||
spin_lock_irq(&pool->lock);
|
spin_lock_irq(&pool->lock);
|
||||||
|
|
||||||
WARN_ON_ONCE(pool->flags & POOL_FREEZING);
|
WARN_ON_ONCE(pool->flags & POOL_FREEZING);
|
||||||
|
@ -3772,11 +3770,10 @@ void thaw_workqueues(void)
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
|
|
||||||
for_each_gcwq_cpu(cpu) {
|
for_each_gcwq_cpu(cpu) {
|
||||||
struct global_cwq *gcwq = get_gcwq(cpu);
|
|
||||||
struct worker_pool *pool;
|
struct worker_pool *pool;
|
||||||
struct workqueue_struct *wq;
|
struct workqueue_struct *wq;
|
||||||
|
|
||||||
for_each_worker_pool(pool, gcwq) {
|
for_each_std_worker_pool(pool, cpu) {
|
||||||
spin_lock_irq(&pool->lock);
|
spin_lock_irq(&pool->lock);
|
||||||
|
|
||||||
WARN_ON_ONCE(!(pool->flags & POOL_FREEZING));
|
WARN_ON_ONCE(!(pool->flags & POOL_FREEZING));
|
||||||
|
@ -3818,11 +3815,10 @@ static int __init init_workqueues(void)
|
||||||
|
|
||||||
/* initialize gcwqs */
|
/* initialize gcwqs */
|
||||||
for_each_gcwq_cpu(cpu) {
|
for_each_gcwq_cpu(cpu) {
|
||||||
struct global_cwq *gcwq = get_gcwq(cpu);
|
|
||||||
struct worker_pool *pool;
|
struct worker_pool *pool;
|
||||||
|
|
||||||
for_each_worker_pool(pool, gcwq) {
|
for_each_std_worker_pool(pool, cpu) {
|
||||||
pool->gcwq = gcwq;
|
pool->gcwq = get_gcwq(cpu);
|
||||||
spin_lock_init(&pool->lock);
|
spin_lock_init(&pool->lock);
|
||||||
pool->cpu = cpu;
|
pool->cpu = cpu;
|
||||||
pool->flags |= POOL_DISASSOCIATED;
|
pool->flags |= POOL_DISASSOCIATED;
|
||||||
|
@ -3847,10 +3843,9 @@ static int __init init_workqueues(void)
|
||||||
|
|
||||||
/* create the initial worker */
|
/* create the initial worker */
|
||||||
for_each_online_gcwq_cpu(cpu) {
|
for_each_online_gcwq_cpu(cpu) {
|
||||||
struct global_cwq *gcwq = get_gcwq(cpu);
|
|
||||||
struct worker_pool *pool;
|
struct worker_pool *pool;
|
||||||
|
|
||||||
for_each_worker_pool(pool, gcwq) {
|
for_each_std_worker_pool(pool, cpu) {
|
||||||
struct worker *worker;
|
struct worker *worker;
|
||||||
|
|
||||||
if (cpu != WORK_CPU_UNBOUND)
|
if (cpu != WORK_CPU_UNBOUND)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue