Lines Matching refs:wq

203 	struct workqueue_struct *wq;		/* I: the owning workqueue */  member
377 static void workqueue_sysfs_unregister(struct workqueue_struct *wq);
389 #define assert_rcu_or_wq_mutex_or_pool_mutex(wq) \ argument
391 !lockdep_is_held(&wq->mutex) && \
444 #define for_each_pwq(pwq, wq) \ argument
445 list_for_each_entry_rcu((pwq), &(wq)->pwqs, pwqs_node, \
446 lockdep_is_held(&(wq->mutex)))
579 static struct pool_workqueue *unbound_pwq_by_node(struct workqueue_struct *wq, in unbound_pwq_by_node() argument
582 assert_rcu_or_wq_mutex_or_pool_mutex(wq); in unbound_pwq_by_node()
591 return wq->dfl_pwq; in unbound_pwq_by_node()
593 return rcu_dereference_raw(wq->numa_pwq_tbl[node]); in unbound_pwq_by_node()
1129 if (WARN_ON_ONCE(!(pwq->wq->flags & WQ_UNBOUND))) in put_pwq()
1222 if (atomic_dec_and_test(&pwq->wq->nr_pwqs_to_flush)) in pwq_dec_nr_in_flight()
1223 complete(&pwq->wq->first_flusher->done); in pwq_dec_nr_in_flight()
1373 static bool is_chained_work(struct workqueue_struct *wq) in is_chained_work() argument
1382 return worker && worker->current_pwq->wq == wq; in is_chained_work()
1418 static void __queue_work(int cpu, struct workqueue_struct *wq, in __queue_work() argument
1437 if (unlikely(wq->flags & __WQ_DRAINING) && in __queue_work()
1438 WARN_ON_ONCE(!is_chained_work(wq))) in __queue_work()
1443 if (wq->flags & WQ_UNBOUND) { in __queue_work()
1446 pwq = unbound_pwq_by_node(wq, cpu_to_node(cpu)); in __queue_work()
1450 pwq = per_cpu_ptr(wq->cpu_pwqs, cpu); in __queue_work()
1466 if (worker && worker->current_pwq->wq == wq) { in __queue_work()
1486 if (wq->flags & WQ_UNBOUND) { in __queue_work()
1493 wq->name, cpu); in __queue_work()
1536 bool queue_work_on(int cpu, struct workqueue_struct *wq, in queue_work_on() argument
1545 __queue_work(cpu, wq, work); in queue_work_on()
1607 bool queue_work_node(int node, struct workqueue_struct *wq, in queue_work_node() argument
1622 WARN_ON_ONCE(!(wq->flags & WQ_UNBOUND)); in queue_work_node()
1629 __queue_work(cpu, wq, work); in queue_work_node()
1643 __queue_work(dwork->cpu, dwork->wq, &dwork->work); in delayed_work_timer_fn()
1647 static void __queue_delayed_work(int cpu, struct workqueue_struct *wq, in __queue_delayed_work() argument
1653 WARN_ON_ONCE(!wq); in __queue_delayed_work()
1665 __queue_work(cpu, wq, &dwork->work); in __queue_delayed_work()
1669 dwork->wq = wq; in __queue_delayed_work()
1690 bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq, in queue_delayed_work_on() argument
1701 __queue_delayed_work(cpu, wq, dwork, delay); in queue_delayed_work_on()
1728 bool mod_delayed_work_on(int cpu, struct workqueue_struct *wq, in mod_delayed_work_on() argument
1739 __queue_delayed_work(cpu, wq, dwork, delay); in mod_delayed_work_on()
1754 __queue_work(WORK_CPU_UNBOUND, rwork->wq, &rwork->work); in rcu_work_rcufn()
1768 bool queue_rcu_work(struct workqueue_struct *wq, struct rcu_work *rwork) in queue_rcu_work() argument
1773 rwork->wq = wq; in queue_rcu_work()
2033 struct workqueue_struct *wq = pwq->wq; in send_mayday() local
2037 if (!wq->rescuer) in send_mayday()
2048 list_add_tail(&pwq->mayday_node, &wq->maydays); in send_mayday()
2049 wake_up_process(wq->rescuer->task); in send_mayday()
2187 bool cpu_intensive = pwq->wq->flags & WQ_CPU_INTENSIVE; in process_one_work()
2231 strscpy(worker->desc, pwq->wq->name, WORKER_DESC_LEN); in process_one_work()
2264 lock_map_acquire(&pwq->wq->lockdep_map); in process_one_work()
2296 lock_map_release(&pwq->wq->lockdep_map); in process_one_work()
2485 struct workqueue_struct *wq = rescuer->rescue_wq; in rescuer_thread() local
2512 while (!list_empty(&wq->maydays)) { in rescuer_thread()
2513 struct pool_workqueue *pwq = list_first_entry(&wq->maydays, in rescuer_thread()
2560 if (wq->rescuer && list_empty(&pwq->mayday_node)) { in rescuer_thread()
2562 list_add_tail(&pwq->mayday_node, &wq->maydays); in rescuer_thread()
2628 WARN_ONCE(worker && ((worker->current_pwq->wq->flags & in check_flush_dependency()
2631 worker->current_pwq->wq->name, worker->current_func, in check_flush_dependency()
2750 static bool flush_workqueue_prep_pwqs(struct workqueue_struct *wq, in flush_workqueue_prep_pwqs() argument
2757 WARN_ON_ONCE(atomic_read(&wq->nr_pwqs_to_flush)); in flush_workqueue_prep_pwqs()
2758 atomic_set(&wq->nr_pwqs_to_flush, 1); in flush_workqueue_prep_pwqs()
2761 for_each_pwq(pwq, wq) { in flush_workqueue_prep_pwqs()
2771 atomic_inc(&wq->nr_pwqs_to_flush); in flush_workqueue_prep_pwqs()
2784 if (flush_color >= 0 && atomic_dec_and_test(&wq->nr_pwqs_to_flush)) in flush_workqueue_prep_pwqs()
2785 complete(&wq->first_flusher->done); in flush_workqueue_prep_pwqs()
2797 void __flush_workqueue(struct workqueue_struct *wq) in __flush_workqueue() argument
2802 .done = COMPLETION_INITIALIZER_ONSTACK_MAP(this_flusher.done, wq->lockdep_map), in __flush_workqueue()
2809 lock_map_acquire(&wq->lockdep_map); in __flush_workqueue()
2810 lock_map_release(&wq->lockdep_map); in __flush_workqueue()
2812 mutex_lock(&wq->mutex); in __flush_workqueue()
2817 next_color = work_next_color(wq->work_color); in __flush_workqueue()
2819 if (next_color != wq->flush_color) { in __flush_workqueue()
2825 WARN_ON_ONCE(!list_empty(&wq->flusher_overflow)); in __flush_workqueue()
2826 this_flusher.flush_color = wq->work_color; in __flush_workqueue()
2827 wq->work_color = next_color; in __flush_workqueue()
2829 if (!wq->first_flusher) { in __flush_workqueue()
2831 WARN_ON_ONCE(wq->flush_color != this_flusher.flush_color); in __flush_workqueue()
2833 wq->first_flusher = &this_flusher; in __flush_workqueue()
2835 if (!flush_workqueue_prep_pwqs(wq, wq->flush_color, in __flush_workqueue()
2836 wq->work_color)) { in __flush_workqueue()
2838 wq->flush_color = next_color; in __flush_workqueue()
2839 wq->first_flusher = NULL; in __flush_workqueue()
2844 WARN_ON_ONCE(wq->flush_color == this_flusher.flush_color); in __flush_workqueue()
2845 list_add_tail(&this_flusher.list, &wq->flusher_queue); in __flush_workqueue()
2846 flush_workqueue_prep_pwqs(wq, -1, wq->work_color); in __flush_workqueue()
2854 list_add_tail(&this_flusher.list, &wq->flusher_overflow); in __flush_workqueue()
2857 check_flush_dependency(wq, NULL); in __flush_workqueue()
2859 mutex_unlock(&wq->mutex); in __flush_workqueue()
2869 if (READ_ONCE(wq->first_flusher) != &this_flusher) in __flush_workqueue()
2872 mutex_lock(&wq->mutex); in __flush_workqueue()
2875 if (wq->first_flusher != &this_flusher) in __flush_workqueue()
2878 WRITE_ONCE(wq->first_flusher, NULL); in __flush_workqueue()
2881 WARN_ON_ONCE(wq->flush_color != this_flusher.flush_color); in __flush_workqueue()
2887 list_for_each_entry_safe(next, tmp, &wq->flusher_queue, list) { in __flush_workqueue()
2888 if (next->flush_color != wq->flush_color) in __flush_workqueue()
2894 WARN_ON_ONCE(!list_empty(&wq->flusher_overflow) && in __flush_workqueue()
2895 wq->flush_color != work_next_color(wq->work_color)); in __flush_workqueue()
2898 wq->flush_color = work_next_color(wq->flush_color); in __flush_workqueue()
2901 if (!list_empty(&wq->flusher_overflow)) { in __flush_workqueue()
2908 list_for_each_entry(tmp, &wq->flusher_overflow, list) in __flush_workqueue()
2909 tmp->flush_color = wq->work_color; in __flush_workqueue()
2911 wq->work_color = work_next_color(wq->work_color); in __flush_workqueue()
2913 list_splice_tail_init(&wq->flusher_overflow, in __flush_workqueue()
2914 &wq->flusher_queue); in __flush_workqueue()
2915 flush_workqueue_prep_pwqs(wq, -1, wq->work_color); in __flush_workqueue()
2918 if (list_empty(&wq->flusher_queue)) { in __flush_workqueue()
2919 WARN_ON_ONCE(wq->flush_color != wq->work_color); in __flush_workqueue()
2927 WARN_ON_ONCE(wq->flush_color == wq->work_color); in __flush_workqueue()
2928 WARN_ON_ONCE(wq->flush_color != next->flush_color); in __flush_workqueue()
2931 wq->first_flusher = next; in __flush_workqueue()
2933 if (flush_workqueue_prep_pwqs(wq, wq->flush_color, -1)) in __flush_workqueue()
2940 wq->first_flusher = NULL; in __flush_workqueue()
2944 mutex_unlock(&wq->mutex); in __flush_workqueue()
2959 void drain_workqueue(struct workqueue_struct *wq) in drain_workqueue() argument
2969 mutex_lock(&wq->mutex); in drain_workqueue()
2970 if (!wq->nr_drainers++) in drain_workqueue()
2971 wq->flags |= __WQ_DRAINING; in drain_workqueue()
2972 mutex_unlock(&wq->mutex); in drain_workqueue()
2974 __flush_workqueue(wq); in drain_workqueue()
2976 mutex_lock(&wq->mutex); in drain_workqueue()
2978 for_each_pwq(pwq, wq) { in drain_workqueue()
2991 wq->name, __func__, flush_cnt); in drain_workqueue()
2993 mutex_unlock(&wq->mutex); in drain_workqueue()
2997 if (!--wq->nr_drainers) in drain_workqueue()
2998 wq->flags &= ~__WQ_DRAINING; in drain_workqueue()
2999 mutex_unlock(&wq->mutex); in drain_workqueue()
3032 check_flush_dependency(pwq->wq, work); in start_flush_work()
3047 (pwq->wq->saved_max_active == 1 || pwq->wq->rescuer)) { in start_flush_work()
3048 lock_map_acquire(&pwq->wq->lockdep_map); in start_flush_work()
3049 lock_map_release(&pwq->wq->lockdep_map); in start_flush_work()
3216 __queue_work(dwork->cpu, dwork->wq, &dwork->work); in flush_delayed_work()
3482 static void wq_init_lockdep(struct workqueue_struct *wq) in wq_init_lockdep() argument
3486 lockdep_register_key(&wq->key); in wq_init_lockdep()
3487 lock_name = kasprintf(GFP_KERNEL, "%s%s", "(wq_completion)", wq->name); in wq_init_lockdep()
3489 lock_name = wq->name; in wq_init_lockdep()
3491 wq->lock_name = lock_name; in wq_init_lockdep()
3492 lockdep_init_map(&wq->lockdep_map, lock_name, &wq->key, 0); in wq_init_lockdep()
3495 static void wq_unregister_lockdep(struct workqueue_struct *wq) in wq_unregister_lockdep() argument
3497 lockdep_unregister_key(&wq->key); in wq_unregister_lockdep()
3500 static void wq_free_lockdep(struct workqueue_struct *wq) in wq_free_lockdep() argument
3502 if (wq->lock_name != wq->name) in wq_free_lockdep()
3503 kfree(wq->lock_name); in wq_free_lockdep()
3506 static void wq_init_lockdep(struct workqueue_struct *wq) in wq_init_lockdep() argument
3510 static void wq_unregister_lockdep(struct workqueue_struct *wq) in wq_unregister_lockdep() argument
3514 static void wq_free_lockdep(struct workqueue_struct *wq) in wq_free_lockdep() argument
3521 struct workqueue_struct *wq = in rcu_free_wq() local
3524 wq_free_lockdep(wq); in rcu_free_wq()
3526 if (!(wq->flags & WQ_UNBOUND)) in rcu_free_wq()
3527 free_percpu(wq->cpu_pwqs); in rcu_free_wq()
3529 free_workqueue_attrs(wq->unbound_attrs); in rcu_free_wq()
3531 kfree(wq); in rcu_free_wq()
3706 struct workqueue_struct *wq = pwq->wq; in pwq_unbound_release_workfn() local
3715 if (WARN_ON_ONCE(!(wq->flags & WQ_UNBOUND))) in pwq_unbound_release_workfn()
3718 mutex_lock(&wq->mutex); in pwq_unbound_release_workfn()
3720 is_last = list_empty(&wq->pwqs); in pwq_unbound_release_workfn()
3721 mutex_unlock(&wq->mutex); in pwq_unbound_release_workfn()
3735 wq_unregister_lockdep(wq); in pwq_unbound_release_workfn()
3736 call_rcu(&wq->rcu, rcu_free_wq); in pwq_unbound_release_workfn()
3750 struct workqueue_struct *wq = pwq->wq; in pwq_adjust_max_active() local
3751 bool freezable = wq->flags & WQ_FREEZABLE; in pwq_adjust_max_active()
3755 lockdep_assert_held(&wq->mutex); in pwq_adjust_max_active()
3758 if (!freezable && pwq->max_active == wq->saved_max_active) in pwq_adjust_max_active()
3772 pwq->max_active = wq->saved_max_active; in pwq_adjust_max_active()
3796 static void init_pwq(struct pool_workqueue *pwq, struct workqueue_struct *wq, in init_pwq() argument
3804 pwq->wq = wq; in init_pwq()
3816 struct workqueue_struct *wq = pwq->wq; in link_pwq() local
3818 lockdep_assert_held(&wq->mutex); in link_pwq()
3825 pwq->work_color = wq->work_color; in link_pwq()
3831 list_add_rcu(&pwq->pwqs_node, &wq->pwqs); in link_pwq()
3835 static struct pool_workqueue *alloc_unbound_pwq(struct workqueue_struct *wq, in alloc_unbound_pwq() argument
3853 init_pwq(pwq, wq, pool); in alloc_unbound_pwq()
3910 static struct pool_workqueue *numa_pwq_tbl_install(struct workqueue_struct *wq, in numa_pwq_tbl_install() argument
3917 lockdep_assert_held(&wq->mutex); in numa_pwq_tbl_install()
3922 old_pwq = rcu_access_pointer(wq->numa_pwq_tbl[node]); in numa_pwq_tbl_install()
3923 rcu_assign_pointer(wq->numa_pwq_tbl[node], pwq); in numa_pwq_tbl_install()
3929 struct workqueue_struct *wq; /* target workqueue */ member
3954 apply_wqattrs_prepare(struct workqueue_struct *wq, in apply_wqattrs_prepare() argument
3992 ctx->dfl_pwq = alloc_unbound_pwq(wq, new_attrs); in apply_wqattrs_prepare()
3998 ctx->pwq_tbl[node] = alloc_unbound_pwq(wq, tmp_attrs); in apply_wqattrs_prepare()
4012 ctx->wq = wq; in apply_wqattrs_prepare()
4029 mutex_lock(&ctx->wq->mutex); in apply_wqattrs_commit()
4031 copy_workqueue_attrs(ctx->wq->unbound_attrs, ctx->attrs); in apply_wqattrs_commit()
4035 ctx->pwq_tbl[node] = numa_pwq_tbl_install(ctx->wq, node, in apply_wqattrs_commit()
4040 swap(ctx->wq->dfl_pwq, ctx->dfl_pwq); in apply_wqattrs_commit()
4042 mutex_unlock(&ctx->wq->mutex); in apply_wqattrs_commit()
4058 static int apply_workqueue_attrs_locked(struct workqueue_struct *wq, in apply_workqueue_attrs_locked() argument
4064 if (WARN_ON(!(wq->flags & WQ_UNBOUND))) in apply_workqueue_attrs_locked()
4068 if (!list_empty(&wq->pwqs)) { in apply_workqueue_attrs_locked()
4069 if (WARN_ON(wq->flags & __WQ_ORDERED_EXPLICIT)) in apply_workqueue_attrs_locked()
4072 wq->flags &= ~__WQ_ORDERED; in apply_workqueue_attrs_locked()
4075 ctx = apply_wqattrs_prepare(wq, attrs); in apply_workqueue_attrs_locked()
4104 int apply_workqueue_attrs(struct workqueue_struct *wq, in apply_workqueue_attrs() argument
4112 ret = apply_workqueue_attrs_locked(wq, attrs); in apply_workqueue_attrs()
4140 static void wq_update_unbound_numa(struct workqueue_struct *wq, int cpu, in wq_update_unbound_numa() argument
4151 if (!wq_numa_enabled || !(wq->flags & WQ_UNBOUND) || in wq_update_unbound_numa()
4152 wq->unbound_attrs->no_numa) in wq_update_unbound_numa()
4163 copy_workqueue_attrs(target_attrs, wq->unbound_attrs); in wq_update_unbound_numa()
4164 pwq = unbound_pwq_by_node(wq, node); in wq_update_unbound_numa()
4172 if (wq_calc_node_cpumask(wq->dfl_pwq->pool->attrs, node, cpu_off, cpumask)) { in wq_update_unbound_numa()
4180 pwq = alloc_unbound_pwq(wq, target_attrs); in wq_update_unbound_numa()
4183 wq->name); in wq_update_unbound_numa()
4188 mutex_lock(&wq->mutex); in wq_update_unbound_numa()
4189 old_pwq = numa_pwq_tbl_install(wq, node, pwq); in wq_update_unbound_numa()
4193 mutex_lock(&wq->mutex); in wq_update_unbound_numa()
4194 raw_spin_lock_irq(&wq->dfl_pwq->pool->lock); in wq_update_unbound_numa()
4195 get_pwq(wq->dfl_pwq); in wq_update_unbound_numa()
4196 raw_spin_unlock_irq(&wq->dfl_pwq->pool->lock); in wq_update_unbound_numa()
4197 old_pwq = numa_pwq_tbl_install(wq, node, wq->dfl_pwq); in wq_update_unbound_numa()
4199 mutex_unlock(&wq->mutex); in wq_update_unbound_numa()
4203 static int alloc_and_link_pwqs(struct workqueue_struct *wq) in alloc_and_link_pwqs() argument
4205 bool highpri = wq->flags & WQ_HIGHPRI; in alloc_and_link_pwqs()
4208 if (!(wq->flags & WQ_UNBOUND)) { in alloc_and_link_pwqs()
4209 wq->cpu_pwqs = alloc_percpu(struct pool_workqueue); in alloc_and_link_pwqs()
4210 if (!wq->cpu_pwqs) in alloc_and_link_pwqs()
4215 per_cpu_ptr(wq->cpu_pwqs, cpu); in alloc_and_link_pwqs()
4219 init_pwq(pwq, wq, &cpu_pools[highpri]); in alloc_and_link_pwqs()
4221 mutex_lock(&wq->mutex); in alloc_and_link_pwqs()
4223 mutex_unlock(&wq->mutex); in alloc_and_link_pwqs()
4229 if (wq->flags & __WQ_ORDERED) { in alloc_and_link_pwqs()
4230 ret = apply_workqueue_attrs(wq, ordered_wq_attrs[highpri]); in alloc_and_link_pwqs()
4232 WARN(!ret && (wq->pwqs.next != &wq->dfl_pwq->pwqs_node || in alloc_and_link_pwqs()
4233 wq->pwqs.prev != &wq->dfl_pwq->pwqs_node), in alloc_and_link_pwqs()
4234 "ordering guarantee broken for workqueue %s\n", wq->name); in alloc_and_link_pwqs()
4236 ret = apply_workqueue_attrs(wq, unbound_std_wq_attrs[highpri]); in alloc_and_link_pwqs()
4259 static int init_rescuer(struct workqueue_struct *wq) in init_rescuer() argument
4264 if (!(wq->flags & WQ_MEM_RECLAIM)) in init_rescuer()
4271 rescuer->rescue_wq = wq; in init_rescuer()
4272 rescuer->task = kthread_create(rescuer_thread, rescuer, "%s", wq->name); in init_rescuer()
4279 wq->rescuer = rescuer; in init_rescuer()
4293 struct workqueue_struct *wq; in alloc_workqueue() local
4312 tbl_size = nr_node_ids * sizeof(wq->numa_pwq_tbl[0]); in alloc_workqueue()
4314 wq = kzalloc(sizeof(*wq) + tbl_size, GFP_KERNEL); in alloc_workqueue()
4315 if (!wq) in alloc_workqueue()
4319 wq->unbound_attrs = alloc_workqueue_attrs(); in alloc_workqueue()
4320 if (!wq->unbound_attrs) in alloc_workqueue()
4325 vsnprintf(wq->name, sizeof(wq->name), fmt, args); in alloc_workqueue()
4329 max_active = wq_clamp_max_active(max_active, flags, wq->name); in alloc_workqueue()
4332 wq->flags = flags; in alloc_workqueue()
4333 wq->saved_max_active = max_active; in alloc_workqueue()
4334 mutex_init(&wq->mutex); in alloc_workqueue()
4335 atomic_set(&wq->nr_pwqs_to_flush, 0); in alloc_workqueue()
4336 INIT_LIST_HEAD(&wq->pwqs); in alloc_workqueue()
4337 INIT_LIST_HEAD(&wq->flusher_queue); in alloc_workqueue()
4338 INIT_LIST_HEAD(&wq->flusher_overflow); in alloc_workqueue()
4339 INIT_LIST_HEAD(&wq->maydays); in alloc_workqueue()
4341 wq_init_lockdep(wq); in alloc_workqueue()
4342 INIT_LIST_HEAD(&wq->list); in alloc_workqueue()
4344 if (alloc_and_link_pwqs(wq) < 0) in alloc_workqueue()
4347 if (wq_online && init_rescuer(wq) < 0) in alloc_workqueue()
4350 if ((wq->flags & WQ_SYSFS) && workqueue_sysfs_register(wq)) in alloc_workqueue()
4360 mutex_lock(&wq->mutex); in alloc_workqueue()
4361 for_each_pwq(pwq, wq) in alloc_workqueue()
4363 mutex_unlock(&wq->mutex); in alloc_workqueue()
4365 list_add_tail_rcu(&wq->list, &workqueues); in alloc_workqueue()
4369 return wq; in alloc_workqueue()
4372 wq_unregister_lockdep(wq); in alloc_workqueue()
4373 wq_free_lockdep(wq); in alloc_workqueue()
4375 free_workqueue_attrs(wq->unbound_attrs); in alloc_workqueue()
4376 kfree(wq); in alloc_workqueue()
4379 destroy_workqueue(wq); in alloc_workqueue()
4392 if ((pwq != pwq->wq->dfl_pwq) && (pwq->refcnt > 1)) in pwq_busy()
4406 void destroy_workqueue(struct workqueue_struct *wq) in destroy_workqueue() argument
4415 workqueue_sysfs_unregister(wq); in destroy_workqueue()
4418 drain_workqueue(wq); in destroy_workqueue()
4421 if (wq->rescuer) { in destroy_workqueue()
4422 struct worker *rescuer = wq->rescuer; in destroy_workqueue()
4426 wq->rescuer = NULL; in destroy_workqueue()
4439 mutex_lock(&wq->mutex); in destroy_workqueue()
4440 for_each_pwq(pwq, wq) { in destroy_workqueue()
4444 __func__, wq->name); in destroy_workqueue()
4447 mutex_unlock(&wq->mutex); in destroy_workqueue()
4449 show_one_workqueue(wq); in destroy_workqueue()
4454 mutex_unlock(&wq->mutex); in destroy_workqueue()
4460 list_del_rcu(&wq->list); in destroy_workqueue()
4463 if (!(wq->flags & WQ_UNBOUND)) { in destroy_workqueue()
4464 wq_unregister_lockdep(wq); in destroy_workqueue()
4469 call_rcu(&wq->rcu, rcu_free_wq); in destroy_workqueue()
4477 pwq = rcu_access_pointer(wq->numa_pwq_tbl[node]); in destroy_workqueue()
4478 RCU_INIT_POINTER(wq->numa_pwq_tbl[node], NULL); in destroy_workqueue()
4486 pwq = wq->dfl_pwq; in destroy_workqueue()
4487 wq->dfl_pwq = NULL; in destroy_workqueue()
4503 void workqueue_set_max_active(struct workqueue_struct *wq, int max_active) in workqueue_set_max_active() argument
4508 if (WARN_ON(wq->flags & __WQ_ORDERED_EXPLICIT)) in workqueue_set_max_active()
4511 max_active = wq_clamp_max_active(max_active, wq->flags, wq->name); in workqueue_set_max_active()
4513 mutex_lock(&wq->mutex); in workqueue_set_max_active()
4515 wq->flags &= ~__WQ_ORDERED; in workqueue_set_max_active()
4516 wq->saved_max_active = max_active; in workqueue_set_max_active()
4518 for_each_pwq(pwq, wq) in workqueue_set_max_active()
4521 mutex_unlock(&wq->mutex); in workqueue_set_max_active()
4574 bool workqueue_congested(int cpu, struct workqueue_struct *wq) in workqueue_congested() argument
4585 if (!(wq->flags & WQ_UNBOUND)) in workqueue_congested()
4586 pwq = per_cpu_ptr(wq->cpu_pwqs, cpu); in workqueue_congested()
4588 pwq = unbound_pwq_by_node(wq, cpu_to_node(cpu)); in workqueue_congested()
4674 struct workqueue_struct *wq = NULL; in print_worker_info() local
4692 copy_from_kernel_nofault(&wq, &pwq->wq, sizeof(wq)); in print_worker_info()
4693 copy_from_kernel_nofault(name, wq->name, sizeof(name) - 1); in print_worker_info()
4802 void show_one_workqueue(struct workqueue_struct *wq) in show_one_workqueue() argument
4808 for_each_pwq(pwq, wq) { in show_one_workqueue()
4817 pr_info("workqueue %s: flags=0x%x\n", wq->name, wq->flags); in show_one_workqueue()
4819 for_each_pwq(pwq, wq) { in show_one_workqueue()
4895 struct workqueue_struct *wq; in show_all_workqueues() local
4903 list_for_each_entry_rcu(wq, &workqueues, list) in show_all_workqueues()
4904 show_one_workqueue(wq); in show_all_workqueues()
5121 struct workqueue_struct *wq; in workqueue_online_cpu() local
5138 list_for_each_entry(wq, &workqueues, list) in workqueue_online_cpu()
5139 wq_update_unbound_numa(wq, cpu, true); in workqueue_online_cpu()
5147 struct workqueue_struct *wq; in workqueue_offline_cpu() local
5157 list_for_each_entry(wq, &workqueues, list) in workqueue_offline_cpu()
5158 wq_update_unbound_numa(wq, cpu, false); in workqueue_offline_cpu()
5239 struct workqueue_struct *wq; in freeze_workqueues_begin() local
5247 list_for_each_entry(wq, &workqueues, list) { in freeze_workqueues_begin()
5248 mutex_lock(&wq->mutex); in freeze_workqueues_begin()
5249 for_each_pwq(pwq, wq) in freeze_workqueues_begin()
5251 mutex_unlock(&wq->mutex); in freeze_workqueues_begin()
5273 struct workqueue_struct *wq; in freeze_workqueues_busy() local
5280 list_for_each_entry(wq, &workqueues, list) { in freeze_workqueues_busy()
5281 if (!(wq->flags & WQ_FREEZABLE)) in freeze_workqueues_busy()
5288 for_each_pwq(pwq, wq) { in freeze_workqueues_busy()
5314 struct workqueue_struct *wq; in thaw_workqueues() local
5325 list_for_each_entry(wq, &workqueues, list) { in thaw_workqueues()
5326 mutex_lock(&wq->mutex); in thaw_workqueues()
5327 for_each_pwq(pwq, wq) in thaw_workqueues()
5329 mutex_unlock(&wq->mutex); in thaw_workqueues()
5341 struct workqueue_struct *wq; in workqueue_apply_unbound_cpumask() local
5346 list_for_each_entry(wq, &workqueues, list) { in workqueue_apply_unbound_cpumask()
5347 if (!(wq->flags & WQ_UNBOUND)) in workqueue_apply_unbound_cpumask()
5350 if (wq->flags & __WQ_ORDERED) in workqueue_apply_unbound_cpumask()
5353 ctx = apply_wqattrs_prepare(wq, wq->unbound_attrs); in workqueue_apply_unbound_cpumask()
5441 struct workqueue_struct *wq; member
5449 return wq_dev->wq; in dev_to_wq()
5455 struct workqueue_struct *wq = dev_to_wq(dev); in per_cpu_show() local
5457 return scnprintf(buf, PAGE_SIZE, "%d\n", (bool)!(wq->flags & WQ_UNBOUND)); in per_cpu_show()
5464 struct workqueue_struct *wq = dev_to_wq(dev); in max_active_show() local
5466 return scnprintf(buf, PAGE_SIZE, "%d\n", wq->saved_max_active); in max_active_show()
5473 struct workqueue_struct *wq = dev_to_wq(dev); in max_active_store() local
5479 workqueue_set_max_active(wq, val); in max_active_store()
5494 struct workqueue_struct *wq = dev_to_wq(dev); in wq_pool_ids_show() local
5503 unbound_pwq_by_node(wq, node)->pool->id); in wq_pool_ids_show()
5516 struct workqueue_struct *wq = dev_to_wq(dev); in wq_nice_show() local
5519 mutex_lock(&wq->mutex); in wq_nice_show()
5520 written = scnprintf(buf, PAGE_SIZE, "%d\n", wq->unbound_attrs->nice); in wq_nice_show()
5521 mutex_unlock(&wq->mutex); in wq_nice_show()
5527 static struct workqueue_attrs *wq_sysfs_prep_attrs(struct workqueue_struct *wq) in wq_sysfs_prep_attrs() argument
5537 copy_workqueue_attrs(attrs, wq->unbound_attrs); in wq_sysfs_prep_attrs()
5544 struct workqueue_struct *wq = dev_to_wq(dev); in wq_nice_store() local
5550 attrs = wq_sysfs_prep_attrs(wq); in wq_nice_store()
5556 ret = apply_workqueue_attrs_locked(wq, attrs); in wq_nice_store()
5569 struct workqueue_struct *wq = dev_to_wq(dev); in wq_cpumask_show() local
5572 mutex_lock(&wq->mutex); in wq_cpumask_show()
5574 cpumask_pr_args(wq->unbound_attrs->cpumask)); in wq_cpumask_show()
5575 mutex_unlock(&wq->mutex); in wq_cpumask_show()
5583 struct workqueue_struct *wq = dev_to_wq(dev); in wq_cpumask_store() local
5589 attrs = wq_sysfs_prep_attrs(wq); in wq_cpumask_store()
5595 ret = apply_workqueue_attrs_locked(wq, attrs); in wq_cpumask_store()
5606 struct workqueue_struct *wq = dev_to_wq(dev); in wq_numa_show() local
5609 mutex_lock(&wq->mutex); in wq_numa_show()
5611 !wq->unbound_attrs->no_numa); in wq_numa_show()
5612 mutex_unlock(&wq->mutex); in wq_numa_show()
5620 struct workqueue_struct *wq = dev_to_wq(dev); in wq_numa_store() local
5626 attrs = wq_sysfs_prep_attrs(wq); in wq_numa_store()
5633 ret = apply_workqueue_attrs_locked(wq, attrs); in wq_numa_store()
5723 int workqueue_sysfs_register(struct workqueue_struct *wq) in workqueue_sysfs_register() argument
5733 if (WARN_ON(wq->flags & __WQ_ORDERED_EXPLICIT)) in workqueue_sysfs_register()
5736 wq->wq_dev = wq_dev = kzalloc(sizeof(*wq_dev), GFP_KERNEL); in workqueue_sysfs_register()
5740 wq_dev->wq = wq; in workqueue_sysfs_register()
5743 dev_set_name(&wq_dev->dev, "%s", wq->name); in workqueue_sysfs_register()
5754 wq->wq_dev = NULL; in workqueue_sysfs_register()
5758 if (wq->flags & WQ_UNBOUND) { in workqueue_sysfs_register()
5765 wq->wq_dev = NULL; in workqueue_sysfs_register()
5782 static void workqueue_sysfs_unregister(struct workqueue_struct *wq) in workqueue_sysfs_unregister() argument
5784 struct wq_device *wq_dev = wq->wq_dev; in workqueue_sysfs_unregister()
5786 if (!wq->wq_dev) in workqueue_sysfs_unregister()
5789 wq->wq_dev = NULL; in workqueue_sysfs_unregister()
5793 static void workqueue_sysfs_unregister(struct workqueue_struct *wq) { } in workqueue_sysfs_unregister() argument
6078 struct workqueue_struct *wq; in workqueue_init() local
6101 list_for_each_entry(wq, &workqueues, list) { in workqueue_init()
6102 wq_update_unbound_numa(wq, smp_processor_id(), true); in workqueue_init()
6103 WARN(init_rescuer(wq), in workqueue_init()
6105 wq->name); in workqueue_init()