From patchwork Fri Oct 27 23:38:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 10030831 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4F7E8602D6 for ; Fri, 27 Oct 2017 23:44:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2202E22AFC for ; Fri, 27 Oct 2017 23:44:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1325726E96; Fri, 27 Oct 2017 23:44:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8144522AFC for ; Fri, 27 Oct 2017 23:44:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Mime-Version:Message-Id:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=50Z5EzsTnPeGXaqcZP7EMzwOdevcLQsozgwU/ACkNNQ=; b=XqJwm+/KGu3bFV ehdeNTth6hmWS2R5YWCfdNSEjDwfWAyTFoKiUkYKOvizCjr97fIAYiORgZWiSaB0yzAMSfo/+85Rm LngX+jMF7qQoqpE6ymw5TFwrp1BrPBRtBLOYKvPagaJkVVehvXoqAeVnnrfCWHi++/i39ttry7t4D FhAbBFJFDVSw5sCK6KaI9s4TRAbfgjb0PCohHh3czlHDDdk1HsPDxuU2bQZxebTvCohNp9eBjEx3/ HmOgSss8jTyZtlmkjC+GQlyRC/5iX2mnVmlntv25sxb6Y55+vs0ehGZZB6gkFVsGiASBo1rgyybht Fv4aU9Xz++ZOOVL6bufA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e8EIg-0003Hh-HE; Fri, 27 Oct 2017 23:44:30 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e8ED7-0000ym-4Y for linux-arm-kernel@lists.infradead.org; Fri, 27 Oct 2017 23:38:50 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BB0F91596; Fri, 27 Oct 2017 16:38:24 -0700 (PDT) Received: from dupont (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0F8EE3F25D; Fri, 27 Oct 2017 16:38:21 -0700 (PDT) Date: Fri, 27 Oct 2017 18:38:20 -0500 From: Kim Phillips To: Arnaldo Carvalho de Melo , Mark Rutland , Will Deacon Subject: [PATCH 2/2] perf tools: arm-spe: add customized strerror function Message-Id: <20171027183820.8f7a789c322fca10db8f9b3f@arm.com> Organization: Arm X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171027_163845_536136_13B0B899 X-CRM114-Status: GOOD ( 12.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robh@kernel.org, Andi Kleen , mathieu.poirier@linaro.org, pawel.moll@arm.com, suzuki.poulose@arm.com, marc.zyngier@arm.com, linux-kernel@vger.kernel.org, Adrian Hunter , alexander.shishkin@linux.intel.com, peterz@infradead.org, mingo@redhat.com, Jiri Olsa , tglx@linutronix.de, Wang Nan , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add a routine to try to help the user determine how they're supposed to use the SPE driver. Example #1: Trouble setting sample rate: $ sudo ./perf record -e arm_spe_0/ts_enable=1,pa_enable=1/ -F 1 true Error: required sample period missing. Use '--count=' $ ./perf record -e arm_spe_0/ts_enable=1/ -c 0 true Error: required sample period missing. Use '--count=' $ ./perf record -e arm_spe_0/ts_enable=1/ -c 1 true [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.009 MB perf.data ] $ Example #2: Non-privileged user tries to obtain physical address data: $ ./perf record -e arm_spe_0/ts_enable=1,pa_enable=1/ -c 1 true Error: arm_spe_0/ts_enable=1,pa_enable=1/:u: physical address and time, and EL1 context ID data collection require admin privileges $ sudo ./perf record -e arm_spe_0/ts_enable=1,pa_enable=1/ -c 1 true [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.054 MB perf.data ] $ Example #3: Trying to exclude idle profiling: $ sudo ./perf record -e arm_spe_0/ts_enable=1,pa_enable=1/I -c 1 true Error: arm_spe_0/ts_enable=1,pa_enable=1/I: Cannot exclude profiling when idle, try without //I $ Signed-off-by: Kim Phillips --- DO NOT APPLY: This should really be an RFC, since depends on this RFC: https://www.spinics.net/lists/arm-kernel/msg613725.html but providing as part of SPE tool patch anyway in case it helps resolve the RFC. tools/perf/arch/arm64/util/evsel.c | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tools/perf/arch/arm64/util/evsel.c b/tools/perf/arch/arm64/util/evsel.c index e09cbb5d1518..222bf761d11b 100644 --- a/tools/perf/arch/arm64/util/evsel.c +++ b/tools/perf/arch/arm64/util/evsel.c @@ -70,6 +70,44 @@ target__has_task(target), target__has_cpu(target), target__none(target) return 0; } +#ifdef HAVE_AUXTRACE_SUPPORT +static int strerror_arm_spe(struct perf_evsel *evsel, + struct target *target __maybe_unused, + int err, char *msg, size_t size) +{ + const char *evname = perf_evsel__name(evsel); + struct perf_event_attr *attr = &evsel->attr; + + switch (err) { + case EOPNOTSUPP: + if (attr->exclude_idle) + return scnprintf(msg, size, + "%s: Cannot exclude profiling when idle, try without //I\n", evname); + return scnprintf(msg, size, "%s: unsupported error code:\n" + "EITHER this driver may not support a possibly h/w-implementation\n" + "\tdefined event filter bit that has been set in the PMSEVFR register\n" + "OR h/w doesn't support filtering by one or more of: latency,\n" + "\toperation type, or events\n", evname); + break; + case EACCES: + if (strstr(evname, "pa_enable") || strstr(evname, "pct_enable")) + return scnprintf(msg, size, + "%s: physical address and time, and EL1 context ID data collection\n" + "\trequire admin privileges\n", evname); + break; + case EINVAL: + if (attr->freq || !attr->sample_period) + return scnprintf(msg, size, + "required sample period missing. Use '--count='\n"); + break; + default: + break; + } + + return 0; +} +#endif + int perf_evsel__open_strerror_arch(struct perf_evsel *evsel, struct target *target, int err, char *msg, size_t size) @@ -80,5 +118,10 @@ int perf_evsel__open_strerror_arch(struct perf_evsel *evsel, if (strstarts(evname, "ccn")) return ccn_strerror(evsel, target, err, msg, size); +#ifdef HAVE_AUXTRACE_SUPPORT + if (strstarts(evname, "arm_spe")) + return strerror_arm_spe(evsel, target, err, msg, size); +#endif + return 0; }