aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/fork.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/fork.c')
-rw-r--r--kernel/fork.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index da4a6a10d088..051f090d40c1 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -76,6 +76,9 @@
76 76
77#include <trace/events/sched.h> 77#include <trace/events/sched.h>
78 78
79#define CREATE_TRACE_POINTS
80#include <trace/events/task.h>
81
79/* 82/*
80 * Protected counters by write_lock_irq(&tasklist_lock) 83 * Protected counters by write_lock_irq(&tasklist_lock)
81 */ 84 */
@@ -870,6 +873,7 @@ static int copy_io(unsigned long clone_flags, struct task_struct *tsk)
870{ 873{
871#ifdef CONFIG_BLOCK 874#ifdef CONFIG_BLOCK
872 struct io_context *ioc = current->io_context; 875 struct io_context *ioc = current->io_context;
876 struct io_context *new_ioc;
873 877
874 if (!ioc) 878 if (!ioc)
875 return 0; 879 return 0;
@@ -881,11 +885,12 @@ static int copy_io(unsigned long clone_flags, struct task_struct *tsk)
881 if (unlikely(!tsk->io_context)) 885 if (unlikely(!tsk->io_context))
882 return -ENOMEM; 886 return -ENOMEM;
883 } else if (ioprio_valid(ioc->ioprio)) { 887 } else if (ioprio_valid(ioc->ioprio)) {
884 tsk->io_context = alloc_io_context(GFP_KERNEL, -1); 888 new_ioc = get_task_io_context(tsk, GFP_KERNEL, NUMA_NO_NODE);
885 if (unlikely(!tsk->io_context)) 889 if (unlikely(!new_ioc))
886 return -ENOMEM; 890 return -ENOMEM;
887 891
888 tsk->io_context->ioprio = ioc->ioprio; 892 new_ioc->ioprio = ioc->ioprio;
893 put_io_context(new_ioc, NULL);
889 } 894 }
890#endif 895#endif
891 return 0; 896 return 0;
@@ -972,7 +977,7 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
972 sched_autogroup_fork(sig); 977 sched_autogroup_fork(sig);
973 978
974#ifdef CONFIG_CGROUPS 979#ifdef CONFIG_CGROUPS
975 init_rwsem(&sig->threadgroup_fork_lock); 980 init_rwsem(&sig->group_rwsem);
976#endif 981#endif
977 982
978 sig->oom_adj = current->signal->oom_adj; 983 sig->oom_adj = current->signal->oom_adj;
@@ -992,7 +997,6 @@ static void copy_flags(unsigned long clone_flags, struct task_struct *p)
992 new_flags |= PF_FORKNOEXEC; 997 new_flags |= PF_FORKNOEXEC;
993 new_flags |= PF_STARTING; 998 new_flags |= PF_STARTING;
994 p->flags = new_flags; 999 p->flags = new_flags;
995 clear_freeze_flag(p);
996} 1000}
997 1001
998SYSCALL_DEFINE1(set_tid_address, int __user *, tidptr) 1002SYSCALL_DEFINE1(set_tid_address, int __user *, tidptr)
@@ -1023,8 +1027,8 @@ void mm_init_owner(struct mm_struct *mm, struct task_struct *p)
1023 */ 1027 */
1024static void posix_cpu_timers_init(struct task_struct *tsk) 1028static void posix_cpu_timers_init(struct task_struct *tsk)
1025{ 1029{
1026 tsk->cputime_expires.prof_exp = cputime_zero; 1030 tsk->cputime_expires.prof_exp = 0;
1027 tsk->cputime_expires.virt_exp = cputime_zero; 1031 tsk->cputime_expires.virt_exp = 0;
1028 tsk->cputime_expires.sched_exp = 0; 1032 tsk->cputime_expires.sched_exp = 0;
1029 INIT_LIST_HEAD(&tsk->cpu_timers[0]); 1033 INIT_LIST_HEAD(&tsk->cpu_timers[0]);
1030 INIT_LIST_HEAD(&tsk->cpu_timers[1]); 1034 INIT_LIST_HEAD(&tsk->cpu_timers[1]);
@@ -1132,14 +1136,10 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1132 1136
1133 init_sigpending(&p->pending); 1137 init_sigpending(&p->pending);
1134 1138
1135 p->utime = cputime_zero; 1139 p->utime = p->stime = p->gtime = 0;
1136 p->stime = cputime_zero; 1140 p->utimescaled = p->stimescaled = 0;
1137 p->gtime = cputime_zero;
1138 p->utimescaled = cputime_zero;
1139 p->stimescaled = cputime_zero;
1140#ifndef CONFIG_VIRT_CPU_ACCOUNTING 1141#ifndef CONFIG_VIRT_CPU_ACCOUNTING
1141 p->prev_utime = cputime_zero; 1142 p->prev_utime = p->prev_stime = 0;
1142 p->prev_stime = cputime_zero;
1143#endif 1143#endif
1144#if defined(SPLIT_RSS_COUNTING) 1144#if defined(SPLIT_RSS_COUNTING)
1145 memset(&p->rss_stat, 0, sizeof(p->rss_stat)); 1145 memset(&p->rss_stat, 0, sizeof(p->rss_stat));
@@ -1158,7 +1158,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1158 p->io_context = NULL; 1158 p->io_context = NULL;
1159 p->audit_context = NULL; 1159 p->audit_context = NULL;
1160 if (clone_flags & CLONE_THREAD) 1160 if (clone_flags & CLONE_THREAD)
1161 threadgroup_fork_read_lock(current); 1161 threadgroup_change_begin(current);
1162 cgroup_fork(p); 1162 cgroup_fork(p);
1163#ifdef CONFIG_NUMA 1163#ifdef CONFIG_NUMA
1164 p->mempolicy = mpol_dup(p->mempolicy); 1164 p->mempolicy = mpol_dup(p->mempolicy);
@@ -1296,6 +1296,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1296 1296
1297 p->nr_dirtied = 0; 1297 p->nr_dirtied = 0;
1298 p->nr_dirtied_pause = 128 >> (PAGE_SHIFT - 10); 1298 p->nr_dirtied_pause = 128 >> (PAGE_SHIFT - 10);
1299 p->dirty_paused_when = 0;
1299 1300
1300 /* 1301 /*
1301 * Ok, make it visible to the rest of the system. 1302 * Ok, make it visible to the rest of the system.
@@ -1373,8 +1374,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1373 proc_fork_connector(p); 1374 proc_fork_connector(p);
1374 cgroup_post_fork(p); 1375 cgroup_post_fork(p);
1375 if (clone_flags & CLONE_THREAD) 1376 if (clone_flags & CLONE_THREAD)
1376 threadgroup_fork_read_unlock(current); 1377 threadgroup_change_end(current);
1377 perf_event_fork(p); 1378 perf_event_fork(p);
1379
1380 trace_task_newtask(p, clone_flags);
1381
1378 return p; 1382 return p;
1379 1383
1380bad_fork_free_pid: 1384bad_fork_free_pid:
@@ -1408,7 +1412,7 @@ bad_fork_cleanup_policy:
1408bad_fork_cleanup_cgroup: 1412bad_fork_cleanup_cgroup:
1409#endif 1413#endif
1410 if (clone_flags & CLONE_THREAD) 1414 if (clone_flags & CLONE_THREAD)
1411 threadgroup_fork_read_unlock(current); 1415 threadgroup_change_end(current);
1412 cgroup_exit(p, cgroup_callbacks_done); 1416 cgroup_exit(p, cgroup_callbacks_done);
1413 delayacct_tsk_free(p); 1417 delayacct_tsk_free(p);
1414 module_put(task_thread_info(p)->exec_domain->module); 1418 module_put(task_thread_info(p)->exec_domain->module);
@@ -1523,8 +1527,6 @@ long do_fork(unsigned long clone_flags,
1523 init_completion(&vfork); 1527 init_completion(&vfork);
1524 } 1528 }
1525 1529
1526 audit_finish_fork(p);
1527
1528 /* 1530 /*
1529 * We set PF_STARTING at creation in case tracing wants to 1531 * We set PF_STARTING at creation in case tracing wants to
1530 * use this to distinguish a fully live task from one that 1532 * use this to distinguish a fully live task from one that