projects
/
deliverable
/
lttng-modules.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Perf counter support: check if busy
[deliverable/lttng-modules.git]
/
lttng-context-perf-counters.c
diff --git
a/lttng-context-perf-counters.c
b/lttng-context-perf-counters.c
index 005c651039e045fb6cb34142b5f8eb355497b515..2f131d61e32f2cdbd4f7b152b478f7c60e3be6c2 100644
(file)
--- a/
lttng-context-perf-counters.c
+++ b/
lttng-context-perf-counters.c
@@
-37,8
+37,12
@@
void perf_counter_record(struct lttng_ctx_field *field,
event = field->u.perf_counter->e[ctx->cpu];
if (likely(event)) {
event = field->u.perf_counter->e[ctx->cpu];
if (likely(event)) {
- event->pmu->read(event);
- value = local64_read(&event->count);
+ if (unlikely(event->state == PERF_EVENT_STATE_ERROR)) {
+ value = 0;
+ } else {
+ event->pmu->read(event);
+ value = local64_read(&event->count);
+ }
} else {
/*
* Perf chooses not to be clever and not to support enabling a
} else {
/*
* Perf chooses not to be clever and not to support enabling a
@@
-114,6
+118,10
@@
int __cpuinit lttng_perf_counter_cpu_hp_callback(struct notifier_block *nb,
cpu, NULL, overflow_callback);
if (!pevent || IS_ERR(pevent))
return NOTIFY_BAD;
cpu, NULL, overflow_callback);
if (!pevent || IS_ERR(pevent))
return NOTIFY_BAD;
+ if (pevent->state == PERF_EVENT_STATE_ERROR) {
+ perf_event_release_kernel(pevent);
+ return NOTIFY_BAD;
+ }
barrier(); /* Create perf counter before setting event */
events[cpu] = pevent;
break;
barrier(); /* Create perf counter before setting event */
events[cpu] = pevent;
break;
@@
-200,6
+208,10
@@
int lttng_add_perf_counter_to_ctx(uint32_t type,
ret = -EINVAL;
goto counter_error;
}
ret = -EINVAL;
goto counter_error;
}
+ if (events[cpu]->state == PERF_EVENT_STATE_ERROR) {
+ ret = -EBUSY;
+ goto counter_busy;
+ }
}
put_online_cpus();
}
put_online_cpus();
@@
-221,6
+233,7
@@
int lttng_add_perf_counter_to_ctx(uint32_t type,
wrapper_vmalloc_sync_all();
return 0;
wrapper_vmalloc_sync_all();
return 0;
+counter_busy:
counter_error:
for_each_online_cpu(cpu) {
if (events[cpu] && !IS_ERR(events[cpu]))
counter_error:
for_each_online_cpu(cpu) {
if (events[cpu] && !IS_ERR(events[cpu]))
This page took
0.035934 seconds
and
5
git commands to generate.