From patchwork Tue Oct 24 08:04:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 10023613 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 C892560381 for ; Tue, 24 Oct 2017 08:04:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6AD822230 for ; Tue, 24 Oct 2017 08:04:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7E7724151; Tue, 24 Oct 2017 08:04:39 +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=ham 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 EE44F22230 for ; Tue, 24 Oct 2017 08:04:38 +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=4HbyIXBbLHQNaBU33LRT9SOwCvUfWARzWcJVEaKTYiw=; b=qYwuneIfqSvV9+ bQLSuJQ7Y2fNfCbrOoNTIkQJOLqYTV0ZCDWZh9Mo9NZxYIrA/ZkGzeeELx2vO/cL/Iix6y1tytDm0 7AHhPl6Y0Pwx4aVsmOlAPfk9aQAn9eq2a7d2kM1CHDBeA3KWaBeOw0fDsAwJdFZ6vtA4RO2A3Ixo4 ZzHsJslDoRSaXacJdgS9B3XjivHInFmcf5FHUr5zswN+zb9DVu9qU9bixaw3CHLxXzRyVKFXPOitR k7KiReja2clL1sj9naWG9dTnW9bzw0++N/1ZvpLK4i/zJfENKkWOIP6pKfGgustvlzdzi+/N08zTq o/7/c8TvnPdNi8BBU2wg==; 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 1e6uCN-0000na-Kv; Tue, 24 Oct 2017 08:04:31 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e6uCK-0000mB-4B for linux-arm-kernel@lists.infradead.org; Tue, 24 Oct 2017 08:04:30 +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 4ADA980D; Tue, 24 Oct 2017 01:04:07 -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 186E63F3E1; Tue, 24 Oct 2017 01:04:06 -0700 (PDT) Date: Tue, 24 Oct 2017 03:04:04 -0500 From: Kim Phillips To: Arnaldo Carvalho de Melo Subject: [RFC 1/3] perf tool: Introduce arch-specific supplemental perf open strerror capability Message-Id: <20171024030404.ec366ec2d9c38910ccd84ba5@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-20171024_010428_183697_A0577E3C X-CRM114-Status: GOOD ( 15.11 ) 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: mark.rutland@arm.com, robh@kernel.org, mathieu.poirier@linaro.org, pawel.moll@arm.com, suzuki.poulose@arm.com, marc.zyngier@arm.com, Will Deacon , linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com, peterz@infradead.org, mingo@redhat.com, tglx@linutronix.de, 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 Introduce new tools/perf/arch/*/util/evsel.c:perf_evsel__suppl_strerror() so each arch can start to customize usability for its h/w PMU drivers. Signed-off-by: Kim Phillips --- tools/perf/arch/x86/util/Build | 1 + tools/perf/arch/x86/util/evsel.c | 24 ++++++++++++++++++++++++ tools/perf/util/evsel.c | 21 +++++++++++++++------ tools/perf/util/evsel.h | 2 ++ 4 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 tools/perf/arch/x86/util/evsel.c diff --git a/tools/perf/arch/x86/util/Build b/tools/perf/arch/x86/util/Build index f95e6f46ef0d..90ae9358ec21 100644 --- a/tools/perf/arch/x86/util/Build +++ b/tools/perf/arch/x86/util/Build @@ -4,6 +4,7 @@ libperf-y += pmu.o libperf-y += kvm-stat.o libperf-y += perf_regs.o libperf-y += group.o +libperf-y += evsel.o libperf-$(CONFIG_DWARF) += dwarf-regs.o libperf-$(CONFIG_BPF_PROLOGUE) += dwarf-regs.o diff --git a/tools/perf/arch/x86/util/evsel.c b/tools/perf/arch/x86/util/evsel.c new file mode 100644 index 000000000000..95c623c0119f --- /dev/null +++ b/tools/perf/arch/x86/util/evsel.c @@ -0,0 +1,24 @@ +#include + +#include +#include + +#include "../../util/evsel.h" + +int perf_evsel__suppl_strerror(struct perf_evsel *evsel, + struct target *target __maybe_unused, + int err, char *msg, size_t size) +{ + switch (err) { + case EOPNOTSUPP: + if (evsel->attr.type == PERF_TYPE_HARDWARE) + return scnprintf(msg, size, "%s", + "No hardware sampling interrupt available.\n" + "No APIC? If so then you can boot the kernel with the \"lapic\" boot parameter to force-enable it."); + break; + default: + break; + } + + return 0; +} diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 3ec0aed0bdcb..a6aa18e3a0c2 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -2686,12 +2686,27 @@ static bool find_process(const char *name) return ret ? false : true; } +int __weak perf_evsel__suppl_strerror(struct perf_evsel *evsel __maybe_unused, + struct target *target __maybe_unused, + int err __maybe_unused, + char *msg __maybe_unused, + size_t size __maybe_unused) +{ + return 0; +} + int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target, int err, char *msg, size_t size) { char sbuf[STRERR_BUFSIZE]; int printed = 0; + printed = perf_evsel__suppl_strerror(evsel, target, err, msg, size); + if (printed > 0) { + msg += printed; + size -= printed; + } + switch (err) { case EPERM: case EACCES: @@ -2745,12 +2760,6 @@ int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target, if (evsel->attr.precise_ip) return scnprintf(msg, size, "%s", "\'precise\' request may not be supported. Try removing 'p' modifier."); -#if defined(__i386__) || defined(__x86_64__) - if (evsel->attr.type == PERF_TYPE_HARDWARE) - return scnprintf(msg, size, "%s", - "No hardware sampling interrupt available.\n" - "No APIC? If so then you can boot the kernel with the \"lapic\" boot parameter to force-enable it."); -#endif break; case EBUSY: if (find_process("oprofiled")) diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 77bd310eb0cb..aef759c178aa 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -416,6 +416,8 @@ bool perf_evsel__fallback(struct perf_evsel *evsel, int err, char *msg, size_t msgsize); int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target, int err, char *msg, size_t size); +int perf_evsel__suppl_strerror(struct perf_evsel *evsel, struct target *target, + int err, char *msg, size_t size); static inline int perf_evsel__group_idx(struct perf_evsel *evsel) {