aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/perf_counter.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index 7515c7695428..0a45490f4029 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -3568,6 +3568,7 @@ perf_counter_alloc(struct perf_counter_attr *attr,
3568 int cpu, 3568 int cpu,
3569 struct perf_counter_context *ctx, 3569 struct perf_counter_context *ctx,
3570 struct perf_counter *group_leader, 3570 struct perf_counter *group_leader,
3571 struct perf_counter *parent_counter,
3571 gfp_t gfpflags) 3572 gfp_t gfpflags)
3572{ 3573{
3573 const struct pmu *pmu; 3574 const struct pmu *pmu;
@@ -3603,6 +3604,8 @@ perf_counter_alloc(struct perf_counter_attr *attr,
3603 counter->ctx = ctx; 3604 counter->ctx = ctx;
3604 counter->oncpu = -1; 3605 counter->oncpu = -1;
3605 3606
3607 counter->parent = parent_counter;
3608
3606 counter->ns = get_pid_ns(current->nsproxy->pid_ns); 3609 counter->ns = get_pid_ns(current->nsproxy->pid_ns);
3607 counter->id = atomic64_inc_return(&perf_counter_id); 3610 counter->id = atomic64_inc_return(&perf_counter_id);
3608 3611
@@ -3827,7 +3830,7 @@ SYSCALL_DEFINE5(perf_counter_open,
3827 } 3830 }
3828 3831
3829 counter = perf_counter_alloc(&attr, cpu, ctx, group_leader, 3832 counter = perf_counter_alloc(&attr, cpu, ctx, group_leader,
3830 GFP_KERNEL); 3833 NULL, GFP_KERNEL);
3831 ret = PTR_ERR(counter); 3834 ret = PTR_ERR(counter);
3832 if (IS_ERR(counter)) 3835 if (IS_ERR(counter))
3833 goto err_put_context; 3836 goto err_put_context;
@@ -3893,7 +3896,8 @@ inherit_counter(struct perf_counter *parent_counter,
3893 3896
3894 child_counter = perf_counter_alloc(&parent_counter->attr, 3897 child_counter = perf_counter_alloc(&parent_counter->attr,
3895 parent_counter->cpu, child_ctx, 3898 parent_counter->cpu, child_ctx,
3896 group_leader, GFP_KERNEL); 3899 group_leader, parent_counter,
3900 GFP_KERNEL);
3897 if (IS_ERR(child_counter)) 3901 if (IS_ERR(child_counter))
3898 return child_counter; 3902 return child_counter;
3899 get_ctx(child_ctx); 3903 get_ctx(child_ctx);
@@ -3916,12 +3920,6 @@ inherit_counter(struct perf_counter *parent_counter,
3916 */ 3920 */
3917 add_counter_to_ctx(child_counter, child_ctx); 3921 add_counter_to_ctx(child_counter, child_ctx);
3918 3922
3919 child_counter->parent = parent_counter;
3920 /*
3921 * inherit into child's child as well:
3922 */
3923 child_counter->attr.inherit = 1;
3924
3925 /* 3923 /*
3926 * Get a reference to the parent filp - we will fput it 3924 * Get a reference to the parent filp - we will fput it
3927 * when the child counter exits. This is safe to do because 3925 * when the child counter exits. This is safe to do because