aboutsummaryrefslogtreecommitdiff
path: root/kernel/events/core.c
diff options
context:
space:
mode:
authorKevin Hilman <khilman@linaro.org>2015-09-14 14:20:05 -0700
committerKevin Hilman <khilman@linaro.org>2015-09-14 14:20:05 -0700
commitde5cfb5acd63d7f86bd60dc4a578519fe4831bca (patch)
tree166fde342fc3aaf31e6498d448dc4af5dc400ec9 /kernel/events/core.c
parent6c5cc590aee3a2602edfa907120e6c1f6d0dc0e4 (diff)
parentc765e5c15e7d23d2b8b37fafdafc63c0ea75fabf (diff)
Merge branch 'linux-linaro-lsk-v3.14' into linux-linaro-lsk-v3.14-androidlsk-v3.14-15.09-android
* linux-linaro-lsk-v3.14: (66 commits) Linux 3.14.52 arm64: KVM: Fix host crash when injecting a fault into a 32bit guest SCSI: Fix NULL pointer dereference in runtime PM arm64/mm: Remove hack in mmap randomize layout crypto: caam - fix memory corruption in ahash_final_ctx regmap: regcache-rbtree: Clean new present bits on present bitmap resize libfc: Fix fc_fcp_cleanup_each_cmd() libfc: Fix fc_exch_recv_req() error path drm/vmwgfx: Fix execbuf locking issues drm/radeon: add new OLAND pci id EDAC, ppc4xx: Access mci->csrows array elements properly localmodconfig: Use Kbuild files too dm thin metadata: delete btrees when releasing metadata snapshot perf: Fix PERF_EVENT_IOC_PERIOD migration race perf: Fix fasync handling on inherited events xen-blkfront: don't add indirect pages to list when !feature_persistent mm/hwpoison: fix page refcount of unknown non LRU page ipc/sem.c: update/correct memory barriers ipc,sem: fix use after free on IPC_RMID after a task using same semaphore set exits arm64: el0_dbg does not set link reg for return to user path, breaks debug ...
Diffstat (limited to 'kernel/events/core.c')
-rw-r--r--kernel/events/core.c87
1 files changed, 65 insertions, 22 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 60146febb9b3..3bf20e36a8e7 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3562,28 +3562,21 @@ static void perf_event_for_each(struct perf_event *event,
mutex_unlock(&ctx->mutex);
}
-static int perf_event_period(struct perf_event *event, u64 __user *arg)
-{
- struct perf_event_context *ctx = event->ctx;
- int ret = 0, active;
+struct period_event {
+ struct perf_event *event;
u64 value;
+};
- if (!is_sampling_event(event))
- return -EINVAL;
-
- if (copy_from_user(&value, arg, sizeof(value)))
- return -EFAULT;
-
- if (!value)
- return -EINVAL;
+static int __perf_event_period(void *info)
+{
+ struct period_event *pe = info;
+ struct perf_event *event = pe->event;
+ struct perf_event_context *ctx = event->ctx;
+ u64 value = pe->value;
+ bool active;
- raw_spin_lock_irq(&ctx->lock);
+ raw_spin_lock(&ctx->lock);
if (event->attr.freq) {
- if (value > sysctl_perf_event_sample_rate) {
- ret = -EINVAL;
- goto unlock;
- }
-
event->attr.sample_freq = value;
} else {
event->attr.sample_period = value;
@@ -3602,11 +3595,53 @@ static int perf_event_period(struct perf_event *event, u64 __user *arg)
event->pmu->start(event, PERF_EF_RELOAD);
perf_pmu_enable(ctx->pmu);
}
+ raw_spin_unlock(&ctx->lock);
-unlock:
+ return 0;
+}
+
+static int perf_event_period(struct perf_event *event, u64 __user *arg)
+{
+ struct period_event pe = { .event = event, };
+ struct perf_event_context *ctx = event->ctx;
+ struct task_struct *task;
+ u64 value;
+
+ if (!is_sampling_event(event))
+ return -EINVAL;
+
+ if (copy_from_user(&value, arg, sizeof(value)))
+ return -EFAULT;
+
+ if (!value)
+ return -EINVAL;
+
+ if (event->attr.freq && value > sysctl_perf_event_sample_rate)
+ return -EINVAL;
+
+ task = ctx->task;
+ pe.value = value;
+
+ if (!task) {
+ cpu_function_call(event->cpu, __perf_event_period, &pe);
+ return 0;
+ }
+
+retry:
+ if (!task_function_call(task, __perf_event_period, &pe))
+ return 0;
+
+ raw_spin_lock_irq(&ctx->lock);
+ if (ctx->is_active) {
+ raw_spin_unlock_irq(&ctx->lock);
+ task = ctx->task;
+ goto retry;
+ }
+
+ __perf_event_period(&pe);
raw_spin_unlock_irq(&ctx->lock);
- return ret;
+ return 0;
}
static const struct file_operations perf_fops;
@@ -4218,12 +4253,20 @@ static const struct file_operations perf_fops = {
* to user-space before waking everybody up.
*/
+static inline struct fasync_struct **perf_event_fasync(struct perf_event *event)
+{
+ /* only the parent has fasync state */
+ if (event->parent)
+ event = event->parent;
+ return &event->fasync;
+}
+
void perf_event_wakeup(struct perf_event *event)
{
ring_buffer_wakeup(event);
if (event->pending_kill) {
- kill_fasync(&event->fasync, SIGIO, event->pending_kill);
+ kill_fasync(perf_event_fasync(event), SIGIO, event->pending_kill);
event->pending_kill = 0;
}
}
@@ -5432,7 +5475,7 @@ static int __perf_event_overflow(struct perf_event *event,
else
perf_event_output(event, data, regs);
- if (event->fasync && event->pending_kill) {
+ if (*perf_event_fasync(event) && event->pending_kill) {
event->pending_wakeup = 1;
irq_work_queue(&event->pending);
}