From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753495AbbIKQAl (ORCPT ); Fri, 11 Sep 2015 12:00:41 -0400 Received: from mga11.intel.com ([192.55.52.93]:56661 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753438AbbIKQAj (ORCPT ); Fri, 11 Sep 2015 12:00:39 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,511,1437462000"; d="scan'208";a="767124209" From: Alexander Shishkin To: Peter Zijlstra , Ingo Molnar Cc: linux-kernel@vger.kernel.org, vince@deater.net, eranian@google.com, johannes@sipsolutions.net, Arnaldo Carvalho de Melo , Alexander Shishkin Subject: [PATCH RFC v3 3/6] perf/x86: Annotate a BTS error with extended error reporting Date: Fri, 11 Sep 2015 19:00:02 +0300 Message-Id: <1441987205-4021-4-git-send-email-alexander.shishkin@linux.intel.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: <1441987205-4021-1-git-send-email-alexander.shishkin@linux.intel.com> References: <1441987205-4021-1-git-send-email-alexander.shishkin@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Old-style BTS driver does not support kernel tracing, which normally would be visible to userspace as -EOPNOTSUPP, or from the tool's user's perspective: > # perf record -e branches -c1 ls > Error: > No hardware sampling interrupt available. > No APIC? If so then you can boot the kernel with the "lapic" boot parameter to force-enable it. but with the new way of reporting errors, they will see the following: > # perf record -e branches -c1 ls > Error: > Syscall returned -95, becasue BTS sampling not allowed for kernel space. > Offending attribute field: "exclude_kernel" which is somewhat more to the point of what has actually transpired. Signed-off-by: Alexander Shishkin --- arch/x86/kernel/cpu/perf_event.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c index f56cf074d0..e3d953ef49 100644 --- a/arch/x86/kernel/cpu/perf_event.c +++ b/arch/x86/kernel/cpu/perf_event.c @@ -12,6 +12,8 @@ * For licencing details see kernel-base/COPYING */ +#define EXTERR_MODNAME "perf/x86" + #include #include #include @@ -426,7 +428,8 @@ int x86_setup_perfctr(struct perf_event *event) /* BTS is currently only allowed for user-mode. */ if (!attr->exclude_kernel) - return -EOPNOTSUPP; + return perf_err(-EOPNOTSUPP, exclude_kernel, + "BTS sampling not allowed for kernel space"); /* disallow bts if conflicting events are present */ if (x86_add_exclusive(x86_lbr_exclusive_lbr)) -- 2.5.1