aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_ds.c2
-rw-r--r--include/linux/perf_event.h4
-rw-r--r--kernel/events/core.c26
-rw-r--r--kernel/events/ring_buffer.c19
4 files changed, 23 insertions, 28 deletions
diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c
index 0941f93f2940..1b1ef3addcfd 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_ds.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c
@@ -340,7 +340,7 @@ static int intel_pmu_drain_bts_buffer(void)
340 */ 340 */
341 perf_prepare_sample(&header, &data, event, &regs); 341 perf_prepare_sample(&header, &data, event, &regs);
342 342
343 if (perf_output_begin(&handle, event, header.size * (top - at), 1)) 343 if (perf_output_begin(&handle, event, header.size * (top - at)))
344 return 1; 344 return 1;
345 345
346 for (; at < top; at++) { 346 for (; at < top; at++) {
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 0946a8bc098d..771b0b2845e4 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -925,7 +925,6 @@ struct perf_output_handle {
925 unsigned long size; 925 unsigned long size;
926 void *addr; 926 void *addr;
927 int page; 927 int page;
928 int sample;
929}; 928};
930 929
931#ifdef CONFIG_PERF_EVENTS 930#ifdef CONFIG_PERF_EVENTS
@@ -1117,8 +1116,7 @@ extern void perf_bp_event(struct perf_event *event, void *data);
1117#endif 1116#endif
1118 1117
1119extern int perf_output_begin(struct perf_output_handle *handle, 1118extern int perf_output_begin(struct perf_output_handle *handle,
1120 struct perf_event *event, unsigned int size, 1119 struct perf_event *event, unsigned int size);
1121 int sample);
1122extern void perf_output_end(struct perf_output_handle *handle); 1120extern void perf_output_end(struct perf_output_handle *handle);
1123extern void perf_output_copy(struct perf_output_handle *handle, 1121extern void perf_output_copy(struct perf_output_handle *handle,
1124 const void *buf, unsigned int len); 1122 const void *buf, unsigned int len);
diff --git a/kernel/events/core.c b/kernel/events/core.c
index dbd1ca75bd3c..81de28dcca8c 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3928,6 +3928,20 @@ void perf_output_sample(struct perf_output_handle *handle,
3928 perf_output_put(handle, raw); 3928 perf_output_put(handle, raw);
3929 } 3929 }
3930 } 3930 }
3931
3932 if (!event->attr.watermark) {
3933 int wakeup_events = event->attr.wakeup_events;
3934
3935 if (wakeup_events) {
3936 struct ring_buffer *rb = handle->rb;
3937 int events = local_inc_return(&rb->events);
3938
3939 if (events >= wakeup_events) {
3940 local_sub(wakeup_events, &rb->events);
3941 local_inc(&rb->wakeup);
3942 }
3943 }
3944 }
3931} 3945}
3932 3946
3933void perf_prepare_sample(struct perf_event_header *header, 3947void perf_prepare_sample(struct perf_event_header *header,
@@ -3984,7 +3998,7 @@ static void perf_event_output(struct perf_event *event,
3984 3998
3985 perf_prepare_sample(&header, data, event, regs); 3999 perf_prepare_sample(&header, data, event, regs);
3986 4000
3987 if (perf_output_begin(&handle, event, header.size, 1)) 4001 if (perf_output_begin(&handle, event, header.size))
3988 goto exit; 4002 goto exit;
3989 4003
3990 perf_output_sample(&handle, &header, data, event); 4004 perf_output_sample(&handle, &header, data, event);
@@ -4024,7 +4038,7 @@ perf_event_read_event(struct perf_event *event,
4024 int ret; 4038 int ret;
4025 4039
4026 perf_event_header__init_id(&read_event.header, &sample, event); 4040 perf_event_header__init_id(&read_event.header, &sample, event);
4027 ret = perf_output_begin(&handle, event, read_event.header.size, 0); 4041 ret = perf_output_begin(&handle, event, read_event.header.size);
4028 if (ret) 4042 if (ret)
4029 return; 4043 return;
4030 4044
@@ -4067,7 +4081,7 @@ static void perf_event_task_output(struct perf_event *event,
4067 perf_event_header__init_id(&task_event->event_id.header, &sample, event); 4081 perf_event_header__init_id(&task_event->event_id.header, &sample, event);
4068 4082
4069 ret = perf_output_begin(&handle, event, 4083 ret = perf_output_begin(&handle, event,
4070 task_event->event_id.header.size, 0); 4084 task_event->event_id.header.size);
4071 if (ret) 4085 if (ret)
4072 goto out; 4086 goto out;
4073 4087
@@ -4204,7 +4218,7 @@ static void perf_event_comm_output(struct perf_event *event,
4204 4218
4205 perf_event_header__init_id(&comm_event->event_id.header, &sample, event); 4219 perf_event_header__init_id(&comm_event->event_id.header, &sample, event);
4206 ret = perf_output_begin(&handle, event, 4220 ret = perf_output_begin(&handle, event,
4207 comm_event->event_id.header.size, 0); 4221 comm_event->event_id.header.size);
4208 4222
4209 if (ret) 4223 if (ret)
4210 goto out; 4224 goto out;
@@ -4351,7 +4365,7 @@ static void perf_event_mmap_output(struct perf_event *event,
4351 4365
4352 perf_event_header__init_id(&mmap_event->event_id.header, &sample, event); 4366 perf_event_header__init_id(&mmap_event->event_id.header, &sample, event);
4353 ret = perf_output_begin(&handle, event, 4367 ret = perf_output_begin(&handle, event,
4354 mmap_event->event_id.header.size, 0); 4368 mmap_event->event_id.header.size);
4355 if (ret) 4369 if (ret)
4356 goto out; 4370 goto out;
4357 4371
@@ -4546,7 +4560,7 @@ static void perf_log_throttle(struct perf_event *event, int enable)
4546 perf_event_header__init_id(&throttle_event.header, &sample, event); 4560 perf_event_header__init_id(&throttle_event.header, &sample, event);
4547 4561
4548 ret = perf_output_begin(&handle, event, 4562 ret = perf_output_begin(&handle, event,
4549 throttle_event.header.size, 0); 4563 throttle_event.header.size);
4550 if (ret) 4564 if (ret)
4551 return; 4565 return;
4552 4566
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 8b3b73630fa4..a2a29205cc0f 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -98,8 +98,7 @@ out:
98} 98}
99 99
100int perf_output_begin(struct perf_output_handle *handle, 100int perf_output_begin(struct perf_output_handle *handle,
101 struct perf_event *event, unsigned int size, 101 struct perf_event *event, unsigned int size)
102 int sample)
103{ 102{
104 struct ring_buffer *rb; 103 struct ring_buffer *rb;
105 unsigned long tail, offset, head; 104 unsigned long tail, offset, head;
@@ -124,7 +123,6 @@ int perf_output_begin(struct perf_output_handle *handle,
124 123
125 handle->rb = rb; 124 handle->rb = rb;
126 handle->event = event; 125 handle->event = event;
127 handle->sample = sample;
128 126
129 if (!rb->nr_pages) 127 if (!rb->nr_pages)
130 goto out; 128 goto out;
@@ -192,21 +190,6 @@ void perf_output_copy(struct perf_output_handle *handle,
192 190
193void perf_output_end(struct perf_output_handle *handle) 191void perf_output_end(struct perf_output_handle *handle)
194{ 192{
195 struct perf_event *event = handle->event;
196 struct ring_buffer *rb = handle->rb;
197
198 if (handle->sample && !event->attr.watermark) {
199 int wakeup_events = event->attr.wakeup_events;
200
201 if (wakeup_events) {
202 int events = local_inc_return(&rb->events);
203 if (events >= wakeup_events) {
204 local_sub(wakeup_events, &rb->events);
205 local_inc(&rb->wakeup);
206 }
207 }
208 }
209
210 perf_output_put_handle(handle); 193 perf_output_put_handle(handle);
211 rcu_read_unlock(); 194 rcu_read_unlock();
212} 195}