Lines Matching refs:wq
200 struct workqueue_struct *wq; /* I: the owning workqueue */ member
354 static void workqueue_sysfs_unregister(struct workqueue_struct *wq);
364 #define assert_rcu_or_wq_mutex(wq) \ argument
366 !lockdep_is_held(&wq->mutex), \
369 #define assert_rcu_or_wq_mutex_or_pool_mutex(wq) \ argument
371 !lockdep_is_held(&wq->mutex) && \
424 #define for_each_pwq(pwq, wq) \ argument
425 list_for_each_entry_rcu((pwq), &(wq)->pwqs, pwqs_node) \
426 if (({ assert_rcu_or_wq_mutex(wq); false; })) { } \
560 static struct pool_workqueue *unbound_pwq_by_node(struct workqueue_struct *wq, in unbound_pwq_by_node() argument
563 assert_rcu_or_wq_mutex_or_pool_mutex(wq); in unbound_pwq_by_node()
572 return wq->dfl_pwq; in unbound_pwq_by_node()
574 return rcu_dereference_raw(wq->numa_pwq_tbl[node]); in unbound_pwq_by_node()
1080 if (WARN_ON_ONCE(!(pwq->wq->flags & WQ_UNBOUND))) in put_pwq()
1173 if (atomic_dec_and_test(&pwq->wq->nr_pwqs_to_flush)) in pwq_dec_nr_in_flight()
1174 complete(&pwq->wq->first_flusher->done); in pwq_dec_nr_in_flight()
1318 static bool is_chained_work(struct workqueue_struct *wq) in is_chained_work() argument
1327 return worker && worker->current_pwq->wq == wq; in is_chained_work()
1363 static void __queue_work(int cpu, struct workqueue_struct *wq, in __queue_work() argument
1383 if (unlikely(wq->flags & __WQ_DRAINING) && in __queue_work()
1384 WARN_ON_ONCE(!is_chained_work(wq))) in __queue_work()
1391 if (!(wq->flags & WQ_UNBOUND)) in __queue_work()
1392 pwq = per_cpu_ptr(wq->cpu_pwqs, cpu); in __queue_work()
1394 pwq = unbound_pwq_by_node(wq, cpu_to_node(cpu)); in __queue_work()
1409 if (worker && worker->current_pwq->wq == wq) { in __queue_work()
1429 if (wq->flags & WQ_UNBOUND) { in __queue_work()
1436 wq->name, cpu); in __queue_work()
1477 bool queue_work_on(int cpu, struct workqueue_struct *wq, in queue_work_on() argument
1486 __queue_work(cpu, wq, work); in queue_work_on()
1500 __queue_work(dwork->cpu, dwork->wq, &dwork->work); in delayed_work_timer_fn()
1504 static void __queue_delayed_work(int cpu, struct workqueue_struct *wq, in __queue_delayed_work() argument
1510 WARN_ON_ONCE(!wq); in __queue_delayed_work()
1522 __queue_work(cpu, wq, &dwork->work); in __queue_delayed_work()
1526 dwork->wq = wq; in __queue_delayed_work()
1547 bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq, in queue_delayed_work_on() argument
1558 __queue_delayed_work(cpu, wq, dwork, delay); in queue_delayed_work_on()
1585 bool mod_delayed_work_on(int cpu, struct workqueue_struct *wq, in mod_delayed_work_on() argument
1596 __queue_delayed_work(cpu, wq, dwork, delay); in mod_delayed_work_on()
1611 __queue_work(WORK_CPU_UNBOUND, rwork->wq, &rwork->work); in rcu_work_rcufn()
1625 bool queue_rcu_work(struct workqueue_struct *wq, struct rcu_work *rwork) in queue_rcu_work() argument
1630 rwork->wq = wq; in queue_rcu_work()
1898 struct workqueue_struct *wq = pwq->wq; in send_mayday() local
1902 if (!wq->rescuer) in send_mayday()
1913 list_add_tail(&pwq->mayday_node, &wq->maydays); in send_mayday()
1914 wake_up_process(wq->rescuer->task); in send_mayday()
2052 bool cpu_intensive = pwq->wq->flags & WQ_CPU_INTENSIVE; in process_one_work()
2095 strscpy(worker->desc, pwq->wq->name, WORKER_DESC_LEN); in process_one_work()
2128 lock_map_acquire(&pwq->wq->lockdep_map); in process_one_work()
2160 lock_map_release(&pwq->wq->lockdep_map); in process_one_work()
2345 struct workqueue_struct *wq = rescuer->rescue_wq; in rescuer_thread() local
2372 while (!list_empty(&wq->maydays)) { in rescuer_thread()
2373 struct pool_workqueue *pwq = list_first_entry(&wq->maydays, in rescuer_thread()
2417 list_move_tail(&pwq->mayday_node, &wq->maydays); in rescuer_thread()
2482 WARN_ONCE(worker && ((worker->current_pwq->wq->flags & in check_flush_dependency()
2485 worker->current_pwq->wq->name, worker->current_func, in check_flush_dependency()
2596 static bool flush_workqueue_prep_pwqs(struct workqueue_struct *wq, in flush_workqueue_prep_pwqs() argument
2603 WARN_ON_ONCE(atomic_read(&wq->nr_pwqs_to_flush)); in flush_workqueue_prep_pwqs()
2604 atomic_set(&wq->nr_pwqs_to_flush, 1); in flush_workqueue_prep_pwqs()
2607 for_each_pwq(pwq, wq) { in flush_workqueue_prep_pwqs()
2617 atomic_inc(&wq->nr_pwqs_to_flush); in flush_workqueue_prep_pwqs()
2630 if (flush_color >= 0 && atomic_dec_and_test(&wq->nr_pwqs_to_flush)) in flush_workqueue_prep_pwqs()
2631 complete(&wq->first_flusher->done); in flush_workqueue_prep_pwqs()
2643 void flush_workqueue(struct workqueue_struct *wq) in flush_workqueue() argument
2648 .done = COMPLETION_INITIALIZER_ONSTACK_MAP(this_flusher.done, wq->lockdep_map), in flush_workqueue()
2655 lock_map_acquire(&wq->lockdep_map); in flush_workqueue()
2656 lock_map_release(&wq->lockdep_map); in flush_workqueue()
2658 mutex_lock(&wq->mutex); in flush_workqueue()
2663 next_color = work_next_color(wq->work_color); in flush_workqueue()
2665 if (next_color != wq->flush_color) { in flush_workqueue()
2671 WARN_ON_ONCE(!list_empty(&wq->flusher_overflow)); in flush_workqueue()
2672 this_flusher.flush_color = wq->work_color; in flush_workqueue()
2673 wq->work_color = next_color; in flush_workqueue()
2675 if (!wq->first_flusher) { in flush_workqueue()
2677 WARN_ON_ONCE(wq->flush_color != this_flusher.flush_color); in flush_workqueue()
2679 wq->first_flusher = &this_flusher; in flush_workqueue()
2681 if (!flush_workqueue_prep_pwqs(wq, wq->flush_color, in flush_workqueue()
2682 wq->work_color)) { in flush_workqueue()
2684 wq->flush_color = next_color; in flush_workqueue()
2685 wq->first_flusher = NULL; in flush_workqueue()
2690 WARN_ON_ONCE(wq->flush_color == this_flusher.flush_color); in flush_workqueue()
2691 list_add_tail(&this_flusher.list, &wq->flusher_queue); in flush_workqueue()
2692 flush_workqueue_prep_pwqs(wq, -1, wq->work_color); in flush_workqueue()
2700 list_add_tail(&this_flusher.list, &wq->flusher_overflow); in flush_workqueue()
2703 check_flush_dependency(wq, NULL); in flush_workqueue()
2705 mutex_unlock(&wq->mutex); in flush_workqueue()
2715 if (wq->first_flusher != &this_flusher) in flush_workqueue()
2718 mutex_lock(&wq->mutex); in flush_workqueue()
2721 if (wq->first_flusher != &this_flusher) in flush_workqueue()
2724 wq->first_flusher = NULL; in flush_workqueue()
2727 WARN_ON_ONCE(wq->flush_color != this_flusher.flush_color); in flush_workqueue()
2733 list_for_each_entry_safe(next, tmp, &wq->flusher_queue, list) { in flush_workqueue()
2734 if (next->flush_color != wq->flush_color) in flush_workqueue()
2740 WARN_ON_ONCE(!list_empty(&wq->flusher_overflow) && in flush_workqueue()
2741 wq->flush_color != work_next_color(wq->work_color)); in flush_workqueue()
2744 wq->flush_color = work_next_color(wq->flush_color); in flush_workqueue()
2747 if (!list_empty(&wq->flusher_overflow)) { in flush_workqueue()
2754 list_for_each_entry(tmp, &wq->flusher_overflow, list) in flush_workqueue()
2755 tmp->flush_color = wq->work_color; in flush_workqueue()
2757 wq->work_color = work_next_color(wq->work_color); in flush_workqueue()
2759 list_splice_tail_init(&wq->flusher_overflow, in flush_workqueue()
2760 &wq->flusher_queue); in flush_workqueue()
2761 flush_workqueue_prep_pwqs(wq, -1, wq->work_color); in flush_workqueue()
2764 if (list_empty(&wq->flusher_queue)) { in flush_workqueue()
2765 WARN_ON_ONCE(wq->flush_color != wq->work_color); in flush_workqueue()
2773 WARN_ON_ONCE(wq->flush_color == wq->work_color); in flush_workqueue()
2774 WARN_ON_ONCE(wq->flush_color != next->flush_color); in flush_workqueue()
2777 wq->first_flusher = next; in flush_workqueue()
2779 if (flush_workqueue_prep_pwqs(wq, wq->flush_color, -1)) in flush_workqueue()
2786 wq->first_flusher = NULL; in flush_workqueue()
2790 mutex_unlock(&wq->mutex); in flush_workqueue()
2805 void drain_workqueue(struct workqueue_struct *wq) in drain_workqueue() argument
2815 mutex_lock(&wq->mutex); in drain_workqueue()
2816 if (!wq->nr_drainers++) in drain_workqueue()
2817 wq->flags |= __WQ_DRAINING; in drain_workqueue()
2818 mutex_unlock(&wq->mutex); in drain_workqueue()
2820 flush_workqueue(wq); in drain_workqueue()
2822 mutex_lock(&wq->mutex); in drain_workqueue()
2824 for_each_pwq(pwq, wq) { in drain_workqueue()
2837 wq->name, flush_cnt); in drain_workqueue()
2839 mutex_unlock(&wq->mutex); in drain_workqueue()
2843 if (!--wq->nr_drainers) in drain_workqueue()
2844 wq->flags &= ~__WQ_DRAINING; in drain_workqueue()
2845 mutex_unlock(&wq->mutex); in drain_workqueue()
2878 check_flush_dependency(pwq->wq, work); in start_flush_work()
2893 (pwq->wq->saved_max_active == 1 || pwq->wq->rescuer)) { in start_flush_work()
2894 lock_map_acquire(&pwq->wq->lockdep_map); in start_flush_work()
2895 lock_map_release(&pwq->wq->lockdep_map); in start_flush_work()
3060 __queue_work(dwork->cpu, dwork->wq, &dwork->work); in flush_delayed_work()
3319 struct workqueue_struct *wq = in rcu_free_wq() local
3322 if (!(wq->flags & WQ_UNBOUND)) in rcu_free_wq()
3323 free_percpu(wq->cpu_pwqs); in rcu_free_wq()
3325 free_workqueue_attrs(wq->unbound_attrs); in rcu_free_wq()
3327 kfree(wq->rescuer); in rcu_free_wq()
3328 kfree(wq); in rcu_free_wq()
3490 struct workqueue_struct *wq = pwq->wq; in pwq_unbound_release_workfn() local
3494 if (WARN_ON_ONCE(!(wq->flags & WQ_UNBOUND))) in pwq_unbound_release_workfn()
3497 mutex_lock(&wq->mutex); in pwq_unbound_release_workfn()
3499 is_last = list_empty(&wq->pwqs); in pwq_unbound_release_workfn()
3500 mutex_unlock(&wq->mutex); in pwq_unbound_release_workfn()
3513 call_rcu_sched(&wq->rcu, rcu_free_wq); in pwq_unbound_release_workfn()
3526 struct workqueue_struct *wq = pwq->wq; in pwq_adjust_max_active() local
3527 bool freezable = wq->flags & WQ_FREEZABLE; in pwq_adjust_max_active()
3531 lockdep_assert_held(&wq->mutex); in pwq_adjust_max_active()
3534 if (!freezable && pwq->max_active == wq->saved_max_active) in pwq_adjust_max_active()
3546 pwq->max_active = wq->saved_max_active; in pwq_adjust_max_active()
3565 static void init_pwq(struct pool_workqueue *pwq, struct workqueue_struct *wq, in init_pwq() argument
3573 pwq->wq = wq; in init_pwq()
3585 struct workqueue_struct *wq = pwq->wq; in link_pwq() local
3587 lockdep_assert_held(&wq->mutex); in link_pwq()
3594 pwq->work_color = wq->work_color; in link_pwq()
3600 list_add_rcu(&pwq->pwqs_node, &wq->pwqs); in link_pwq()
3604 static struct pool_workqueue *alloc_unbound_pwq(struct workqueue_struct *wq, in alloc_unbound_pwq() argument
3622 init_pwq(pwq, wq, pool); in alloc_unbound_pwq()
3679 static struct pool_workqueue *numa_pwq_tbl_install(struct workqueue_struct *wq, in numa_pwq_tbl_install() argument
3686 lockdep_assert_held(&wq->mutex); in numa_pwq_tbl_install()
3691 old_pwq = rcu_access_pointer(wq->numa_pwq_tbl[node]); in numa_pwq_tbl_install()
3692 rcu_assign_pointer(wq->numa_pwq_tbl[node], pwq); in numa_pwq_tbl_install()
3698 struct workqueue_struct *wq; /* target workqueue */ member
3723 apply_wqattrs_prepare(struct workqueue_struct *wq, in apply_wqattrs_prepare() argument
3761 ctx->dfl_pwq = alloc_unbound_pwq(wq, new_attrs); in apply_wqattrs_prepare()
3767 ctx->pwq_tbl[node] = alloc_unbound_pwq(wq, tmp_attrs); in apply_wqattrs_prepare()
3781 ctx->wq = wq; in apply_wqattrs_prepare()
3798 mutex_lock(&ctx->wq->mutex); in apply_wqattrs_commit()
3800 copy_workqueue_attrs(ctx->wq->unbound_attrs, ctx->attrs); in apply_wqattrs_commit()
3804 ctx->pwq_tbl[node] = numa_pwq_tbl_install(ctx->wq, node, in apply_wqattrs_commit()
3809 swap(ctx->wq->dfl_pwq, ctx->dfl_pwq); in apply_wqattrs_commit()
3811 mutex_unlock(&ctx->wq->mutex); in apply_wqattrs_commit()
3827 static int apply_workqueue_attrs_locked(struct workqueue_struct *wq, in apply_workqueue_attrs_locked() argument
3833 if (WARN_ON(!(wq->flags & WQ_UNBOUND))) in apply_workqueue_attrs_locked()
3837 if (!list_empty(&wq->pwqs)) { in apply_workqueue_attrs_locked()
3838 if (WARN_ON(wq->flags & __WQ_ORDERED_EXPLICIT)) in apply_workqueue_attrs_locked()
3841 wq->flags &= ~__WQ_ORDERED; in apply_workqueue_attrs_locked()
3844 ctx = apply_wqattrs_prepare(wq, attrs); in apply_workqueue_attrs_locked()
3871 int apply_workqueue_attrs(struct workqueue_struct *wq, in apply_workqueue_attrs() argument
3877 ret = apply_workqueue_attrs_locked(wq, attrs); in apply_workqueue_attrs()
3906 static void wq_update_unbound_numa(struct workqueue_struct *wq, int cpu, in wq_update_unbound_numa() argument
3917 if (!wq_numa_enabled || !(wq->flags & WQ_UNBOUND) || in wq_update_unbound_numa()
3918 wq->unbound_attrs->no_numa) in wq_update_unbound_numa()
3929 copy_workqueue_attrs(target_attrs, wq->unbound_attrs); in wq_update_unbound_numa()
3930 pwq = unbound_pwq_by_node(wq, node); in wq_update_unbound_numa()
3938 if (wq_calc_node_cpumask(wq->dfl_pwq->pool->attrs, node, cpu_off, cpumask)) { in wq_update_unbound_numa()
3946 pwq = alloc_unbound_pwq(wq, target_attrs); in wq_update_unbound_numa()
3949 wq->name); in wq_update_unbound_numa()
3954 mutex_lock(&wq->mutex); in wq_update_unbound_numa()
3955 old_pwq = numa_pwq_tbl_install(wq, node, pwq); in wq_update_unbound_numa()
3959 mutex_lock(&wq->mutex); in wq_update_unbound_numa()
3960 spin_lock_irq(&wq->dfl_pwq->pool->lock); in wq_update_unbound_numa()
3961 get_pwq(wq->dfl_pwq); in wq_update_unbound_numa()
3962 spin_unlock_irq(&wq->dfl_pwq->pool->lock); in wq_update_unbound_numa()
3963 old_pwq = numa_pwq_tbl_install(wq, node, wq->dfl_pwq); in wq_update_unbound_numa()
3965 mutex_unlock(&wq->mutex); in wq_update_unbound_numa()
3969 static int alloc_and_link_pwqs(struct workqueue_struct *wq) in alloc_and_link_pwqs() argument
3971 bool highpri = wq->flags & WQ_HIGHPRI; in alloc_and_link_pwqs()
3974 if (!(wq->flags & WQ_UNBOUND)) { in alloc_and_link_pwqs()
3975 wq->cpu_pwqs = alloc_percpu(struct pool_workqueue); in alloc_and_link_pwqs()
3976 if (!wq->cpu_pwqs) in alloc_and_link_pwqs()
3981 per_cpu_ptr(wq->cpu_pwqs, cpu); in alloc_and_link_pwqs()
3985 init_pwq(pwq, wq, &cpu_pools[highpri]); in alloc_and_link_pwqs()
3987 mutex_lock(&wq->mutex); in alloc_and_link_pwqs()
3989 mutex_unlock(&wq->mutex); in alloc_and_link_pwqs()
3992 } else if (wq->flags & __WQ_ORDERED) { in alloc_and_link_pwqs()
3993 ret = apply_workqueue_attrs(wq, ordered_wq_attrs[highpri]); in alloc_and_link_pwqs()
3995 WARN(!ret && (wq->pwqs.next != &wq->dfl_pwq->pwqs_node || in alloc_and_link_pwqs()
3996 wq->pwqs.prev != &wq->dfl_pwq->pwqs_node), in alloc_and_link_pwqs()
3997 "ordering guarantee broken for workqueue %s\n", wq->name); in alloc_and_link_pwqs()
4000 return apply_workqueue_attrs(wq, unbound_std_wq_attrs[highpri]); in alloc_and_link_pwqs()
4020 static int init_rescuer(struct workqueue_struct *wq) in init_rescuer() argument
4025 if (!(wq->flags & WQ_MEM_RECLAIM)) in init_rescuer()
4032 rescuer->rescue_wq = wq; in init_rescuer()
4033 rescuer->task = kthread_create(rescuer_thread, rescuer, "%s", wq->name); in init_rescuer()
4040 wq->rescuer = rescuer; in init_rescuer()
4055 struct workqueue_struct *wq; in __alloc_workqueue_key() local
4074 tbl_size = nr_node_ids * sizeof(wq->numa_pwq_tbl[0]); in __alloc_workqueue_key()
4076 wq = kzalloc(sizeof(*wq) + tbl_size, GFP_KERNEL); in __alloc_workqueue_key()
4077 if (!wq) in __alloc_workqueue_key()
4081 wq->unbound_attrs = alloc_workqueue_attrs(GFP_KERNEL); in __alloc_workqueue_key()
4082 if (!wq->unbound_attrs) in __alloc_workqueue_key()
4087 vsnprintf(wq->name, sizeof(wq->name), fmt, args); in __alloc_workqueue_key()
4091 max_active = wq_clamp_max_active(max_active, flags, wq->name); in __alloc_workqueue_key()
4094 wq->flags = flags; in __alloc_workqueue_key()
4095 wq->saved_max_active = max_active; in __alloc_workqueue_key()
4096 mutex_init(&wq->mutex); in __alloc_workqueue_key()
4097 atomic_set(&wq->nr_pwqs_to_flush, 0); in __alloc_workqueue_key()
4098 INIT_LIST_HEAD(&wq->pwqs); in __alloc_workqueue_key()
4099 INIT_LIST_HEAD(&wq->flusher_queue); in __alloc_workqueue_key()
4100 INIT_LIST_HEAD(&wq->flusher_overflow); in __alloc_workqueue_key()
4101 INIT_LIST_HEAD(&wq->maydays); in __alloc_workqueue_key()
4103 lockdep_init_map(&wq->lockdep_map, lock_name, key, 0); in __alloc_workqueue_key()
4104 INIT_LIST_HEAD(&wq->list); in __alloc_workqueue_key()
4106 if (alloc_and_link_pwqs(wq) < 0) in __alloc_workqueue_key()
4109 if (wq_online && init_rescuer(wq) < 0) in __alloc_workqueue_key()
4112 if ((wq->flags & WQ_SYSFS) && workqueue_sysfs_register(wq)) in __alloc_workqueue_key()
4122 mutex_lock(&wq->mutex); in __alloc_workqueue_key()
4123 for_each_pwq(pwq, wq) in __alloc_workqueue_key()
4125 mutex_unlock(&wq->mutex); in __alloc_workqueue_key()
4127 list_add_tail_rcu(&wq->list, &workqueues); in __alloc_workqueue_key()
4131 return wq; in __alloc_workqueue_key()
4134 free_workqueue_attrs(wq->unbound_attrs); in __alloc_workqueue_key()
4135 kfree(wq); in __alloc_workqueue_key()
4138 destroy_workqueue(wq); in __alloc_workqueue_key()
4149 void destroy_workqueue(struct workqueue_struct *wq) in destroy_workqueue() argument
4155 drain_workqueue(wq); in destroy_workqueue()
4158 mutex_lock(&wq->mutex); in destroy_workqueue()
4159 for_each_pwq(pwq, wq) { in destroy_workqueue()
4164 mutex_unlock(&wq->mutex); in destroy_workqueue()
4170 if (WARN_ON((pwq != wq->dfl_pwq) && (pwq->refcnt > 1)) || in destroy_workqueue()
4173 mutex_unlock(&wq->mutex); in destroy_workqueue()
4178 mutex_unlock(&wq->mutex); in destroy_workqueue()
4185 list_del_rcu(&wq->list); in destroy_workqueue()
4188 workqueue_sysfs_unregister(wq); in destroy_workqueue()
4190 if (wq->rescuer) in destroy_workqueue()
4191 kthread_stop(wq->rescuer->task); in destroy_workqueue()
4193 if (!(wq->flags & WQ_UNBOUND)) { in destroy_workqueue()
4198 call_rcu_sched(&wq->rcu, rcu_free_wq); in destroy_workqueue()
4206 pwq = rcu_access_pointer(wq->numa_pwq_tbl[node]); in destroy_workqueue()
4207 RCU_INIT_POINTER(wq->numa_pwq_tbl[node], NULL); in destroy_workqueue()
4215 pwq = wq->dfl_pwq; in destroy_workqueue()
4216 wq->dfl_pwq = NULL; in destroy_workqueue()
4232 void workqueue_set_max_active(struct workqueue_struct *wq, int max_active) in workqueue_set_max_active() argument
4237 if (WARN_ON(wq->flags & __WQ_ORDERED_EXPLICIT)) in workqueue_set_max_active()
4240 max_active = wq_clamp_max_active(max_active, wq->flags, wq->name); in workqueue_set_max_active()
4242 mutex_lock(&wq->mutex); in workqueue_set_max_active()
4244 wq->flags &= ~__WQ_ORDERED; in workqueue_set_max_active()
4245 wq->saved_max_active = max_active; in workqueue_set_max_active()
4247 for_each_pwq(pwq, wq) in workqueue_set_max_active()
4250 mutex_unlock(&wq->mutex); in workqueue_set_max_active()
4303 bool workqueue_congested(int cpu, struct workqueue_struct *wq) in workqueue_congested() argument
4313 if (!(wq->flags & WQ_UNBOUND)) in workqueue_congested()
4314 pwq = per_cpu_ptr(wq->cpu_pwqs, cpu); in workqueue_congested()
4316 pwq = unbound_pwq_by_node(wq, cpu_to_node(cpu)); in workqueue_congested()
4401 struct workqueue_struct *wq = NULL; in print_worker_info() local
4419 probe_kernel_read(&wq, &pwq->wq, sizeof(wq)); in print_worker_info()
4420 probe_kernel_read(name, wq->name, sizeof(name) - 1); in print_worker_info()
4483 worker == pwq->wq->rescuer ? "(RESCUER)" : "", in show_pwq()
4532 struct workqueue_struct *wq; in show_workqueue_state() local
4541 list_for_each_entry_rcu(wq, &workqueues, list) { in show_workqueue_state()
4545 for_each_pwq(pwq, wq) { in show_workqueue_state()
4554 pr_info("workqueue %s: flags=0x%x\n", wq->name, wq->flags); in show_workqueue_state()
4556 for_each_pwq(pwq, wq) { in show_workqueue_state()
4823 struct workqueue_struct *wq; in workqueue_online_cpu() local
4840 list_for_each_entry(wq, &workqueues, list) in workqueue_online_cpu()
4841 wq_update_unbound_numa(wq, cpu, true); in workqueue_online_cpu()
4849 struct workqueue_struct *wq; in workqueue_offline_cpu() local
4859 list_for_each_entry(wq, &workqueues, list) in workqueue_offline_cpu()
4860 wq_update_unbound_numa(wq, cpu, false); in workqueue_offline_cpu()
4941 struct workqueue_struct *wq; in freeze_workqueues_begin() local
4949 list_for_each_entry(wq, &workqueues, list) { in freeze_workqueues_begin()
4950 mutex_lock(&wq->mutex); in freeze_workqueues_begin()
4951 for_each_pwq(pwq, wq) in freeze_workqueues_begin()
4953 mutex_unlock(&wq->mutex); in freeze_workqueues_begin()
4975 struct workqueue_struct *wq; in freeze_workqueues_busy() local
4982 list_for_each_entry(wq, &workqueues, list) { in freeze_workqueues_busy()
4983 if (!(wq->flags & WQ_FREEZABLE)) in freeze_workqueues_busy()
4990 for_each_pwq(pwq, wq) { in freeze_workqueues_busy()
5016 struct workqueue_struct *wq; in thaw_workqueues() local
5027 list_for_each_entry(wq, &workqueues, list) { in thaw_workqueues()
5028 mutex_lock(&wq->mutex); in thaw_workqueues()
5029 for_each_pwq(pwq, wq) in thaw_workqueues()
5031 mutex_unlock(&wq->mutex); in thaw_workqueues()
5043 struct workqueue_struct *wq; in workqueue_apply_unbound_cpumask() local
5048 list_for_each_entry(wq, &workqueues, list) { in workqueue_apply_unbound_cpumask()
5049 if (!(wq->flags & WQ_UNBOUND)) in workqueue_apply_unbound_cpumask()
5052 if (wq->flags & __WQ_ORDERED) in workqueue_apply_unbound_cpumask()
5055 ctx = apply_wqattrs_prepare(wq, wq->unbound_attrs); in workqueue_apply_unbound_cpumask()
5136 struct workqueue_struct *wq; member
5144 return wq_dev->wq; in dev_to_wq()
5150 struct workqueue_struct *wq = dev_to_wq(dev); in per_cpu_show() local
5152 return scnprintf(buf, PAGE_SIZE, "%d\n", (bool)!(wq->flags & WQ_UNBOUND)); in per_cpu_show()
5159 struct workqueue_struct *wq = dev_to_wq(dev); in max_active_show() local
5161 return scnprintf(buf, PAGE_SIZE, "%d\n", wq->saved_max_active); in max_active_show()
5168 struct workqueue_struct *wq = dev_to_wq(dev); in max_active_store() local
5174 workqueue_set_max_active(wq, val); in max_active_store()
5189 struct workqueue_struct *wq = dev_to_wq(dev); in wq_pool_ids_show() local
5197 unbound_pwq_by_node(wq, node)->pool->id); in wq_pool_ids_show()
5209 struct workqueue_struct *wq = dev_to_wq(dev); in wq_nice_show() local
5212 mutex_lock(&wq->mutex); in wq_nice_show()
5213 written = scnprintf(buf, PAGE_SIZE, "%d\n", wq->unbound_attrs->nice); in wq_nice_show()
5214 mutex_unlock(&wq->mutex); in wq_nice_show()
5220 static struct workqueue_attrs *wq_sysfs_prep_attrs(struct workqueue_struct *wq) in wq_sysfs_prep_attrs() argument
5230 copy_workqueue_attrs(attrs, wq->unbound_attrs); in wq_sysfs_prep_attrs()
5237 struct workqueue_struct *wq = dev_to_wq(dev); in wq_nice_store() local
5243 attrs = wq_sysfs_prep_attrs(wq); in wq_nice_store()
5249 ret = apply_workqueue_attrs_locked(wq, attrs); in wq_nice_store()
5262 struct workqueue_struct *wq = dev_to_wq(dev); in wq_cpumask_show() local
5265 mutex_lock(&wq->mutex); in wq_cpumask_show()
5267 cpumask_pr_args(wq->unbound_attrs->cpumask)); in wq_cpumask_show()
5268 mutex_unlock(&wq->mutex); in wq_cpumask_show()
5276 struct workqueue_struct *wq = dev_to_wq(dev); in wq_cpumask_store() local
5282 attrs = wq_sysfs_prep_attrs(wq); in wq_cpumask_store()
5288 ret = apply_workqueue_attrs_locked(wq, attrs); in wq_cpumask_store()
5299 struct workqueue_struct *wq = dev_to_wq(dev); in wq_numa_show() local
5302 mutex_lock(&wq->mutex); in wq_numa_show()
5304 !wq->unbound_attrs->no_numa); in wq_numa_show()
5305 mutex_unlock(&wq->mutex); in wq_numa_show()
5313 struct workqueue_struct *wq = dev_to_wq(dev); in wq_numa_store() local
5319 attrs = wq_sysfs_prep_attrs(wq); in wq_numa_store()
5326 ret = apply_workqueue_attrs_locked(wq, attrs); in wq_numa_store()
5416 int workqueue_sysfs_register(struct workqueue_struct *wq) in workqueue_sysfs_register() argument
5426 if (WARN_ON(wq->flags & __WQ_ORDERED_EXPLICIT)) in workqueue_sysfs_register()
5429 wq->wq_dev = wq_dev = kzalloc(sizeof(*wq_dev), GFP_KERNEL); in workqueue_sysfs_register()
5433 wq_dev->wq = wq; in workqueue_sysfs_register()
5436 dev_set_name(&wq_dev->dev, "%s", wq->name); in workqueue_sysfs_register()
5447 wq->wq_dev = NULL; in workqueue_sysfs_register()
5451 if (wq->flags & WQ_UNBOUND) { in workqueue_sysfs_register()
5458 wq->wq_dev = NULL; in workqueue_sysfs_register()
5475 static void workqueue_sysfs_unregister(struct workqueue_struct *wq) in workqueue_sysfs_unregister() argument
5477 struct wq_device *wq_dev = wq->wq_dev; in workqueue_sysfs_unregister()
5479 if (!wq->wq_dev) in workqueue_sysfs_unregister()
5482 wq->wq_dev = NULL; in workqueue_sysfs_unregister()
5486 static void workqueue_sysfs_unregister(struct workqueue_struct *wq) { } in workqueue_sysfs_unregister() argument
5769 struct workqueue_struct *wq; in workqueue_init() local
5792 list_for_each_entry(wq, &workqueues, list) { in workqueue_init()
5793 wq_update_unbound_numa(wq, smp_processor_id(), true); in workqueue_init()
5794 WARN(init_rescuer(wq), in workqueue_init()
5796 wq->name); in workqueue_init()