diff options
Diffstat (limited to 'kernel/perf_event.c')
| -rw-r--r-- | kernel/perf_event.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index 3472bb1a070c..27960f114efd 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c | |||
| @@ -145,7 +145,8 @@ static struct srcu_struct pmus_srcu; | |||
| 145 | */ | 145 | */ |
| 146 | int sysctl_perf_event_paranoid __read_mostly = 1; | 146 | int sysctl_perf_event_paranoid __read_mostly = 1; |
| 147 | 147 | ||
| 148 | int sysctl_perf_event_mlock __read_mostly = 512; /* 'free' kb per user */ | 148 | /* Minimum for 512 kiB + 1 user control page */ |
| 149 | int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */ | ||
| 149 | 150 | ||
| 150 | /* | 151 | /* |
| 151 | * max perf event sample rate | 152 | * max perf event sample rate |
| @@ -941,6 +942,7 @@ static void perf_group_attach(struct perf_event *event) | |||
| 941 | static void | 942 | static void |
| 942 | list_del_event(struct perf_event *event, struct perf_event_context *ctx) | 943 | list_del_event(struct perf_event *event, struct perf_event_context *ctx) |
| 943 | { | 944 | { |
| 945 | struct perf_cpu_context *cpuctx; | ||
| 944 | /* | 946 | /* |
| 945 | * We can have double detach due to exit/hot-unplug + close. | 947 | * We can have double detach due to exit/hot-unplug + close. |
| 946 | */ | 948 | */ |
| @@ -949,8 +951,17 @@ list_del_event(struct perf_event *event, struct perf_event_context *ctx) | |||
| 949 | 951 | ||
| 950 | event->attach_state &= ~PERF_ATTACH_CONTEXT; | 952 | event->attach_state &= ~PERF_ATTACH_CONTEXT; |
| 951 | 953 | ||
| 952 | if (is_cgroup_event(event)) | 954 | if (is_cgroup_event(event)) { |
| 953 | ctx->nr_cgroups--; | 955 | ctx->nr_cgroups--; |
| 956 | cpuctx = __get_cpu_context(ctx); | ||
| 957 | /* | ||
| 958 | * if there are no more cgroup events | ||
| 959 | * then cler cgrp to avoid stale pointer | ||
| 960 | * in update_cgrp_time_from_cpuctx() | ||
| 961 | */ | ||
| 962 | if (!ctx->nr_cgroups) | ||
| 963 | cpuctx->cgrp = NULL; | ||
| 964 | } | ||
| 954 | 965 | ||
| 955 | ctx->nr_events--; | 966 | ctx->nr_events--; |
| 956 | if (event->attr.inherit_stat) | 967 | if (event->attr.inherit_stat) |
| @@ -6520,6 +6531,11 @@ SYSCALL_DEFINE5(perf_event_open, | |||
| 6520 | goto err_alloc; | 6531 | goto err_alloc; |
| 6521 | } | 6532 | } |
| 6522 | 6533 | ||
| 6534 | if (task) { | ||
| 6535 | put_task_struct(task); | ||
| 6536 | task = NULL; | ||
| 6537 | } | ||
| 6538 | |||
| 6523 | /* | 6539 | /* |
| 6524 | * Look up the group leader (we will attach this event to it): | 6540 | * Look up the group leader (we will attach this event to it): |
| 6525 | */ | 6541 | */ |
