fork.c (5469dc270cd44c451590d40c031e6a71c1f637e8) fork.c (725fc629ff2545b061407305ae51016c9f928fce)
1/*
2 * linux/kernel/fork.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 */
6
7/*
8 * 'fork.c' contains the help-routines for the 'fork' system call

--- 326 unchanged lines hidden (view full) ---

335void set_task_stack_end_magic(struct task_struct *tsk)
336{
337 unsigned long *stackend;
338
339 stackend = end_of_stack(tsk);
340 *stackend = STACK_END_MAGIC; /* for overflow detection */
341}
342
1/*
2 * linux/kernel/fork.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 */
6
7/*
8 * 'fork.c' contains the help-routines for the 'fork' system call

--- 326 unchanged lines hidden (view full) ---

335void set_task_stack_end_magic(struct task_struct *tsk)
336{
337 unsigned long *stackend;
338
339 stackend = end_of_stack(tsk);
340 *stackend = STACK_END_MAGIC; /* for overflow detection */
341}
342
343static struct task_struct *dup_task_struct(struct task_struct *orig)
343static struct task_struct *dup_task_struct(struct task_struct *orig, int node)
344{
345 struct task_struct *tsk;
346 struct thread_info *ti;
344{
345 struct task_struct *tsk;
346 struct thread_info *ti;
347 int node = tsk_fork_get_node(orig);
348 int err;
349
347 int err;
348
349 if (node == NUMA_NO_NODE)
350 node = tsk_fork_get_node(orig);
350 tsk = alloc_task_struct_node(node);
351 if (!tsk)
352 return NULL;
353
354 ti = alloc_thread_info_node(tsk, node);
355 if (!ti)
356 goto free_tsk;
357

--- 913 unchanged lines hidden (view full) ---

1271 * flags). The actual kick-off is left to the caller.
1272 */
1273static struct task_struct *copy_process(unsigned long clone_flags,
1274 unsigned long stack_start,
1275 unsigned long stack_size,
1276 int __user *child_tidptr,
1277 struct pid *pid,
1278 int trace,
351 tsk = alloc_task_struct_node(node);
352 if (!tsk)
353 return NULL;
354
355 ti = alloc_thread_info_node(tsk, node);
356 if (!ti)
357 goto free_tsk;
358

--- 913 unchanged lines hidden (view full) ---

1272 * flags). The actual kick-off is left to the caller.
1273 */
1274static struct task_struct *copy_process(unsigned long clone_flags,
1275 unsigned long stack_start,
1276 unsigned long stack_size,
1277 int __user *child_tidptr,
1278 struct pid *pid,
1279 int trace,
1279 unsigned long tls)
1280 unsigned long tls,
1281 int node)
1280{
1281 int retval;
1282 struct task_struct *p;
1283
1284 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
1285 return ERR_PTR(-EINVAL);
1286
1287 if ((clone_flags & (CLONE_NEWUSER|CLONE_FS)) == (CLONE_NEWUSER|CLONE_FS))

--- 35 unchanged lines hidden (view full) ---

1323 return ERR_PTR(-EINVAL);
1324 }
1325
1326 retval = security_task_create(clone_flags);
1327 if (retval)
1328 goto fork_out;
1329
1330 retval = -ENOMEM;
1282{
1283 int retval;
1284 struct task_struct *p;
1285
1286 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
1287 return ERR_PTR(-EINVAL);
1288
1289 if ((clone_flags & (CLONE_NEWUSER|CLONE_FS)) == (CLONE_NEWUSER|CLONE_FS))

--- 35 unchanged lines hidden (view full) ---

1325 return ERR_PTR(-EINVAL);
1326 }
1327
1328 retval = security_task_create(clone_flags);
1329 if (retval)
1330 goto fork_out;
1331
1332 retval = -ENOMEM;
1331 p = dup_task_struct(current);
1333 p = dup_task_struct(current, node);
1332 if (!p)
1333 goto fork_out;
1334
1335 ftrace_graph_init_task(p);
1336
1337 rt_mutex_init_task(p);
1338
1339#ifdef CONFIG_PROVE_LOCKING

--- 361 unchanged lines hidden (view full) ---

1701 INIT_HLIST_NODE(&links[type].node); /* not really needed */
1702 links[type].pid = &init_struct_pid;
1703 }
1704}
1705
1706struct task_struct *fork_idle(int cpu)
1707{
1708 struct task_struct *task;
1334 if (!p)
1335 goto fork_out;
1336
1337 ftrace_graph_init_task(p);
1338
1339 rt_mutex_init_task(p);
1340
1341#ifdef CONFIG_PROVE_LOCKING

--- 361 unchanged lines hidden (view full) ---

1703 INIT_HLIST_NODE(&links[type].node); /* not really needed */
1704 links[type].pid = &init_struct_pid;
1705 }
1706}
1707
1708struct task_struct *fork_idle(int cpu)
1709{
1710 struct task_struct *task;
1709 task = copy_process(CLONE_VM, 0, 0, NULL, &init_struct_pid, 0, 0);
1711 task = copy_process(CLONE_VM, 0, 0, NULL, &init_struct_pid, 0, 0,
1712 cpu_to_node(cpu));
1710 if (!IS_ERR(task)) {
1711 init_idle_pids(task->pids);
1712 init_idle(task, cpu);
1713 }
1714
1715 return task;
1716}
1717

--- 28 unchanged lines hidden (view full) ---

1746 else
1747 trace = PTRACE_EVENT_FORK;
1748
1749 if (likely(!ptrace_event_enabled(current, trace)))
1750 trace = 0;
1751 }
1752
1753 p = copy_process(clone_flags, stack_start, stack_size,
1713 if (!IS_ERR(task)) {
1714 init_idle_pids(task->pids);
1715 init_idle(task, cpu);
1716 }
1717
1718 return task;
1719}
1720

--- 28 unchanged lines hidden (view full) ---

1749 else
1750 trace = PTRACE_EVENT_FORK;
1751
1752 if (likely(!ptrace_event_enabled(current, trace)))
1753 trace = 0;
1754 }
1755
1756 p = copy_process(clone_flags, stack_start, stack_size,
1754 child_tidptr, NULL, trace, tls);
1757 child_tidptr, NULL, trace, tls, NUMA_NO_NODE);
1755 /*
1756 * Do this prior waking up the new thread - the thread pointer
1757 * might get invalid after that point, if the thread exits quickly.
1758 */
1759 if (!IS_ERR(p)) {
1760 struct completion vfork;
1761 struct pid *pid;
1762

--- 388 unchanged lines hidden ---
1758 /*
1759 * Do this prior waking up the new thread - the thread pointer
1760 * might get invalid after that point, if the thread exits quickly.
1761 */
1762 if (!IS_ERR(p)) {
1763 struct completion vfork;
1764 struct pid *pid;
1765

--- 388 unchanged lines hidden ---