Go to the documentation of this file. 1 #ifndef _LINUX_KTHREAD_H
2 #define _LINUX_KTHREAD_H
5 #include <linux/sched.h>
13 #define kthread_create(threadfn, data, namefmt, arg...) \
14 kthread_create_on_node(threadfn, data, -1, namefmt, ##arg)
31 #define kthread_run(threadfn, data, namefmt, ...) \
33 struct task_struct *__k \
34 = kthread_create(threadfn, data, namefmt, ## __VA_ARGS__); \
36 wake_up_process(__k); \
79 #define KTHREAD_WORKER_INIT(worker) { \
80 .lock = __SPIN_LOCK_UNLOCKED((worker).lock), \
81 .work_list = LIST_HEAD_INIT((worker).work_list), \
84 #define KTHREAD_WORK_INIT(work, fn) { \
85 .node = LIST_HEAD_INIT((work).node), \
87 .done = __WAIT_QUEUE_HEAD_INITIALIZER((work).done), \
90 #define DEFINE_KTHREAD_WORKER(worker) \
91 struct kthread_worker worker = KTHREAD_WORKER_INIT(worker)
93 #define DEFINE_KTHREAD_WORK(work, fn) \
94 struct kthread_work work = KTHREAD_WORK_INIT(work, fn)
101 #ifdef CONFIG_LOCKDEP
102 # define KTHREAD_WORKER_INIT_ONSTACK(worker) \
103 ({ init_kthread_worker(&worker); worker; })
104 # define DEFINE_KTHREAD_WORKER_ONSTACK(worker) \
105 struct kthread_worker worker = KTHREAD_WORKER_INIT_ONSTACK(worker)
106 # define KTHREAD_WORK_INIT_ONSTACK(work, fn) \
107 ({ init_kthread_work((&work), fn); work; })
108 # define DEFINE_KTHREAD_WORK_ONSTACK(work, fn) \
109 struct kthread_work work = KTHREAD_WORK_INIT_ONSTACK(work, fn)
111 # define DEFINE_KTHREAD_WORKER_ONSTACK(worker) DEFINE_KTHREAD_WORKER(worker)
112 # define DEFINE_KTHREAD_WORK_ONSTACK(work, fn) DEFINE_KTHREAD_WORK(work, fn)
118 #define init_kthread_worker(worker) \
120 static struct lock_class_key __key; \
121 __init_kthread_worker((worker), "("#worker")->lock", &__key); \
124 #define init_kthread_work(work, fn) \
126 memset((work), 0, sizeof(struct kthread_work)); \
127 INIT_LIST_HEAD(&(work)->node); \
128 (work)->func = (fn); \
129 init_waitqueue_head(&(work)->done); \