Lines Matching refs:kthread

56 struct kthread {  struct
82 static inline struct kthread *to_kthread(struct task_struct *k) in to_kthread() argument
99 static inline struct kthread *__to_kthread(struct task_struct *p) in __to_kthread()
101 void *kthread = p->worker_private; in __to_kthread() local
102 if (kthread && !(p->flags & PF_KTHREAD)) in __to_kthread()
103 kthread = NULL; in __to_kthread()
104 return kthread; in __to_kthread()
109 struct kthread *kthread = to_kthread(tsk); in get_kthread_comm() local
111 if (!kthread || !kthread->full_name) { in get_kthread_comm()
116 strscpy_pad(buf, kthread->full_name, buf_size); in get_kthread_comm()
121 struct kthread *kthread; in set_kthread_struct() local
126 kthread = kzalloc(sizeof(*kthread), GFP_KERNEL); in set_kthread_struct()
127 if (!kthread) in set_kthread_struct()
130 init_completion(&kthread->exited); in set_kthread_struct()
131 init_completion(&kthread->parked); in set_kthread_struct()
132 INIT_LIST_HEAD(&kthread->hotplug_node); in set_kthread_struct()
133 p->vfork_done = &kthread->exited; in set_kthread_struct()
135 kthread->task = p; in set_kthread_struct()
136 kthread->node = tsk_fork_get_node(current); in set_kthread_struct()
137 p->worker_private = kthread; in set_kthread_struct()
143 struct kthread *kthread; in free_kthread_struct() local
148 kthread = to_kthread(k); in free_kthread_struct()
149 if (!kthread) in free_kthread_struct()
153 WARN_ON_ONCE(kthread->blkcg_css); in free_kthread_struct()
156 kfree(kthread->full_name); in free_kthread_struct()
157 kfree(kthread); in free_kthread_struct()
197 struct kthread *kthread = __to_kthread(current); in kthread_should_stop_or_park() local
199 if (!kthread) in kthread_should_stop_or_park()
202 return kthread->flags & (BIT(KTHREAD_SHOULD_STOP) | BIT(KTHREAD_SHOULD_PARK)); in kthread_should_stop_or_park()
238 struct kthread *kthread = __to_kthread(task); in kthread_func() local
239 if (kthread) in kthread_func()
240 return kthread->threadfn; in kthread_func()
270 struct kthread *kthread = __to_kthread(task); in kthread_probe_data() local
273 if (kthread) in kthread_probe_data()
274 copy_from_kernel_nofault(&data, &kthread->data, sizeof(data)); in kthread_probe_data()
278 static void __kthread_parkme(struct kthread *self) in __kthread_parkme()
325 struct kthread *kthread = to_kthread(current); in kthread_exit() local
326 kthread->result = result; in kthread_exit()
327 if (!list_empty(&kthread->hotplug_node)) { in kthread_exit()
329 list_del(&kthread->hotplug_node); in kthread_exit()
332 if (kthread->preferred_affinity) { in kthread_exit()
333 kfree(kthread->preferred_affinity); in kthread_exit()
334 kthread->preferred_affinity = NULL; in kthread_exit()
362 static void kthread_fetch_affinity(struct kthread *kthread, struct cpumask *cpumask) in kthread_fetch_affinity() argument
366 if (kthread->preferred_affinity) { in kthread_fetch_affinity()
367 pref = kthread->preferred_affinity; in kthread_fetch_affinity()
369 if (WARN_ON_ONCE(kthread->node == NUMA_NO_NODE)) in kthread_fetch_affinity()
371 pref = cpumask_of_node(kthread->node); in kthread_fetch_affinity()
381 struct kthread *kthread = to_kthread(current); in kthread_affine_node() local
386 if (kthread->node == NUMA_NO_NODE) { in kthread_affine_node()
395 WARN_ON_ONCE(!list_empty(&kthread->hotplug_node)); in kthread_affine_node()
396 list_add_tail(&kthread->hotplug_node, &kthreads_hotplug); in kthread_affine_node()
404 kthread_fetch_affinity(kthread, affinity); in kthread_affine_node()
412 static int kthread(void *_create) in kthread() function
420 struct kthread *self; in kthread()
487 pid = kernel_thread(kthread, create, create->full_name, in create_kthread()
618 struct kthread *kthread = to_kthread(p); in kthread_bind_mask() local
620 WARN_ON_ONCE(kthread->started); in kthread_bind_mask()
634 struct kthread *kthread = to_kthread(p); in kthread_bind() local
636 WARN_ON_ONCE(kthread->started); in kthread_bind()
669 struct kthread *kthread = to_kthread(k); in kthread_set_per_cpu() local
670 if (!kthread) in kthread_set_per_cpu()
676 clear_bit(KTHREAD_IS_PER_CPU, &kthread->flags); in kthread_set_per_cpu()
680 kthread->cpu = cpu; in kthread_set_per_cpu()
681 set_bit(KTHREAD_IS_PER_CPU, &kthread->flags); in kthread_set_per_cpu()
686 struct kthread *kthread = __to_kthread(p); in kthread_is_per_cpu() local
687 if (!kthread) in kthread_is_per_cpu()
690 return test_bit(KTHREAD_IS_PER_CPU, &kthread->flags); in kthread_is_per_cpu()
703 struct kthread *kthread = to_kthread(k); in kthread_unpark() local
705 if (!test_bit(KTHREAD_SHOULD_PARK, &kthread->flags)) in kthread_unpark()
711 if (test_bit(KTHREAD_IS_PER_CPU, &kthread->flags)) in kthread_unpark()
712 __kthread_bind(k, kthread->cpu, TASK_PARKED); in kthread_unpark()
714 clear_bit(KTHREAD_SHOULD_PARK, &kthread->flags); in kthread_unpark()
736 struct kthread *kthread = to_kthread(k); in kthread_park() local
741 if (WARN_ON_ONCE(test_bit(KTHREAD_SHOULD_PARK, &kthread->flags))) in kthread_park()
744 set_bit(KTHREAD_SHOULD_PARK, &kthread->flags); in kthread_park()
751 wait_for_completion(&kthread->parked); in kthread_park()
780 struct kthread *kthread; in kthread_stop() local
786 kthread = to_kthread(k); in kthread_stop()
787 set_bit(KTHREAD_SHOULD_STOP, &kthread->flags); in kthread_stop()
791 wait_for_completion(&kthread->exited); in kthread_stop()
792 ret = kthread->result; in kthread_stop()
859 struct kthread *kthread = to_kthread(p); in kthread_affine_preferred() local
864 if (!wait_task_inactive(p, TASK_UNINTERRUPTIBLE) || kthread->started) { in kthread_affine_preferred()
869 WARN_ON_ONCE(kthread->preferred_affinity); in kthread_affine_preferred()
874 kthread->preferred_affinity = kzalloc(sizeof(struct cpumask), GFP_KERNEL); in kthread_affine_preferred()
875 if (!kthread->preferred_affinity) { in kthread_affine_preferred()
881 cpumask_copy(kthread->preferred_affinity, mask); in kthread_affine_preferred()
882 WARN_ON_ONCE(!list_empty(&kthread->hotplug_node)); in kthread_affine_preferred()
883 list_add_tail(&kthread->hotplug_node, &kthreads_hotplug); in kthread_affine_preferred()
884 kthread_fetch_affinity(kthread, affinity); in kthread_affine_preferred()
908 struct kthread *k; in kthreads_online_cpu()
1687 struct kthread *kthread; in kthread_associate_blkcg() local
1691 kthread = to_kthread(current); in kthread_associate_blkcg()
1692 if (!kthread) in kthread_associate_blkcg()
1695 if (kthread->blkcg_css) { in kthread_associate_blkcg()
1696 css_put(kthread->blkcg_css); in kthread_associate_blkcg()
1697 kthread->blkcg_css = NULL; in kthread_associate_blkcg()
1701 kthread->blkcg_css = css; in kthread_associate_blkcg()
1713 struct kthread *kthread; in kthread_blkcg() local
1716 kthread = to_kthread(current); in kthread_blkcg()
1717 if (kthread) in kthread_blkcg()
1718 return kthread->blkcg_css; in kthread_blkcg()