diff options
Diffstat (limited to 'kernel/fork.c')
-rw-r--r-- | kernel/fork.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 2a372a0e206f..7b93da72d4a2 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <linux/mount.h> | 47 | #include <linux/mount.h> |
48 | #include <linux/audit.h> | 48 | #include <linux/audit.h> |
49 | #include <linux/memcontrol.h> | 49 | #include <linux/memcontrol.h> |
50 | #include <linux/ftrace.h> | ||
50 | #include <linux/profile.h> | 51 | #include <linux/profile.h> |
51 | #include <linux/rmap.h> | 52 | #include <linux/rmap.h> |
52 | #include <linux/acct.h> | 53 | #include <linux/acct.h> |
@@ -80,6 +81,8 @@ DEFINE_PER_CPU(unsigned long, process_counts) = 0; | |||
80 | 81 | ||
81 | __cacheline_aligned DEFINE_RWLOCK(tasklist_lock); /* outer */ | 82 | __cacheline_aligned DEFINE_RWLOCK(tasklist_lock); /* outer */ |
82 | 83 | ||
84 | DEFINE_TRACE(sched_process_fork); | ||
85 | |||
83 | int nr_processes(void) | 86 | int nr_processes(void) |
84 | { | 87 | { |
85 | int cpu; | 88 | int cpu; |
@@ -137,6 +140,7 @@ void free_task(struct task_struct *tsk) | |||
137 | prop_local_destroy_single(&tsk->dirties); | 140 | prop_local_destroy_single(&tsk->dirties); |
138 | free_thread_info(tsk->stack); | 141 | free_thread_info(tsk->stack); |
139 | rt_mutex_debug_task_free(tsk); | 142 | rt_mutex_debug_task_free(tsk); |
143 | ftrace_graph_exit_task(tsk); | ||
140 | free_task_struct(tsk); | 144 | free_task_struct(tsk); |
141 | } | 145 | } |
142 | EXPORT_SYMBOL(free_task); | 146 | EXPORT_SYMBOL(free_task); |
@@ -315,17 +319,20 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm) | |||
315 | file = tmp->vm_file; | 319 | file = tmp->vm_file; |
316 | if (file) { | 320 | if (file) { |
317 | struct inode *inode = file->f_path.dentry->d_inode; | 321 | struct inode *inode = file->f_path.dentry->d_inode; |
322 | struct address_space *mapping = file->f_mapping; | ||
323 | |||
318 | get_file(file); | 324 | get_file(file); |
319 | if (tmp->vm_flags & VM_DENYWRITE) | 325 | if (tmp->vm_flags & VM_DENYWRITE) |
320 | atomic_dec(&inode->i_writecount); | 326 | atomic_dec(&inode->i_writecount); |
321 | 327 | spin_lock(&mapping->i_mmap_lock); | |
322 | /* insert tmp into the share list, just after mpnt */ | 328 | if (tmp->vm_flags & VM_SHARED) |
323 | spin_lock(&file->f_mapping->i_mmap_lock); | 329 | mapping->i_mmap_writable++; |
324 | tmp->vm_truncate_count = mpnt->vm_truncate_count; | 330 | tmp->vm_truncate_count = mpnt->vm_truncate_count; |
325 | flush_dcache_mmap_lock(file->f_mapping); | 331 | flush_dcache_mmap_lock(mapping); |
332 | /* insert tmp into the share list, just after mpnt */ | ||
326 | vma_prio_tree_add(tmp, mpnt); | 333 | vma_prio_tree_add(tmp, mpnt); |
327 | flush_dcache_mmap_unlock(file->f_mapping); | 334 | flush_dcache_mmap_unlock(mapping); |
328 | spin_unlock(&file->f_mapping->i_mmap_lock); | 335 | spin_unlock(&mapping->i_mmap_lock); |
329 | } | 336 | } |
330 | 337 | ||
331 | /* | 338 | /* |
@@ -1133,6 +1140,8 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1133 | } | 1140 | } |
1134 | } | 1141 | } |
1135 | 1142 | ||
1143 | ftrace_graph_init_task(p); | ||
1144 | |||
1136 | p->pid = pid_nr(pid); | 1145 | p->pid = pid_nr(pid); |
1137 | p->tgid = p->pid; | 1146 | p->tgid = p->pid; |
1138 | if (clone_flags & CLONE_THREAD) | 1147 | if (clone_flags & CLONE_THREAD) |
@@ -1141,7 +1150,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1141 | if (current->nsproxy != p->nsproxy) { | 1150 | if (current->nsproxy != p->nsproxy) { |
1142 | retval = ns_cgroup_clone(p, pid); | 1151 | retval = ns_cgroup_clone(p, pid); |
1143 | if (retval) | 1152 | if (retval) |
1144 | goto bad_fork_free_pid; | 1153 | goto bad_fork_free_graph; |
1145 | } | 1154 | } |
1146 | 1155 | ||
1147 | p->set_child_tid = (clone_flags & CLONE_CHILD_SETTID) ? child_tidptr : NULL; | 1156 | p->set_child_tid = (clone_flags & CLONE_CHILD_SETTID) ? child_tidptr : NULL; |
@@ -1234,7 +1243,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1234 | spin_unlock(¤t->sighand->siglock); | 1243 | spin_unlock(¤t->sighand->siglock); |
1235 | write_unlock_irq(&tasklist_lock); | 1244 | write_unlock_irq(&tasklist_lock); |
1236 | retval = -ERESTARTNOINTR; | 1245 | retval = -ERESTARTNOINTR; |
1237 | goto bad_fork_free_pid; | 1246 | goto bad_fork_free_graph; |
1238 | } | 1247 | } |
1239 | 1248 | ||
1240 | if (clone_flags & CLONE_THREAD) { | 1249 | if (clone_flags & CLONE_THREAD) { |
@@ -1271,6 +1280,8 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1271 | cgroup_post_fork(p); | 1280 | cgroup_post_fork(p); |
1272 | return p; | 1281 | return p; |
1273 | 1282 | ||
1283 | bad_fork_free_graph: | ||
1284 | ftrace_graph_exit_task(p); | ||
1274 | bad_fork_free_pid: | 1285 | bad_fork_free_pid: |
1275 | if (pid != &init_struct_pid) | 1286 | if (pid != &init_struct_pid) |
1276 | free_pid(pid); | 1287 | free_pid(pid); |
@@ -1398,6 +1409,7 @@ long do_fork(unsigned long clone_flags, | |||
1398 | init_completion(&vfork); | 1409 | init_completion(&vfork); |
1399 | } | 1410 | } |
1400 | 1411 | ||
1412 | audit_finish_fork(p); | ||
1401 | tracehook_report_clone(trace, regs, clone_flags, nr, p); | 1413 | tracehook_report_clone(trace, regs, clone_flags, nr, p); |
1402 | 1414 | ||
1403 | /* | 1415 | /* |