Lines Matching refs:kthread

16 #include <linux/kthread.h>
40 /* Information passed to kthread() from kthreadd. */
53 struct kthread {
74 static inline struct kthread *to_kthread(struct task_struct *k)
81 * Variant of to_kthread() that doesn't assume @p is a kthread.
87 * the task is both a kthread and struct kthread is persistent. However
91 static inline struct kthread *__to_kthread(struct task_struct *p)
93 void *kthread = p->worker_private;
94 if (kthread && !(p->flags & PF_KTHREAD))
95 kthread = NULL;
96 return kthread;
101 struct kthread *kthread = to_kthread(tsk);
103 if (!kthread || !kthread->full_name) {
108 strscpy_pad(buf, kthread->full_name, buf_size);
113 struct kthread *kthread;
118 kthread = kzalloc(sizeof(*kthread), GFP_KERNEL);
119 if (!kthread)
122 init_completion(&kthread->exited);
123 init_completion(&kthread->parked);
124 p->vfork_done = &kthread->exited;
126 p->worker_private = kthread;
132 struct kthread *kthread;
137 kthread = to_kthread(k);
138 if (!kthread)
142 WARN_ON_ONCE(kthread->blkcg_css);
145 kfree(kthread->full_name);
146 kfree(kthread);
150 * kthread_should_stop - should this kthread return now?
152 * When someone calls kthread_stop() on your kthread, it will be woken
168 * kthread_should_park - should this kthread park now?
170 * When someone calls kthread_park() on your kthread, it will be woken
186 struct kthread *kthread = __to_kthread(current);
188 if (!kthread)
191 return kthread->flags & (BIT(KTHREAD_SHOULD_STOP) | BIT(KTHREAD_SHOULD_PARK));
195 * kthread_freezable_should_stop - should this freezable kthread return now?
220 * kthread_func - return the function specified on kthread creation
221 * @task: kthread task in question
223 * Returns NULL if the task is not a kthread.
227 struct kthread *kthread = __to_kthread(task);
228 if (kthread)
229 return kthread->threadfn;
235 * kthread_data - return data value specified on kthread creation
236 * @task: kthread task in question
238 * Return the data value specified when kthread @task was created.
250 * @task: possible kthread task in question
252 * @task could be a kthread task. Return the data value specified when it
253 * was created if accessible. If @task isn't a kthread task or its data is
259 struct kthread *kthread = __to_kthread(task);
262 if (kthread)
263 copy_from_kernel_nofault(&data, &kthread->data, sizeof(data));
267 static void __kthread_parkme(struct kthread *self)
303 * kthread_exit - Cause the current kthread return @result to kthread_stop().
314 struct kthread *kthread = to_kthread(current);
315 kthread->result = result;
321 * kthread_complete_and_exit - Exit the current kthread.
341 static int kthread(void *_create)
344 /* Copy data: it's on kthread's stack */
349 struct kthread *self;
412 pid = kernel_thread(kthread, create, create->full_name,
482 * kthread_create_on_node - create a kthread.
494 * in @node, to get NUMA affinity for kthread stack, or else give NUMA_NO_NODE.
547 * kthread_bind - bind a just-created kthread to a cpu.
562 * kthread_create_on_cpu - Create a cpu bound kthread
590 struct kthread *kthread = to_kthread(k);
591 if (!kthread)
597 clear_bit(KTHREAD_IS_PER_CPU, &kthread->flags);
601 kthread->cpu = cpu;
602 set_bit(KTHREAD_IS_PER_CPU, &kthread->flags);
607 struct kthread *kthread = __to_kthread(p);
608 if (!kthread)
611 return test_bit(KTHREAD_IS_PER_CPU, &kthread->flags);
624 struct kthread *kthread = to_kthread(k);
627 * Newly created kthread was parked when the CPU was offline.
630 if (test_bit(KTHREAD_IS_PER_CPU, &kthread->flags))
631 __kthread_bind(k, kthread->cpu, TASK_PARKED);
633 clear_bit(KTHREAD_SHOULD_PARK, &kthread->flags);
651 * If called by the kthread itself just the park bit is set.
655 struct kthread *kthread = to_kthread(k);
660 if (WARN_ON_ONCE(test_bit(KTHREAD_SHOULD_PARK, &kthread->flags)))
663 set_bit(KTHREAD_SHOULD_PARK, &kthread->flags);
670 wait_for_completion(&kthread->parked);
699 struct kthread *kthread;
705 kthread = to_kthread(k);
706 set_bit(KTHREAD_SHOULD_STOP, &kthread->flags);
710 wait_for_completion(&kthread->exited);
711 ret = kthread->result;
788 * kthread_worker_fn - kthread function to process kthread_worker
791 * This function implements the main cycle of kthread worker. It processes
808 * FIXME: Update the check and remove the assignment when all kthread
893 * kthread_create_worker - create a kthread worker
895 * @namefmt: printf-style name for the kthread worker (task).
916 * kthread_create_worker_on_cpu - create a kthread worker and bind it
920 * @namefmt: printf-style name for the kthread worker (task).
922 * Use a valid CPU number if you want to bind the kthread worker
929 * The kthread worker API is simple and generic. It just provides a way
1031 * kthread_delayed_work_timer_fn - callback that queues the associated kthread
1096 * kthread_queue_delayed_work - queue the associated kthread work
1235 * kthread_mod_delayed_work - modify delay of or queue a kthread delayed work
1236 * @worker: kthread worker to use
1237 * @dwork: kthread delayed work to queue
1342 * kthread_cancel_work_sync - cancel a kthread work and wait for it to finish
1343 * @work: the kthread work to cancel
1364 * kthread_cancel_delayed_work_sync - cancel a kthread delayed work and
1366 * @dwork: the kthread delayed work to cancel
1398 * kthread_destroy_worker - destroy a kthread worker
1401 * Flush and destroy @worker. The simple flush is enough because the kthread
1426 * kthread_use_mm - make the calling kthread operate on an address space
1459 * When a kthread starts operating on an address space, the loop
1484 * When a kthread stops operating on an address space, the loop
1506 * kthread_associate_blkcg - associate blkcg to current kthread
1509 * Current thread must be a kthread. The thread is running jobs on behalf of
1512 * original thread's cgroup info in current kthread context for later
1517 struct kthread *kthread;
1521 kthread = to_kthread(current);
1522 if (!kthread)
1525 if (kthread->blkcg_css) {
1526 css_put(kthread->blkcg_css);
1527 kthread->blkcg_css = NULL;
1531 kthread->blkcg_css = css;
1537 * kthread_blkcg - get associated blkcg css of current kthread
1539 * Current thread must be a kthread.
1543 struct kthread *kthread;
1546 kthread = to_kthread(current);
1547 if (kthread)
1548 return kthread->blkcg_css;