[PATCH v3 29/46] perf/x86/intel/cmt: add error handling to intel_cmt_event_read
From: David Carrillo-Cisneros
Date: Sat Oct 29 2016 - 20:48:00 EST
First part of intel_cmt_event_read. Error conditions and placeholder
for oncoming chunks.
Signed-off-by: David Carrillo-Cisneros <davidcc@xxxxxxxxxx>
---
arch/x86/events/intel/cmt.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/arch/x86/events/intel/cmt.c b/arch/x86/events/intel/cmt.c
index ef1000f..f5ab48e 100644
--- a/arch/x86/events/intel/cmt.c
+++ b/arch/x86/events/intel/cmt.c
@@ -1320,6 +1320,31 @@ static struct monr *monr_next_descendant_post(struct monr *pos,
static int intel_cmt_event_read(struct perf_event *event)
{
+ struct monr *monr = monr_from_event(event);
+
+ /*
+ * preemption disabled since called holding
+ * event's ctx->lock raw_spin_lock.
+ */
+ WARN_ON_ONCE(!preempt_count());
+
+ /* terminated monrs are zombies and must not be read. */
+ if (WARN_ON_ONCE(monr->flags & CMT_MONR_ZOMBIE))
+ return -ENXIO;
+
+ /*
+ * Only event parent can return a value, everyone else share its
+ * rmid and therefore doesn't track occupancy independently.
+ */
+ if (event->parent) {
+ local64_set(&event->count, 0);
+ return 0;
+ }
+
+ if (event->attach_state & PERF_ATTACH_TASK) {
+ /* To add support in next patches in series */
+ return -ENOTSUPP;
+ }
/* To add support in next patches in series */
return -ENOTSUPP;
}
--
2.8.0.rc3.226.g39d4020