[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1441987205-4021-3-git-send-email-alexander.shishkin@linux.intel.com>
Date: Fri, 11 Sep 2015 19:00:01 +0300
From: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
To: Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Ingo Molnar <mingo@...hat.com>
Cc: linux-kernel@...r.kernel.org, vince@...ter.net, eranian@...gle.com,
johannes@...solutions.net,
Arnaldo Carvalho de Melo <acme@...radead.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Subject: [PATCH RFC v3 2/6] perf: Use extended syscall error reporting
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@...ux.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists