102
/* called from do_fork() to get node information for about to be created task */
103
int tsk_fork_get_node(struct task_struct *tsk)
106
if (tsk == kthreadd_task)
107
return tsk->pref_node_fork;
109
return numa_node_id();
101
112
static void create_kthread(struct kthread_create_info *create)
117
current->pref_node_fork = create->node;
105
119
/* We want our own signal handler (we take no signals by default). */
106
120
pid = kernel_thread(kthread, create, CLONE_FS | CLONE_FILES | SIGCHLD);
114
* kthread_create - create a kthread.
128
* kthread_create_on_node - create a kthread.
115
129
* @threadfn: the function to run until signal_pending(current).
116
130
* @data: data ptr for @threadfn.
131
* @node: memory node number.
117
132
* @namefmt: printf-style name for the thread.
119
134
* Description: This helper function creates and names a kernel
120
135
* thread. The thread will be stopped: use wake_up_process() to start
121
136
* it. See also kthread_run().
138
* If thread is going to be bound on a particular cpu, give its node
139
* in @node, to get NUMA affinity for kthread stack, or else give -1.
123
140
* When woken, the thread will run @threadfn() with @data as its
124
141
* argument. @threadfn() can either call do_exit() directly if it is a
125
* standalone thread for which noone will call kthread_stop(), or
142
* standalone thread for which no one will call kthread_stop(), or
126
143
* return when 'kthread_should_stop()' is true (which means
127
144
* kthread_stop() has been called). The return value should be zero
128
145
* or a negative error number; it will be passed to kthread_stop().
130
147
* Returns a task_struct or ERR_PTR(-ENOMEM).
132
struct task_struct *kthread_create(int (*threadfn)(void *data),
134
const char namefmt[],
149
struct task_struct *kthread_create_on_node(int (*threadfn)(void *data),
152
const char namefmt[],
137
155
struct kthread_create_info create;
139
157
create.threadfn = threadfn;
140
158
create.data = data;
141
160
init_completion(&create.done);
143
162
spin_lock(&kthread_create_lock);