From: Alexander Shishkin <alexander.shishkin@linux.intel.com>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>, Ingo Molnar <mingo@redhat.com>
Cc: linux-kernel@vger.kernel.org, vince@deater.net,
eranian@google.com, johannes@sipsolutions.net,
Arnaldo Carvalho de Melo <acme@infradead.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>
Subject: [PATCH RFC v3 2/6] perf: Use extended syscall error reporting
Date: Fri, 11 Sep 2015 19:00:01 +0300 [thread overview]
Message-ID: <1441987205-4021-3-git-send-email-alexander.shishkin@linux.intel.com> (raw)
In-Reply-To: <1441987205-4021-1-git-send-email-alexander.shishkin@linux.intel.com>
This patch makes use of the extended syscall error reporting
infrastructure to relay error messages that result from perf_event_open()
attribute validation. On top of the default error report bits, it also
transfers the name of the attribute field that triggered the error.
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
---
include/linux/perf_event.h | 14 ++++++++++++++
kernel/events/core.c | 17 ++++++++++++++++-
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 2027809433..eb63074012 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -16,6 +16,20 @@
#include <uapi/linux/perf_event.h>
+#include <linux/exterr.h>
+
+struct perf_ext_err_site {
+ struct ext_err_site site;
+ const char *attr_field;
+};
+
+#define perf_err(__c, __a, __m) \
+ ({ /* make sure it's a real field before stringifying it */ \
+ struct perf_event_attr __x; (void)__x.__a; \
+ ext_err(perf, __c, __m, \
+ .attr_field = __stringify(__a)); \
+ })
+
/*
* Kernel-internal data types and definitions:
*/
diff --git a/kernel/events/core.c b/kernel/events/core.c
index ae16867670..a714f0602b 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -9,6 +9,8 @@
* For licensing details see kernel-base/COPYING
*/
+#define EXTERR_MODNAME "perf"
+
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/cpu.h>
@@ -44,11 +46,24 @@
#include <linux/compat.h>
#include <linux/bpf.h>
#include <linux/filter.h>
+#include <linux/exterr.h>
#include "internal.h"
#include <asm/irq_regs.h>
+static char *perf_exterr_format(void *site)
+{
+ struct perf_ext_err_site *psite = site;
+ char *output;
+
+ output = kasprintf(GFP_KERNEL, "\t\"attr_field\": \"%s\"\n",
+ psite->attr_field);
+ return output;
+}
+
+DECLARE_EXTERR_DOMAIN(perf, perf_exterr_format);
+
static struct workqueue_struct *perf_wq;
typedef int (*remote_function_f)(void *);
@@ -8352,7 +8367,7 @@ err_group_fd:
fdput(group);
err_fd:
put_unused_fd(event_fd);
- return err;
+ return ext_err_errno(err);
}
/**
--
2.5.1
next prev parent reply other threads:[~2015-09-11 16:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-11 15:59 [PATCH RFC v3 0/6] Introduce extended syscall error reporting Alexander Shishkin
2015-09-11 16:00 ` [PATCH RFC v3 1/6] exterr: " Alexander Shishkin
2015-09-14 20:19 ` Jonathan Corbet
2015-09-15 14:15 ` Alexander Shishkin
2015-09-15 14:31 ` Johannes Berg
2015-09-15 15:24 ` Alexander Shishkin
2015-09-15 16:35 ` Jonathan Corbet
2015-09-15 17:02 ` Johannes Berg
2015-09-14 21:59 ` Jonathan Corbet
2016-01-11 10:34 ` Alexander Shishkin
2015-09-11 16:00 ` Alexander Shishkin [this message]
2015-09-11 16:00 ` [PATCH RFC v3 3/6] perf/x86: Annotate a BTS error with extended " Alexander Shishkin
2015-09-11 16:00 ` [PATCH RFC v3 4/6] perf tools: Add a simple JSON parser Alexander Shishkin
2015-09-11 16:00 ` [PATCH RFC v3 5/6] perf tools: Add userspace counterpart for extended error reporting Alexander Shishkin
2015-09-11 16:00 ` [PATCH RFC v3 6/6] perf tools: Use extended syscall " Alexander Shishkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1441987205-4021-3-git-send-email-alexander.shishkin@linux.intel.com \
--to=alexander.shishkin@linux.intel.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@infradead.org \
--cc=eranian@google.com \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=vince@deater.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).