From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757145AbcJ3Apr (ORCPT ); Sat, 29 Oct 2016 20:45:47 -0400 Received: from mail-pf0-f179.google.com ([209.85.192.179]:35197 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755815AbcJ3AkY (ORCPT ); Sat, 29 Oct 2016 20:40:24 -0400 From: David Carrillo-Cisneros To: linux-kernel@vger.kernel.org Cc: "x86@kernel.org" , Ingo Molnar , Thomas Gleixner , Andi Kleen , Kan Liang , Peter Zijlstra , Vegard Nossum , Marcelo Tosatti , Nilay Vaish , Borislav Petkov , Vikas Shivappa , Ravi V Shankar , Fenghua Yu , Paul Turner , Stephane Eranian , David Carrillo-Cisneros Subject: [PATCH v3 29/46] perf/x86/intel/cmt: add error handling to intel_cmt_event_read Date: Sat, 29 Oct 2016 17:38:26 -0700 Message-Id: <1477787923-61185-30-git-send-email-davidcc@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1477787923-61185-1-git-send-email-davidcc@google.com> References: <1477787923-61185-1-git-send-email-davidcc@google.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org First part of intel_cmt_event_read. Error conditions and placeholder for oncoming chunks. Signed-off-by: David Carrillo-Cisneros --- 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