diff options
Diffstat (limited to 'kernel/fork.c')
-rw-r--r-- | kernel/fork.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index bb762b4dd217..4430eb1376f2 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -62,6 +62,7 @@ | |||
62 | #include <linux/blkdev.h> | 62 | #include <linux/blkdev.h> |
63 | #include <linux/fs_struct.h> | 63 | #include <linux/fs_struct.h> |
64 | #include <linux/magic.h> | 64 | #include <linux/magic.h> |
65 | #include <linux/perf_counter.h> | ||
65 | 66 | ||
66 | #include <asm/pgtable.h> | 67 | #include <asm/pgtable.h> |
67 | #include <asm/pgalloc.h> | 68 | #include <asm/pgalloc.h> |
@@ -1096,6 +1097,10 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1096 | /* Perform scheduler related setup. Assign this task to a CPU. */ | 1097 | /* Perform scheduler related setup. Assign this task to a CPU. */ |
1097 | sched_fork(p, clone_flags); | 1098 | sched_fork(p, clone_flags); |
1098 | 1099 | ||
1100 | retval = perf_counter_init_task(p); | ||
1101 | if (retval) | ||
1102 | goto bad_fork_cleanup_policy; | ||
1103 | |||
1099 | if ((retval = audit_alloc(p))) | 1104 | if ((retval = audit_alloc(p))) |
1100 | goto bad_fork_cleanup_policy; | 1105 | goto bad_fork_cleanup_policy; |
1101 | /* copy all the process information */ | 1106 | /* copy all the process information */ |
@@ -1290,6 +1295,7 @@ bad_fork_cleanup_semundo: | |||
1290 | bad_fork_cleanup_audit: | 1295 | bad_fork_cleanup_audit: |
1291 | audit_free(p); | 1296 | audit_free(p); |
1292 | bad_fork_cleanup_policy: | 1297 | bad_fork_cleanup_policy: |
1298 | perf_counter_free_task(p); | ||
1293 | #ifdef CONFIG_NUMA | 1299 | #ifdef CONFIG_NUMA |
1294 | mpol_put(p->mempolicy); | 1300 | mpol_put(p->mempolicy); |
1295 | bad_fork_cleanup_cgroup: | 1301 | bad_fork_cleanup_cgroup: |
@@ -1403,6 +1409,12 @@ long do_fork(unsigned long clone_flags, | |||
1403 | if (clone_flags & CLONE_VFORK) { | 1409 | if (clone_flags & CLONE_VFORK) { |
1404 | p->vfork_done = &vfork; | 1410 | p->vfork_done = &vfork; |
1405 | init_completion(&vfork); | 1411 | init_completion(&vfork); |
1412 | } else if (!(clone_flags & CLONE_VM)) { | ||
1413 | /* | ||
1414 | * vfork will do an exec which will call | ||
1415 | * set_task_comm() | ||
1416 | */ | ||
1417 | perf_counter_fork(p); | ||
1406 | } | 1418 | } |
1407 | 1419 | ||
1408 | audit_finish_fork(p); | 1420 | audit_finish_fork(p); |