All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V3 0/6] perf: Driver specific configuration for PMU
@ 2016-07-28 21:42 ` Mathieu Poirier
  0 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-07-28 21:42 UTC (permalink / raw)
  To: acme, jolsa; +Cc: peterz, mingo, linux-kernel, linux-arm-kernel

This patchset adds the possiblity of specifying PMU driver configuration
directly from the perf command line.  Anything that falls within the
event specifiers '/.../' and that is preceded by the '@' symbol is
treated as a configurable.  Two formats are supported, @cfg and
@cfg=config.

For example:

perf record -e some_event/@cfg1/ ...

or

perf record -e some_event/@cfg2=config/ ...

or

perf record -e some_event/@cfg1,@cfg2=config/ ...

The above are all valid configuration and will see the strings 'cfg1'
and 'cfg2=config' sent to the PMU driver for parsing and interpretation
using the existing ioctl() mechanism.

The primary customers for this feature are the CoreSight drivers where
the selection of a sink (where trace data is accumulated) needs to be
done in a previous, and separated step, from the launching of the perf
command.

As such something that used to be a two-step process:

# echo 1 > /sys/bus/coresight/devices/20070000.etr/enable_sink
# perf record -e cs_etm//u --per-thread  uname

is integrated in a single command:

# perf record -e cs_etm/@sink=20070000.etr/u --per-thread  uname

The patches include both the kernel and user space part so that the
solution is complete and found in a single place.

It is based on [1] and assumes this set [2] has been applied.  I will
be happy to merge the patchsets if it easier for maintainers to apply,
simply let me know.

Thanks,
Mathieu

Changes for V3:
- Added comment for function drv_str() that explains the reason for
  keeping the entire token intact.
- Added driver config terms to the existing list of config terms.
- Added documenation for driver specific configuration.
- Pushing PMU driver configuration for 'perf stat' as well.  
- Preventing users from selecting a sink from sysFS _and_ perf.

Changes for V2:
- Rebased to [1] as per Jiri's request.

[1]. git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git perf/core
[2]. https://lkml.org/lkml/2016/7/20/519

Mathieu Poirier (6):
  perf/core: Adding PMU driver specific configuration
  perf: Passing struct perf_event to function setup_aux()
  perf tools: add infrastructure for PMU specific configuration
  perf tools: pushing driver configuration down to the kernel
  coresight: adding sink parameter to function coresight_build_path()
  coresight: etm-perf: incorporating sink definition from cmd line

 arch/x86/events/intel/bts.c                      |   4 +-
 arch/x86/events/intel/pt.c                       |   5 +-
 drivers/hwtracing/coresight/coresight-etm-perf.c | 105 ++++++++++++++++++++++-
 drivers/hwtracing/coresight/coresight-priv.h     |   3 +-
 drivers/hwtracing/coresight/coresight.c          |  43 +++++++---
 include/linux/perf_event.h                       |  11 ++-
 include/uapi/linux/perf_event.h                  |   1 +
 kernel/events/core.c                             |  16 ++++
 kernel/events/ring_buffer.c                      |   2 +-
 tools/include/uapi/linux/perf_event.h            |   1 +
 tools/perf/Documentation/perf-record.txt         |  12 +++
 tools/perf/builtin-record.c                      |   9 ++
 tools/perf/builtin-stat.c                        |   8 ++
 tools/perf/util/evlist.c                         |  21 +++++
 tools/perf/util/evlist.h                         |   3 +
 tools/perf/util/evsel.c                          |  24 ++++++
 tools/perf/util/evsel.h                          |   5 ++
 tools/perf/util/parse-events.c                   |   7 +-
 tools/perf/util/parse-events.h                   |   1 +
 tools/perf/util/parse-events.l                   |  22 +++++
 tools/perf/util/parse-events.y                   |  11 +++
 21 files changed, 290 insertions(+), 24 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH V3 0/6] perf: Driver specific configuration for PMU
@ 2016-07-28 21:42 ` Mathieu Poirier
  0 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-07-28 21:42 UTC (permalink / raw)
  To: linux-arm-kernel

This patchset adds the possiblity of specifying PMU driver configuration
directly from the perf command line.  Anything that falls within the
event specifiers '/.../' and that is preceded by the '@' symbol is
treated as a configurable.  Two formats are supported, @cfg and
@cfg=config.

For example:

perf record -e some_event/@cfg1/ ...

or

perf record -e some_event/@cfg2=config/ ...

or

perf record -e some_event/@cfg1, at cfg2=config/ ...

The above are all valid configuration and will see the strings 'cfg1'
and 'cfg2=config' sent to the PMU driver for parsing and interpretation
using the existing ioctl() mechanism.

The primary customers for this feature are the CoreSight drivers where
the selection of a sink (where trace data is accumulated) needs to be
done in a previous, and separated step, from the launching of the perf
command.

As such something that used to be a two-step process:

# echo 1 > /sys/bus/coresight/devices/20070000.etr/enable_sink
# perf record -e cs_etm//u --per-thread  uname

is integrated in a single command:

# perf record -e cs_etm/@sink=20070000.etr/u --per-thread  uname

The patches include both the kernel and user space part so that the
solution is complete and found in a single place.

It is based on [1] and assumes this set [2] has been applied.  I will
be happy to merge the patchsets if it easier for maintainers to apply,
simply let me know.

Thanks,
Mathieu

Changes for V3:
- Added comment for function drv_str() that explains the reason for
  keeping the entire token intact.
- Added driver config terms to the existing list of config terms.
- Added documenation for driver specific configuration.
- Pushing PMU driver configuration for 'perf stat' as well.  
- Preventing users from selecting a sink from sysFS _and_ perf.

Changes for V2:
- Rebased to [1] as per Jiri's request.

[1]. git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git perf/core
[2]. https://lkml.org/lkml/2016/7/20/519

Mathieu Poirier (6):
  perf/core: Adding PMU driver specific configuration
  perf: Passing struct perf_event to function setup_aux()
  perf tools: add infrastructure for PMU specific configuration
  perf tools: pushing driver configuration down to the kernel
  coresight: adding sink parameter to function coresight_build_path()
  coresight: etm-perf: incorporating sink definition from cmd line

 arch/x86/events/intel/bts.c                      |   4 +-
 arch/x86/events/intel/pt.c                       |   5 +-
 drivers/hwtracing/coresight/coresight-etm-perf.c | 105 ++++++++++++++++++++++-
 drivers/hwtracing/coresight/coresight-priv.h     |   3 +-
 drivers/hwtracing/coresight/coresight.c          |  43 +++++++---
 include/linux/perf_event.h                       |  11 ++-
 include/uapi/linux/perf_event.h                  |   1 +
 kernel/events/core.c                             |  16 ++++
 kernel/events/ring_buffer.c                      |   2 +-
 tools/include/uapi/linux/perf_event.h            |   1 +
 tools/perf/Documentation/perf-record.txt         |  12 +++
 tools/perf/builtin-record.c                      |   9 ++
 tools/perf/builtin-stat.c                        |   8 ++
 tools/perf/util/evlist.c                         |  21 +++++
 tools/perf/util/evlist.h                         |   3 +
 tools/perf/util/evsel.c                          |  24 ++++++
 tools/perf/util/evsel.h                          |   5 ++
 tools/perf/util/parse-events.c                   |   7 +-
 tools/perf/util/parse-events.h                   |   1 +
 tools/perf/util/parse-events.l                   |  22 +++++
 tools/perf/util/parse-events.y                   |  11 +++
 21 files changed, 290 insertions(+), 24 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH V3 1/6] perf/core: Adding PMU driver specific configuration
  2016-07-28 21:42 ` Mathieu Poirier
@ 2016-07-28 21:42   ` Mathieu Poirier
  -1 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-07-28 21:42 UTC (permalink / raw)
  To: acme, jolsa
  Cc: peterz, mingo, linux-kernel, linux-arm-kernel, Mathieu Poirier

This patch somewhat mimics the work done on address filters to
add the infrastructure needed to pass PMU specific HW
configuration to the driver before a session starts.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 include/linux/perf_event.h            |  9 +++++++++
 include/uapi/linux/perf_event.h       |  1 +
 kernel/events/core.c                  | 16 ++++++++++++++++
 tools/include/uapi/linux/perf_event.h |  1 +
 4 files changed, 27 insertions(+)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 7921f4f20a58..59d61a12cf9d 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -168,6 +168,9 @@ struct hw_perf_event {
 	/* Last sync'ed generation of filters */
 	unsigned long			addr_filters_gen;
 
+	/* HW specific configuration */
+	void				*drv_configs;
+
 /*
  * hw_perf_event::state flags; used to track the PERF_EF_* state.
  */
@@ -442,6 +445,12 @@ struct pmu {
 	 * Filter events for PMU-specific reasons.
 	 */
 	int (*filter_match)		(struct perf_event *event); /* optional */
+
+	/*
+	 * PMU driver specific configuration.
+	 */
+	int (*set_drv_configs)		(struct perf_event *event,
+					 void __user *arg); /* optional */
 };
 
 /**
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index c66a485a24ac..90fbc5fd3925 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -407,6 +407,7 @@ struct perf_event_attr {
 #define PERF_EVENT_IOC_ID		_IOR('$', 7, __u64 *)
 #define PERF_EVENT_IOC_SET_BPF		_IOW('$', 8, __u32)
 #define PERF_EVENT_IOC_PAUSE_OUTPUT	_IOW('$', 9, __u32)
+#define PERF_EVENT_IOC_SET_DRV_CONFIGS	_IOW('$', 10, char *)
 
 enum perf_event_ioc_flags {
 	PERF_IOC_FLAG_GROUP		= 1U << 0,
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 79dae188a987..9208e6ec036f 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -4457,6 +4457,8 @@ static int perf_event_set_output(struct perf_event *event,
 				 struct perf_event *output_event);
 static int perf_event_set_filter(struct perf_event *event, void __user *arg);
 static int perf_event_set_bpf_prog(struct perf_event *event, u32 prog_fd);
+static int perf_event_set_drv_configs(struct perf_event *event,
+				      void __user *arg);
 
 static long _perf_ioctl(struct perf_event *event, unsigned int cmd, unsigned long arg)
 {
@@ -4526,6 +4528,10 @@ static long _perf_ioctl(struct perf_event *event, unsigned int cmd, unsigned lon
 		rcu_read_unlock();
 		return 0;
 	}
+
+	case PERF_EVENT_IOC_SET_DRV_CONFIGS:
+		return perf_event_set_drv_configs(event, (void __user *)arg);
+
 	default:
 		return -ENOTTY;
 	}
@@ -4558,6 +4564,7 @@ static long perf_compat_ioctl(struct file *file, unsigned int cmd,
 	switch (_IOC_NR(cmd)) {
 	case _IOC_NR(PERF_EVENT_IOC_SET_FILTER):
 	case _IOC_NR(PERF_EVENT_IOC_ID):
+	case _IOC_NR(PERF_EVENT_IOC_SET_DRV_CONFIGS):
 		/* Fix up pointer size (usually 4 -> 8 in 32-on-64-bit case */
 		if (_IOC_SIZE(cmd) == sizeof(compat_uptr_t)) {
 			cmd &= ~IOCSIZE_MASK;
@@ -7633,6 +7640,15 @@ void perf_bp_event(struct perf_event *bp, void *data)
 }
 #endif
 
+static int perf_event_set_drv_configs(struct perf_event *event,
+				  void __user *arg)
+{
+	if (!event->pmu->set_drv_configs)
+		return -EINVAL;
+
+	return event->pmu->set_drv_configs(event, arg);
+}
+
 /*
  * Allocate a new address filter
  */
diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h
index c66a485a24ac..90fbc5fd3925 100644
--- a/tools/include/uapi/linux/perf_event.h
+++ b/tools/include/uapi/linux/perf_event.h
@@ -407,6 +407,7 @@ struct perf_event_attr {
 #define PERF_EVENT_IOC_ID		_IOR('$', 7, __u64 *)
 #define PERF_EVENT_IOC_SET_BPF		_IOW('$', 8, __u32)
 #define PERF_EVENT_IOC_PAUSE_OUTPUT	_IOW('$', 9, __u32)
+#define PERF_EVENT_IOC_SET_DRV_CONFIGS	_IOW('$', 10, char *)
 
 enum perf_event_ioc_flags {
 	PERF_IOC_FLAG_GROUP		= 1U << 0,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH V3 1/6] perf/core: Adding PMU driver specific configuration
@ 2016-07-28 21:42   ` Mathieu Poirier
  0 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-07-28 21:42 UTC (permalink / raw)
  To: linux-arm-kernel

This patch somewhat mimics the work done on address filters to
add the infrastructure needed to pass PMU specific HW
configuration to the driver before a session starts.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 include/linux/perf_event.h            |  9 +++++++++
 include/uapi/linux/perf_event.h       |  1 +
 kernel/events/core.c                  | 16 ++++++++++++++++
 tools/include/uapi/linux/perf_event.h |  1 +
 4 files changed, 27 insertions(+)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 7921f4f20a58..59d61a12cf9d 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -168,6 +168,9 @@ struct hw_perf_event {
 	/* Last sync'ed generation of filters */
 	unsigned long			addr_filters_gen;
 
+	/* HW specific configuration */
+	void				*drv_configs;
+
 /*
  * hw_perf_event::state flags; used to track the PERF_EF_* state.
  */
@@ -442,6 +445,12 @@ struct pmu {
 	 * Filter events for PMU-specific reasons.
 	 */
 	int (*filter_match)		(struct perf_event *event); /* optional */
+
+	/*
+	 * PMU driver specific configuration.
+	 */
+	int (*set_drv_configs)		(struct perf_event *event,
+					 void __user *arg); /* optional */
 };
 
 /**
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index c66a485a24ac..90fbc5fd3925 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -407,6 +407,7 @@ struct perf_event_attr {
 #define PERF_EVENT_IOC_ID		_IOR('$', 7, __u64 *)
 #define PERF_EVENT_IOC_SET_BPF		_IOW('$', 8, __u32)
 #define PERF_EVENT_IOC_PAUSE_OUTPUT	_IOW('$', 9, __u32)
+#define PERF_EVENT_IOC_SET_DRV_CONFIGS	_IOW('$', 10, char *)
 
 enum perf_event_ioc_flags {
 	PERF_IOC_FLAG_GROUP		= 1U << 0,
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 79dae188a987..9208e6ec036f 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -4457,6 +4457,8 @@ static int perf_event_set_output(struct perf_event *event,
 				 struct perf_event *output_event);
 static int perf_event_set_filter(struct perf_event *event, void __user *arg);
 static int perf_event_set_bpf_prog(struct perf_event *event, u32 prog_fd);
+static int perf_event_set_drv_configs(struct perf_event *event,
+				      void __user *arg);
 
 static long _perf_ioctl(struct perf_event *event, unsigned int cmd, unsigned long arg)
 {
@@ -4526,6 +4528,10 @@ static long _perf_ioctl(struct perf_event *event, unsigned int cmd, unsigned lon
 		rcu_read_unlock();
 		return 0;
 	}
+
+	case PERF_EVENT_IOC_SET_DRV_CONFIGS:
+		return perf_event_set_drv_configs(event, (void __user *)arg);
+
 	default:
 		return -ENOTTY;
 	}
@@ -4558,6 +4564,7 @@ static long perf_compat_ioctl(struct file *file, unsigned int cmd,
 	switch (_IOC_NR(cmd)) {
 	case _IOC_NR(PERF_EVENT_IOC_SET_FILTER):
 	case _IOC_NR(PERF_EVENT_IOC_ID):
+	case _IOC_NR(PERF_EVENT_IOC_SET_DRV_CONFIGS):
 		/* Fix up pointer size (usually 4 -> 8 in 32-on-64-bit case */
 		if (_IOC_SIZE(cmd) == sizeof(compat_uptr_t)) {
 			cmd &= ~IOCSIZE_MASK;
@@ -7633,6 +7640,15 @@ void perf_bp_event(struct perf_event *bp, void *data)
 }
 #endif
 
+static int perf_event_set_drv_configs(struct perf_event *event,
+				  void __user *arg)
+{
+	if (!event->pmu->set_drv_configs)
+		return -EINVAL;
+
+	return event->pmu->set_drv_configs(event, arg);
+}
+
 /*
  * Allocate a new address filter
  */
diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h
index c66a485a24ac..90fbc5fd3925 100644
--- a/tools/include/uapi/linux/perf_event.h
+++ b/tools/include/uapi/linux/perf_event.h
@@ -407,6 +407,7 @@ struct perf_event_attr {
 #define PERF_EVENT_IOC_ID		_IOR('$', 7, __u64 *)
 #define PERF_EVENT_IOC_SET_BPF		_IOW('$', 8, __u32)
 #define PERF_EVENT_IOC_PAUSE_OUTPUT	_IOW('$', 9, __u32)
+#define PERF_EVENT_IOC_SET_DRV_CONFIGS	_IOW('$', 10, char *)
 
 enum perf_event_ioc_flags {
 	PERF_IOC_FLAG_GROUP		= 1U << 0,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH V3 2/6] perf: Passing struct perf_event to function setup_aux()
  2016-07-28 21:42 ` Mathieu Poirier
@ 2016-07-28 21:42   ` Mathieu Poirier
  -1 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-07-28 21:42 UTC (permalink / raw)
  To: acme, jolsa
  Cc: peterz, mingo, linux-kernel, linux-arm-kernel, Mathieu Poirier,
	Alexander Shishkin

Some information, like driver specific configuration, is found
in the hw_perf_event  structure.  As such pass a 'struct perf_event'
to function setup_aux() rather than just the CPU number so that
individual drivers can make the right configuration when setting
up a session.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
---
 arch/x86/events/intel/bts.c                      | 4 +++-
 arch/x86/events/intel/pt.c                       | 5 +++--
 drivers/hwtracing/coresight/coresight-etm-perf.c | 4 ++--
 include/linux/perf_event.h                       | 2 +-
 kernel/events/ring_buffer.c                      | 2 +-
 5 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c
index 0a6e393a2e62..98155c2dfcce 100644
--- a/arch/x86/events/intel/bts.c
+++ b/arch/x86/events/intel/bts.c
@@ -68,8 +68,10 @@ static size_t buf_size(struct page *page)
 }
 
 static void *
-bts_buffer_setup_aux(int cpu, void **pages, int nr_pages, bool overwrite)
+bts_buffer_setup_aux(struct perf_event *event, void **pages,
+		     int nr_pages, bool overwrite)
 {
+	int cpu = event->cpu;
 	struct bts_buffer *buf;
 	struct page *page;
 	int node = (cpu == -1) ? cpu : cpu_to_node(cpu);
diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
index 04bb5fb5a8d7..5178c5de0b19 100644
--- a/arch/x86/events/intel/pt.c
+++ b/arch/x86/events/intel/pt.c
@@ -1003,10 +1003,11 @@ static int pt_buffer_init_topa(struct pt_buffer *buf, unsigned long nr_pages,
  * Return:	Our private PT buffer structure.
  */
 static void *
-pt_buffer_setup_aux(int cpu, void **pages, int nr_pages, bool snapshot)
+pt_buffer_setup_aux(struct perf_event *event, void **pages,
+		    int nr_pages, bool snapshot)
 {
 	struct pt_buffer *buf;
-	int node, ret;
+	int node, ret, cpu = event->cpu;
 
 	if (!nr_pages)
 		return NULL;
diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
index 755125f7917f..f4174f36c5a0 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -155,7 +155,7 @@ static void etm_free_aux(void *data)
 	schedule_work(&event_data->work);
 }
 
-static void *etm_setup_aux(int event_cpu, void **pages,
+static void *etm_setup_aux(struct perf_event *event, void **pages,
 			   int nr_pages, bool overwrite)
 {
 	int cpu;
@@ -163,7 +163,7 @@ static void *etm_setup_aux(int event_cpu, void **pages,
 	struct coresight_device *sink;
 	struct etm_event_data *event_data = NULL;
 
-	event_data = alloc_event_data(event_cpu);
+	event_data = alloc_event_data(event->cpu);
 	if (!event_data)
 		return NULL;
 
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 59d61a12cf9d..5275b6594989 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -407,7 +407,7 @@ struct pmu {
 	/*
 	 * Set up pmu-private data structures for an AUX area
 	 */
-	void *(*setup_aux)		(int cpu, void **pages,
+	void *(*setup_aux)		(struct perf_event *event, void **pages,
 					 int nr_pages, bool overwrite);
 					/* optional */
 
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index ae9b90dc9a5a..56aba90af437 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -616,7 +616,7 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event,
 			goto out;
 	}
 
-	rb->aux_priv = event->pmu->setup_aux(event->cpu, rb->aux_pages, nr_pages,
+	rb->aux_priv = event->pmu->setup_aux(event, rb->aux_pages, nr_pages,
 					     overwrite);
 	if (!rb->aux_priv)
 		goto out;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH V3 2/6] perf: Passing struct perf_event to function setup_aux()
@ 2016-07-28 21:42   ` Mathieu Poirier
  0 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-07-28 21:42 UTC (permalink / raw)
  To: linux-arm-kernel

Some information, like driver specific configuration, is found
in the hw_perf_event  structure.  As such pass a 'struct perf_event'
to function setup_aux() rather than just the CPU number so that
individual drivers can make the right configuration when setting
up a session.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
---
 arch/x86/events/intel/bts.c                      | 4 +++-
 arch/x86/events/intel/pt.c                       | 5 +++--
 drivers/hwtracing/coresight/coresight-etm-perf.c | 4 ++--
 include/linux/perf_event.h                       | 2 +-
 kernel/events/ring_buffer.c                      | 2 +-
 5 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c
index 0a6e393a2e62..98155c2dfcce 100644
--- a/arch/x86/events/intel/bts.c
+++ b/arch/x86/events/intel/bts.c
@@ -68,8 +68,10 @@ static size_t buf_size(struct page *page)
 }
 
 static void *
-bts_buffer_setup_aux(int cpu, void **pages, int nr_pages, bool overwrite)
+bts_buffer_setup_aux(struct perf_event *event, void **pages,
+		     int nr_pages, bool overwrite)
 {
+	int cpu = event->cpu;
 	struct bts_buffer *buf;
 	struct page *page;
 	int node = (cpu == -1) ? cpu : cpu_to_node(cpu);
diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
index 04bb5fb5a8d7..5178c5de0b19 100644
--- a/arch/x86/events/intel/pt.c
+++ b/arch/x86/events/intel/pt.c
@@ -1003,10 +1003,11 @@ static int pt_buffer_init_topa(struct pt_buffer *buf, unsigned long nr_pages,
  * Return:	Our private PT buffer structure.
  */
 static void *
-pt_buffer_setup_aux(int cpu, void **pages, int nr_pages, bool snapshot)
+pt_buffer_setup_aux(struct perf_event *event, void **pages,
+		    int nr_pages, bool snapshot)
 {
 	struct pt_buffer *buf;
-	int node, ret;
+	int node, ret, cpu = event->cpu;
 
 	if (!nr_pages)
 		return NULL;
diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
index 755125f7917f..f4174f36c5a0 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -155,7 +155,7 @@ static void etm_free_aux(void *data)
 	schedule_work(&event_data->work);
 }
 
-static void *etm_setup_aux(int event_cpu, void **pages,
+static void *etm_setup_aux(struct perf_event *event, void **pages,
 			   int nr_pages, bool overwrite)
 {
 	int cpu;
@@ -163,7 +163,7 @@ static void *etm_setup_aux(int event_cpu, void **pages,
 	struct coresight_device *sink;
 	struct etm_event_data *event_data = NULL;
 
-	event_data = alloc_event_data(event_cpu);
+	event_data = alloc_event_data(event->cpu);
 	if (!event_data)
 		return NULL;
 
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 59d61a12cf9d..5275b6594989 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -407,7 +407,7 @@ struct pmu {
 	/*
 	 * Set up pmu-private data structures for an AUX area
 	 */
-	void *(*setup_aux)		(int cpu, void **pages,
+	void *(*setup_aux)		(struct perf_event *event, void **pages,
 					 int nr_pages, bool overwrite);
 					/* optional */
 
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index ae9b90dc9a5a..56aba90af437 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -616,7 +616,7 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event,
 			goto out;
 	}
 
-	rb->aux_priv = event->pmu->setup_aux(event->cpu, rb->aux_pages, nr_pages,
+	rb->aux_priv = event->pmu->setup_aux(event, rb->aux_pages, nr_pages,
 					     overwrite);
 	if (!rb->aux_priv)
 		goto out;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH V3 3/6] perf tools: add infrastructure for PMU specific configuration
  2016-07-28 21:42 ` Mathieu Poirier
@ 2016-07-28 21:42   ` Mathieu Poirier
  -1 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-07-28 21:42 UTC (permalink / raw)
  To: acme, jolsa
  Cc: peterz, mingo, linux-kernel, linux-arm-kernel, Mathieu Poirier

This patch adds PMU driver specific configuration to the parser
infrastructure by preceding any term with the '@' letter.  As such
doing something like:

perf record -e some_event/@cfg1,@cfg2=config/ ...

will see 'cfg1' and 'cfg2=config' being added to the list of evsel config
terms.  Token 'cfg1' and 'cfg2=config' are not processed in user space
and are meant to be interpreted by the PMU driver.

First the lexer/parser are supplemented with the required definitions to
recognise the driver specific configuration.  From there they are simply
added to the list of event terms.  The bulk of the work is done in
function "parse_events_add_pmu()" where driver config event terms are
added to a new list of driver config terms, which in turn spliced with
the event's new driver configuration list.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 tools/perf/Documentation/perf-record.txt | 12 ++++++++++++
 tools/perf/util/evsel.h                  |  2 ++
 tools/perf/util/parse-events.c           |  7 ++++++-
 tools/perf/util/parse-events.h           |  1 +
 tools/perf/util/parse-events.l           | 22 ++++++++++++++++++++++
 tools/perf/util/parse-events.y           | 11 +++++++++++
 6 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 69966abf65d1..8f3e65069b9e 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -60,6 +60,18 @@ OPTIONS
 	  Note: If user explicitly sets options which conflict with the params,
 	  the value set by the params will be overridden.
 
+	  Also not defined in .../<pmu>/format/* are PMU driver specific
+	  configuration parameters.  Any configuration parameter preceded by
+	  the letter '@' is not interpreted in user space and sent down directly
+	  to the PMU driver.  For example:
+
+	  perf record -e some_event/@cfg1,@cfg2=config/ ...
+
+	  will see 'cfg1' and 'cfg2=config' pushed to the PMU driver associated
+	  with the event for further processing.  There is no restriction on
+	  what the configuration parameters are, as long as their semantic is
+	  understood and supported by the PMU driver.
+
         - a hardware breakpoint event in the form of '\mem:addr[/len][:access]'
           where addr is the address in memory you want to break in.
           Access is the memory access type (read, write, execute) it can
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 8a4a6c9f1480..e398b5cb70a1 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -46,6 +46,7 @@ enum {
 	PERF_EVSEL__CONFIG_TERM_INHERIT,
 	PERF_EVSEL__CONFIG_TERM_MAX_STACK,
 	PERF_EVSEL__CONFIG_TERM_OVERWRITE,
+	PERF_EVSEL__CONFIG_TERM_DRV_CFG,
 	PERF_EVSEL__CONFIG_TERM_MAX,
 };
 
@@ -57,6 +58,7 @@ struct perf_evsel_config_term {
 		u64	freq;
 		bool	time;
 		char	*callgraph;
+		char	*drv_cfg;
 		u64	stack_user;
 		int	max_stack;
 		bool	inherit;
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 6c913c3914fb..2eb8b1ed4cc8 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -904,6 +904,7 @@ static const char *config_term_names[__PARSE_EVENTS__TERM_TYPE_NR] = {
 	[PARSE_EVENTS__TERM_TYPE_MAX_STACK]		= "max-stack",
 	[PARSE_EVENTS__TERM_TYPE_OVERWRITE]		= "overwrite",
 	[PARSE_EVENTS__TERM_TYPE_NOOVERWRITE]		= "no-overwrite",
+	[PARSE_EVENTS__TERM_TYPE_DRV_CFG]		= "driver-config",
 };
 
 static bool config_term_shrinked;
@@ -1034,7 +1035,8 @@ static int config_term_pmu(struct perf_event_attr *attr,
 			   struct parse_events_term *term,
 			   struct parse_events_error *err)
 {
-	if (term->type_term == PARSE_EVENTS__TERM_TYPE_USER)
+	if (term->type_term == PARSE_EVENTS__TERM_TYPE_USER ||
+	    term->type_term == PARSE_EVENTS__TERM_TYPE_DRV_CFG)
 		/*
 		 * Always succeed for sysfs terms, as we dont know
 		 * at this point what type they need to have.
@@ -1134,6 +1136,9 @@ do {								\
 		case PARSE_EVENTS__TERM_TYPE_NOOVERWRITE:
 			ADD_CONFIG_TERM(OVERWRITE, overwrite, term->val.num ? 0 : 1);
 			break;
+		case PARSE_EVENTS__TERM_TYPE_DRV_CFG:
+			ADD_CONFIG_TERM(DRV_CFG, drv_cfg, term->val.str);
+			break;
 		default:
 			break;
 		}
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index d1edbf8cc66a..8d09a976fca8 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -71,6 +71,7 @@ enum {
 	PARSE_EVENTS__TERM_TYPE_MAX_STACK,
 	PARSE_EVENTS__TERM_TYPE_NOOVERWRITE,
 	PARSE_EVENTS__TERM_TYPE_OVERWRITE,
+	PARSE_EVENTS__TERM_TYPE_DRV_CFG,
 	__PARSE_EVENTS__TERM_TYPE_NR,
 };
 
diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
index 7a2519435da0..9f43fda2570f 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -53,6 +53,26 @@ static int str(yyscan_t scanner, int token)
 	return token;
 }
 
+/*
+ * This function is called when the parser gets two kind of input:
+ *
+ * 	@cfg1 or @cfg2=config
+ *
+ * The leading '@' is stripped off before 'cfg1' and 'cfg2=config' are given to
+ * bison.  In the latter case it is necessary to keep the string intact so that
+ * the PMU kernel driver can determine what configurable is associated to
+ * 'config'.
+ */
+static int drv_str(yyscan_t scanner, int token)
+{
+	YYSTYPE *yylval = parse_events_get_lval(scanner);
+	char *text = parse_events_get_text(scanner);
+
+	/* Strip off the '@' */
+	yylval->str = strdup(text + 1);
+	return token;
+}
+
 #define REWIND(__alloc)				\
 do {								\
 	YYSTYPE *__yylval = parse_events_get_lval(yyscanner);	\
@@ -124,6 +144,7 @@ num_hex		0x[a-fA-F0-9]+
 num_raw_hex	[a-fA-F0-9]+
 name		[a-zA-Z_*?][a-zA-Z0-9_*?.]*
 name_minus	[a-zA-Z_*?][a-zA-Z0-9\-_*?.:]*
+drv_cfg_term	[a-zA-Z0-9_\.]+(=[a-zA-Z0-9_*?\.:]+)?
 /* If you add a modifier you need to update check_modifier() */
 modifier_event	[ukhpPGHSDI]+
 modifier_bp	[rwx]{1,3}
@@ -209,6 +230,7 @@ no-overwrite		{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NOOVERWRITE); }
 {name_minus}		{ return str(yyscanner, PE_NAME); }
 \[all\]			{ return PE_ARRAY_ALL; }
 "["			{ BEGIN(array); return '['; }
+@{drv_cfg_term}		{ return drv_str(yyscanner, PE_DRV_CFG_TERM); }
 }
 
 <mem>{
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 5be4a5f216d6..879115f93edc 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -49,6 +49,7 @@ static void inc_group_count(struct list_head *list,
 %token PE_ERROR
 %token PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT
 %token PE_ARRAY_ALL PE_ARRAY_RANGE
+%token PE_DRV_CFG_TERM
 %type <num> PE_VALUE
 %type <num> PE_VALUE_SYM_HW
 %type <num> PE_VALUE_SYM_SW
@@ -63,6 +64,7 @@ static void inc_group_count(struct list_head *list,
 %type <str> PE_MODIFIER_BP
 %type <str> PE_EVENT_NAME
 %type <str> PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT
+%type <str> PE_DRV_CFG_TERM
 %type <num> value_sym
 %type <head> event_config
 %type <head> opt_event_config
@@ -599,6 +601,15 @@ PE_NAME array '=' PE_VALUE
 	term->array = $2;
 	$$ = term;
 }
+|
+PE_DRV_CFG_TERM
+{
+	struct parse_events_term *term;
+
+	ABORT_ON(parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_DRV_CFG,
+					$1, $1, &@1, NULL));
+	$$ = term;
+}
 
 array:
 '[' array_terms ']'
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH V3 3/6] perf tools: add infrastructure for PMU specific configuration
@ 2016-07-28 21:42   ` Mathieu Poirier
  0 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-07-28 21:42 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds PMU driver specific configuration to the parser
infrastructure by preceding any term with the '@' letter.  As such
doing something like:

perf record -e some_event/@cfg1, at cfg2=config/ ...

will see 'cfg1' and 'cfg2=config' being added to the list of evsel config
terms.  Token 'cfg1' and 'cfg2=config' are not processed in user space
and are meant to be interpreted by the PMU driver.

First the lexer/parser are supplemented with the required definitions to
recognise the driver specific configuration.  From there they are simply
added to the list of event terms.  The bulk of the work is done in
function "parse_events_add_pmu()" where driver config event terms are
added to a new list of driver config terms, which in turn spliced with
the event's new driver configuration list.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 tools/perf/Documentation/perf-record.txt | 12 ++++++++++++
 tools/perf/util/evsel.h                  |  2 ++
 tools/perf/util/parse-events.c           |  7 ++++++-
 tools/perf/util/parse-events.h           |  1 +
 tools/perf/util/parse-events.l           | 22 ++++++++++++++++++++++
 tools/perf/util/parse-events.y           | 11 +++++++++++
 6 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 69966abf65d1..8f3e65069b9e 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -60,6 +60,18 @@ OPTIONS
 	  Note: If user explicitly sets options which conflict with the params,
 	  the value set by the params will be overridden.
 
+	  Also not defined in .../<pmu>/format/* are PMU driver specific
+	  configuration parameters.  Any configuration parameter preceded by
+	  the letter '@' is not interpreted in user space and sent down directly
+	  to the PMU driver.  For example:
+
+	  perf record -e some_event/@cfg1, at cfg2=config/ ...
+
+	  will see 'cfg1' and 'cfg2=config' pushed to the PMU driver associated
+	  with the event for further processing.  There is no restriction on
+	  what the configuration parameters are, as long as their semantic is
+	  understood and supported by the PMU driver.
+
         - a hardware breakpoint event in the form of '\mem:addr[/len][:access]'
           where addr is the address in memory you want to break in.
           Access is the memory access type (read, write, execute) it can
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 8a4a6c9f1480..e398b5cb70a1 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -46,6 +46,7 @@ enum {
 	PERF_EVSEL__CONFIG_TERM_INHERIT,
 	PERF_EVSEL__CONFIG_TERM_MAX_STACK,
 	PERF_EVSEL__CONFIG_TERM_OVERWRITE,
+	PERF_EVSEL__CONFIG_TERM_DRV_CFG,
 	PERF_EVSEL__CONFIG_TERM_MAX,
 };
 
@@ -57,6 +58,7 @@ struct perf_evsel_config_term {
 		u64	freq;
 		bool	time;
 		char	*callgraph;
+		char	*drv_cfg;
 		u64	stack_user;
 		int	max_stack;
 		bool	inherit;
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 6c913c3914fb..2eb8b1ed4cc8 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -904,6 +904,7 @@ static const char *config_term_names[__PARSE_EVENTS__TERM_TYPE_NR] = {
 	[PARSE_EVENTS__TERM_TYPE_MAX_STACK]		= "max-stack",
 	[PARSE_EVENTS__TERM_TYPE_OVERWRITE]		= "overwrite",
 	[PARSE_EVENTS__TERM_TYPE_NOOVERWRITE]		= "no-overwrite",
+	[PARSE_EVENTS__TERM_TYPE_DRV_CFG]		= "driver-config",
 };
 
 static bool config_term_shrinked;
@@ -1034,7 +1035,8 @@ static int config_term_pmu(struct perf_event_attr *attr,
 			   struct parse_events_term *term,
 			   struct parse_events_error *err)
 {
-	if (term->type_term == PARSE_EVENTS__TERM_TYPE_USER)
+	if (term->type_term == PARSE_EVENTS__TERM_TYPE_USER ||
+	    term->type_term == PARSE_EVENTS__TERM_TYPE_DRV_CFG)
 		/*
 		 * Always succeed for sysfs terms, as we dont know
 		 * at this point what type they need to have.
@@ -1134,6 +1136,9 @@ do {								\
 		case PARSE_EVENTS__TERM_TYPE_NOOVERWRITE:
 			ADD_CONFIG_TERM(OVERWRITE, overwrite, term->val.num ? 0 : 1);
 			break;
+		case PARSE_EVENTS__TERM_TYPE_DRV_CFG:
+			ADD_CONFIG_TERM(DRV_CFG, drv_cfg, term->val.str);
+			break;
 		default:
 			break;
 		}
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index d1edbf8cc66a..8d09a976fca8 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -71,6 +71,7 @@ enum {
 	PARSE_EVENTS__TERM_TYPE_MAX_STACK,
 	PARSE_EVENTS__TERM_TYPE_NOOVERWRITE,
 	PARSE_EVENTS__TERM_TYPE_OVERWRITE,
+	PARSE_EVENTS__TERM_TYPE_DRV_CFG,
 	__PARSE_EVENTS__TERM_TYPE_NR,
 };
 
diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
index 7a2519435da0..9f43fda2570f 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -53,6 +53,26 @@ static int str(yyscan_t scanner, int token)
 	return token;
 }
 
+/*
+ * This function is called when the parser gets two kind of input:
+ *
+ * 	@cfg1 or @cfg2=config
+ *
+ * The leading '@' is stripped off before 'cfg1' and 'cfg2=config' are given to
+ * bison.  In the latter case it is necessary to keep the string intact so that
+ * the PMU kernel driver can determine what configurable is associated to
+ * 'config'.
+ */
+static int drv_str(yyscan_t scanner, int token)
+{
+	YYSTYPE *yylval = parse_events_get_lval(scanner);
+	char *text = parse_events_get_text(scanner);
+
+	/* Strip off the '@' */
+	yylval->str = strdup(text + 1);
+	return token;
+}
+
 #define REWIND(__alloc)				\
 do {								\
 	YYSTYPE *__yylval = parse_events_get_lval(yyscanner);	\
@@ -124,6 +144,7 @@ num_hex		0x[a-fA-F0-9]+
 num_raw_hex	[a-fA-F0-9]+
 name		[a-zA-Z_*?][a-zA-Z0-9_*?.]*
 name_minus	[a-zA-Z_*?][a-zA-Z0-9\-_*?.:]*
+drv_cfg_term	[a-zA-Z0-9_\.]+(=[a-zA-Z0-9_*?\.:]+)?
 /* If you add a modifier you need to update check_modifier() */
 modifier_event	[ukhpPGHSDI]+
 modifier_bp	[rwx]{1,3}
@@ -209,6 +230,7 @@ no-overwrite		{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NOOVERWRITE); }
 {name_minus}		{ return str(yyscanner, PE_NAME); }
 \[all\]			{ return PE_ARRAY_ALL; }
 "["			{ BEGIN(array); return '['; }
+@{drv_cfg_term}		{ return drv_str(yyscanner, PE_DRV_CFG_TERM); }
 }
 
 <mem>{
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 5be4a5f216d6..879115f93edc 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -49,6 +49,7 @@ static void inc_group_count(struct list_head *list,
 %token PE_ERROR
 %token PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT
 %token PE_ARRAY_ALL PE_ARRAY_RANGE
+%token PE_DRV_CFG_TERM
 %type <num> PE_VALUE
 %type <num> PE_VALUE_SYM_HW
 %type <num> PE_VALUE_SYM_SW
@@ -63,6 +64,7 @@ static void inc_group_count(struct list_head *list,
 %type <str> PE_MODIFIER_BP
 %type <str> PE_EVENT_NAME
 %type <str> PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT
+%type <str> PE_DRV_CFG_TERM
 %type <num> value_sym
 %type <head> event_config
 %type <head> opt_event_config
@@ -599,6 +601,15 @@ PE_NAME array '=' PE_VALUE
 	term->array = $2;
 	$$ = term;
 }
+|
+PE_DRV_CFG_TERM
+{
+	struct parse_events_term *term;
+
+	ABORT_ON(parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_DRV_CFG,
+					$1, $1, &@1, NULL));
+	$$ = term;
+}
 
 array:
 '[' array_terms ']'
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH V3 4/6] perf tools: pushing driver configuration down to the kernel
  2016-07-28 21:42 ` Mathieu Poirier
@ 2016-07-28 21:42   ` Mathieu Poirier
  -1 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-07-28 21:42 UTC (permalink / raw)
  To: acme, jolsa
  Cc: peterz, mingo, linux-kernel, linux-arm-kernel, Mathieu Poirier

Now that PMU specific driver configuration are queued in
evsel::config_terms, all we need to do is re-use the current
ioctl() mechanism to push down the information to the kernel
driver.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 tools/perf/builtin-record.c |  9 +++++++++
 tools/perf/builtin-stat.c   |  8 ++++++++
 tools/perf/util/evlist.c    | 21 +++++++++++++++++++++
 tools/perf/util/evlist.h    |  3 +++
 tools/perf/util/evsel.c     | 24 ++++++++++++++++++++++++
 tools/perf/util/evsel.h     |  3 +++
 6 files changed, 68 insertions(+)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 8f2c16d9275f..185e2f7cd307 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -383,6 +383,7 @@ static int record__open(struct record *rec)
 	struct perf_evlist *evlist = rec->evlist;
 	struct perf_session *session = rec->session;
 	struct record_opts *opts = &rec->opts;
+	struct perf_evsel_config_term *err_term;
 	int rc = 0;
 
 	perf_evlist__config(evlist, opts, &callchain_param);
@@ -412,6 +413,14 @@ try_again:
 		goto out;
 	}
 
+	if (perf_evlist__apply_drv_configs(evlist, &pos, &err_term)) {
+		error("failed to set config \"%s\" on event %s with %d (%s)\n",
+		      err_term->val.drv_cfg, perf_evsel__name(pos), errno,
+		      strerror_r(errno, msg, sizeof(msg)));
+		rc = -1;
+		goto out;
+	}
+
 	rc = record__mmap(rec);
 	if (rc)
 		goto out;
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 0c16d20d7e32..f003a9e50f4e 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -533,6 +533,7 @@ static int __run_perf_stat(int argc, const char **argv)
 	int status = 0;
 	const bool forks = (argc > 0);
 	bool is_pipe = STAT_RECORD ? perf_stat.file.is_pipe : false;
+	struct perf_evsel_config_term *err_term;
 
 	if (interval) {
 		ts.tv_sec  = interval / 1000;
@@ -604,6 +605,13 @@ try_again:
 		return -1;
 	}
 
+	if (perf_evlist__apply_drv_configs(evsel_list, &counter, &err_term)) {
+		error("failed to set config \"%s\" on event %s with %d (%s)\n",
+		      err_term->val.drv_cfg, perf_evsel__name(counter), errno,
+		      strerror_r(errno, msg, sizeof(msg)));
+		return -1;
+	}
+
 	if (STAT_RECORD) {
 		int err, fd = perf_data_file__fd(&perf_stat.file);
 
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 2a40b8e1def7..dd20a182b5a3 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1433,6 +1433,27 @@ int perf_evlist__apply_filters(struct perf_evlist *evlist, struct perf_evsel **e
 	return err;
 }
 
+int perf_evlist__apply_drv_configs(struct perf_evlist *evlist,
+				   struct perf_evsel **err_evsel,
+				   struct perf_evsel_config_term **err_term)
+{
+	struct perf_evsel *evsel;
+	int err = 0;
+	const int ncpus = cpu_map__nr(evlist->cpus),
+		  nthreads = thread_map__nr(evlist->threads);
+
+	evlist__for_each_entry(evlist, evsel) {
+		err = perf_evsel__apply_drv_configs(evsel, ncpus,
+						    nthreads, err_term);
+		if (err) {
+			*err_evsel = evsel;
+			break;
+		}
+	}
+
+	return err;
+}
+
 int perf_evlist__set_filter(struct perf_evlist *evlist, const char *filter)
 {
 	struct perf_evsel *evsel;
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 4fd034f22d2f..bf7ed0be3f33 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -232,6 +232,9 @@ void perf_evlist__set_maps(struct perf_evlist *evlist, struct cpu_map *cpus,
 			   struct thread_map *threads);
 int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target);
 int perf_evlist__apply_filters(struct perf_evlist *evlist, struct perf_evsel **err_evsel);
+int perf_evlist__apply_drv_configs(struct perf_evlist *evlist,
+				   struct perf_evsel **err_evsel,
+				   struct perf_evsel_config_term **term);
 
 void __perf_evlist__set_leader(struct list_head *list);
 void perf_evlist__set_leader(struct perf_evlist *evlist);
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 8c54df61fe64..e0c44ee586ee 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1034,6 +1034,30 @@ int perf_evsel__append_filter(struct perf_evsel *evsel,
 	return -1;
 }
 
+int perf_evsel__apply_drv_configs(struct perf_evsel *evsel,
+				  int ncpus, int nthreads,
+				  struct perf_evsel_config_term **err_term)
+{
+	int err = 0;
+	struct perf_evsel_config_term *term;
+
+	list_for_each_entry(term, &evsel->config_terms, list) {
+		if (term->type != PERF_EVSEL__CONFIG_TERM_DRV_CFG)
+			continue;
+
+		err = perf_evsel__run_ioctl(evsel, ncpus, nthreads,
+					    PERF_EVENT_IOC_SET_DRV_CONFIGS,
+					    (void *)term->val.drv_cfg);
+
+		if (err) {
+			*err_term = term;
+			break;
+		}
+	}
+
+	return err;
+}
+
 int perf_evsel__enable(struct perf_evsel *evsel)
 {
 	int nthreads = thread_map__nr(evsel->threads);
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index e398b5cb70a1..221eb7cc9795 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -237,6 +237,9 @@ int perf_evsel__append_filter(struct perf_evsel *evsel,
 			      const char *op, const char *filter);
 int perf_evsel__apply_filter(struct perf_evsel *evsel, int ncpus, int nthreads,
 			     const char *filter);
+int perf_evsel__apply_drv_configs(struct perf_evsel *evsel,
+				  int ncpus, int nthreads,
+				  struct perf_evsel_config_term **err_term);
 int perf_evsel__enable(struct perf_evsel *evsel);
 int perf_evsel__disable(struct perf_evsel *evsel);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH V3 4/6] perf tools: pushing driver configuration down to the kernel
@ 2016-07-28 21:42   ` Mathieu Poirier
  0 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-07-28 21:42 UTC (permalink / raw)
  To: linux-arm-kernel

Now that PMU specific driver configuration are queued in
evsel::config_terms, all we need to do is re-use the current
ioctl() mechanism to push down the information to the kernel
driver.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 tools/perf/builtin-record.c |  9 +++++++++
 tools/perf/builtin-stat.c   |  8 ++++++++
 tools/perf/util/evlist.c    | 21 +++++++++++++++++++++
 tools/perf/util/evlist.h    |  3 +++
 tools/perf/util/evsel.c     | 24 ++++++++++++++++++++++++
 tools/perf/util/evsel.h     |  3 +++
 6 files changed, 68 insertions(+)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 8f2c16d9275f..185e2f7cd307 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -383,6 +383,7 @@ static int record__open(struct record *rec)
 	struct perf_evlist *evlist = rec->evlist;
 	struct perf_session *session = rec->session;
 	struct record_opts *opts = &rec->opts;
+	struct perf_evsel_config_term *err_term;
 	int rc = 0;
 
 	perf_evlist__config(evlist, opts, &callchain_param);
@@ -412,6 +413,14 @@ try_again:
 		goto out;
 	}
 
+	if (perf_evlist__apply_drv_configs(evlist, &pos, &err_term)) {
+		error("failed to set config \"%s\" on event %s with %d (%s)\n",
+		      err_term->val.drv_cfg, perf_evsel__name(pos), errno,
+		      strerror_r(errno, msg, sizeof(msg)));
+		rc = -1;
+		goto out;
+	}
+
 	rc = record__mmap(rec);
 	if (rc)
 		goto out;
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 0c16d20d7e32..f003a9e50f4e 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -533,6 +533,7 @@ static int __run_perf_stat(int argc, const char **argv)
 	int status = 0;
 	const bool forks = (argc > 0);
 	bool is_pipe = STAT_RECORD ? perf_stat.file.is_pipe : false;
+	struct perf_evsel_config_term *err_term;
 
 	if (interval) {
 		ts.tv_sec  = interval / 1000;
@@ -604,6 +605,13 @@ try_again:
 		return -1;
 	}
 
+	if (perf_evlist__apply_drv_configs(evsel_list, &counter, &err_term)) {
+		error("failed to set config \"%s\" on event %s with %d (%s)\n",
+		      err_term->val.drv_cfg, perf_evsel__name(counter), errno,
+		      strerror_r(errno, msg, sizeof(msg)));
+		return -1;
+	}
+
 	if (STAT_RECORD) {
 		int err, fd = perf_data_file__fd(&perf_stat.file);
 
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 2a40b8e1def7..dd20a182b5a3 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1433,6 +1433,27 @@ int perf_evlist__apply_filters(struct perf_evlist *evlist, struct perf_evsel **e
 	return err;
 }
 
+int perf_evlist__apply_drv_configs(struct perf_evlist *evlist,
+				   struct perf_evsel **err_evsel,
+				   struct perf_evsel_config_term **err_term)
+{
+	struct perf_evsel *evsel;
+	int err = 0;
+	const int ncpus = cpu_map__nr(evlist->cpus),
+		  nthreads = thread_map__nr(evlist->threads);
+
+	evlist__for_each_entry(evlist, evsel) {
+		err = perf_evsel__apply_drv_configs(evsel, ncpus,
+						    nthreads, err_term);
+		if (err) {
+			*err_evsel = evsel;
+			break;
+		}
+	}
+
+	return err;
+}
+
 int perf_evlist__set_filter(struct perf_evlist *evlist, const char *filter)
 {
 	struct perf_evsel *evsel;
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 4fd034f22d2f..bf7ed0be3f33 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -232,6 +232,9 @@ void perf_evlist__set_maps(struct perf_evlist *evlist, struct cpu_map *cpus,
 			   struct thread_map *threads);
 int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target);
 int perf_evlist__apply_filters(struct perf_evlist *evlist, struct perf_evsel **err_evsel);
+int perf_evlist__apply_drv_configs(struct perf_evlist *evlist,
+				   struct perf_evsel **err_evsel,
+				   struct perf_evsel_config_term **term);
 
 void __perf_evlist__set_leader(struct list_head *list);
 void perf_evlist__set_leader(struct perf_evlist *evlist);
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 8c54df61fe64..e0c44ee586ee 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1034,6 +1034,30 @@ int perf_evsel__append_filter(struct perf_evsel *evsel,
 	return -1;
 }
 
+int perf_evsel__apply_drv_configs(struct perf_evsel *evsel,
+				  int ncpus, int nthreads,
+				  struct perf_evsel_config_term **err_term)
+{
+	int err = 0;
+	struct perf_evsel_config_term *term;
+
+	list_for_each_entry(term, &evsel->config_terms, list) {
+		if (term->type != PERF_EVSEL__CONFIG_TERM_DRV_CFG)
+			continue;
+
+		err = perf_evsel__run_ioctl(evsel, ncpus, nthreads,
+					    PERF_EVENT_IOC_SET_DRV_CONFIGS,
+					    (void *)term->val.drv_cfg);
+
+		if (err) {
+			*err_term = term;
+			break;
+		}
+	}
+
+	return err;
+}
+
 int perf_evsel__enable(struct perf_evsel *evsel)
 {
 	int nthreads = thread_map__nr(evsel->threads);
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index e398b5cb70a1..221eb7cc9795 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -237,6 +237,9 @@ int perf_evsel__append_filter(struct perf_evsel *evsel,
 			      const char *op, const char *filter);
 int perf_evsel__apply_filter(struct perf_evsel *evsel, int ncpus, int nthreads,
 			     const char *filter);
+int perf_evsel__apply_drv_configs(struct perf_evsel *evsel,
+				  int ncpus, int nthreads,
+				  struct perf_evsel_config_term **err_term);
 int perf_evsel__enable(struct perf_evsel *evsel);
 int perf_evsel__disable(struct perf_evsel *evsel);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH V3 5/6] coresight: adding sink parameter to function coresight_build_path()
  2016-07-28 21:42 ` Mathieu Poirier
@ 2016-07-28 21:42   ` Mathieu Poirier
  -1 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-07-28 21:42 UTC (permalink / raw)
  To: acme, jolsa
  Cc: peterz, mingo, linux-kernel, linux-arm-kernel, Mathieu Poirier

Up to now function coresight_build_path() was counting on a sink to
have been selected (from sysFS) prior to being called.  This patch
adds a string argument so that a sink matching the argument can be
selected.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 drivers/hwtracing/coresight/coresight-etm-perf.c |  2 +-
 drivers/hwtracing/coresight/coresight-priv.h     |  3 +-
 drivers/hwtracing/coresight/coresight.c          | 43 ++++++++++++++++--------
 3 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
index f4174f36c5a0..f8c7a8733b23 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -184,7 +184,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
 		 * list of devices from source to sink that can be
 		 * referenced later when the path is actually needed.
 		 */
-		event_data->path[cpu] = coresight_build_path(csdev);
+		event_data->path[cpu] = coresight_build_path(csdev, NULL);
 		if (!event_data->path[cpu])
 			goto err;
 	}
diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h
index ad975c58080d..3cb574b3cdd9 100644
--- a/drivers/hwtracing/coresight/coresight-priv.h
+++ b/drivers/hwtracing/coresight/coresight-priv.h
@@ -94,7 +94,8 @@ static inline void CS_UNLOCK(void __iomem *addr)
 void coresight_disable_path(struct list_head *path);
 int coresight_enable_path(struct list_head *path, u32 mode);
 struct coresight_device *coresight_get_sink(struct list_head *path);
-struct list_head *coresight_build_path(struct coresight_device *csdev);
+struct list_head *coresight_build_path(struct coresight_device *csdev,
+				       const char *sink);
 void coresight_release_path(struct list_head *path);
 
 #ifdef CONFIG_CORESIGHT_SOURCE_ETM3X
diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
index d08d1ab9bba5..2b7196aa54c3 100644
--- a/drivers/hwtracing/coresight/coresight.c
+++ b/drivers/hwtracing/coresight/coresight.c
@@ -372,30 +372,44 @@ struct coresight_device *coresight_get_sink(struct list_head *path)
  * _coresight_build_path - recursively build a path from a @csdev to a sink.
  * @csdev:	The device to start from.
  * @path:	The list to add devices to.
+ * @sink:	The name of the sink this path should connect with.
  *
- * The tree of Coresight device is traversed until an activated sink is
- * found.  From there the sink is added to the list along with all the
- * devices that led to that point - the end result is a list from source
- * to sink. In that list the source is the first device and the sink the
- * last one.
+ * The tree of Coresight device is traversed until an activated sink or
+ * the one specified by @sink is found.
+ * From there the sink is added to the list along with all the devices that
+ * led to that point - the end result is a list from source to sink. In that
+ * list the source is the first device and the sink the last one.
  */
 static int _coresight_build_path(struct coresight_device *csdev,
-				 struct list_head *path)
+				 struct list_head *path, const char *sink)
 {
 	int i;
 	bool found = false;
 	struct coresight_node *node;
 
-	/* An activated sink has been found.  Enqueue the element */
-	if ((csdev->type == CORESIGHT_DEV_TYPE_SINK ||
-	     csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) && csdev->activated)
-		goto out;
+	/*
+	 * First see if we are dealing with a sink.  If we have one check if
+	 * it was selected via sysFS or the perf cmd line.
+	 */
+	if (csdev->type == CORESIGHT_DEV_TYPE_SINK ||
+	    csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) {
+		/* Discourage meddling in sysFS if using the perf interface */
+		if (sink && csdev->activated)
+			return -EINVAL;
+		/* Activated via perf cmd line */
+		if (sink && !strcmp(dev_name(&csdev->dev), sink))
+			goto out;
+		/* Activated via sysFS */
+		if (csdev->activated)
+			goto out;
+	}
 
 	/* Not a sink - recursively explore each port found on this element */
 	for (i = 0; i < csdev->nr_outport; i++) {
 		struct coresight_device *child_dev = csdev->conns[i].child_dev;
 
-		if (child_dev && _coresight_build_path(child_dev, path) == 0) {
+		if (child_dev &&
+		    _coresight_build_path(child_dev, path, sink) == 0) {
 			found = true;
 			break;
 		}
@@ -422,7 +436,8 @@ out:
 	return 0;
 }
 
-struct list_head *coresight_build_path(struct coresight_device *csdev)
+struct list_head *coresight_build_path(struct coresight_device *csdev,
+				       const char *sink)
 {
 	struct list_head *path;
 	int rc;
@@ -433,7 +448,7 @@ struct list_head *coresight_build_path(struct coresight_device *csdev)
 
 	INIT_LIST_HEAD(path);
 
-	rc = _coresight_build_path(csdev, path);
+	rc = _coresight_build_path(csdev, path, sink);
 	if (rc) {
 		kfree(path);
 		return ERR_PTR(rc);
@@ -508,7 +523,7 @@ int coresight_enable(struct coresight_device *csdev)
 	if (csdev->enable)
 		goto out;
 
-	path = coresight_build_path(csdev);
+	path = coresight_build_path(csdev, NULL);
 	if (IS_ERR(path)) {
 		pr_err("building path(s) failed\n");
 		ret = PTR_ERR(path);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH V3 5/6] coresight: adding sink parameter to function coresight_build_path()
@ 2016-07-28 21:42   ` Mathieu Poirier
  0 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-07-28 21:42 UTC (permalink / raw)
  To: linux-arm-kernel

Up to now function coresight_build_path() was counting on a sink to
have been selected (from sysFS) prior to being called.  This patch
adds a string argument so that a sink matching the argument can be
selected.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 drivers/hwtracing/coresight/coresight-etm-perf.c |  2 +-
 drivers/hwtracing/coresight/coresight-priv.h     |  3 +-
 drivers/hwtracing/coresight/coresight.c          | 43 ++++++++++++++++--------
 3 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
index f4174f36c5a0..f8c7a8733b23 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -184,7 +184,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
 		 * list of devices from source to sink that can be
 		 * referenced later when the path is actually needed.
 		 */
-		event_data->path[cpu] = coresight_build_path(csdev);
+		event_data->path[cpu] = coresight_build_path(csdev, NULL);
 		if (!event_data->path[cpu])
 			goto err;
 	}
diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h
index ad975c58080d..3cb574b3cdd9 100644
--- a/drivers/hwtracing/coresight/coresight-priv.h
+++ b/drivers/hwtracing/coresight/coresight-priv.h
@@ -94,7 +94,8 @@ static inline void CS_UNLOCK(void __iomem *addr)
 void coresight_disable_path(struct list_head *path);
 int coresight_enable_path(struct list_head *path, u32 mode);
 struct coresight_device *coresight_get_sink(struct list_head *path);
-struct list_head *coresight_build_path(struct coresight_device *csdev);
+struct list_head *coresight_build_path(struct coresight_device *csdev,
+				       const char *sink);
 void coresight_release_path(struct list_head *path);
 
 #ifdef CONFIG_CORESIGHT_SOURCE_ETM3X
diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
index d08d1ab9bba5..2b7196aa54c3 100644
--- a/drivers/hwtracing/coresight/coresight.c
+++ b/drivers/hwtracing/coresight/coresight.c
@@ -372,30 +372,44 @@ struct coresight_device *coresight_get_sink(struct list_head *path)
  * _coresight_build_path - recursively build a path from a @csdev to a sink.
  * @csdev:	The device to start from.
  * @path:	The list to add devices to.
+ * @sink:	The name of the sink this path should connect with.
  *
- * The tree of Coresight device is traversed until an activated sink is
- * found.  From there the sink is added to the list along with all the
- * devices that led to that point - the end result is a list from source
- * to sink. In that list the source is the first device and the sink the
- * last one.
+ * The tree of Coresight device is traversed until an activated sink or
+ * the one specified by @sink is found.
+ * From there the sink is added to the list along with all the devices that
+ * led to that point - the end result is a list from source to sink. In that
+ * list the source is the first device and the sink the last one.
  */
 static int _coresight_build_path(struct coresight_device *csdev,
-				 struct list_head *path)
+				 struct list_head *path, const char *sink)
 {
 	int i;
 	bool found = false;
 	struct coresight_node *node;
 
-	/* An activated sink has been found.  Enqueue the element */
-	if ((csdev->type == CORESIGHT_DEV_TYPE_SINK ||
-	     csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) && csdev->activated)
-		goto out;
+	/*
+	 * First see if we are dealing with a sink.  If we have one check if
+	 * it was selected via sysFS or the perf cmd line.
+	 */
+	if (csdev->type == CORESIGHT_DEV_TYPE_SINK ||
+	    csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) {
+		/* Discourage meddling in sysFS if using the perf interface */
+		if (sink && csdev->activated)
+			return -EINVAL;
+		/* Activated via perf cmd line */
+		if (sink && !strcmp(dev_name(&csdev->dev), sink))
+			goto out;
+		/* Activated via sysFS */
+		if (csdev->activated)
+			goto out;
+	}
 
 	/* Not a sink - recursively explore each port found on this element */
 	for (i = 0; i < csdev->nr_outport; i++) {
 		struct coresight_device *child_dev = csdev->conns[i].child_dev;
 
-		if (child_dev && _coresight_build_path(child_dev, path) == 0) {
+		if (child_dev &&
+		    _coresight_build_path(child_dev, path, sink) == 0) {
 			found = true;
 			break;
 		}
@@ -422,7 +436,8 @@ out:
 	return 0;
 }
 
-struct list_head *coresight_build_path(struct coresight_device *csdev)
+struct list_head *coresight_build_path(struct coresight_device *csdev,
+				       const char *sink)
 {
 	struct list_head *path;
 	int rc;
@@ -433,7 +448,7 @@ struct list_head *coresight_build_path(struct coresight_device *csdev)
 
 	INIT_LIST_HEAD(path);
 
-	rc = _coresight_build_path(csdev, path);
+	rc = _coresight_build_path(csdev, path, sink);
 	if (rc) {
 		kfree(path);
 		return ERR_PTR(rc);
@@ -508,7 +523,7 @@ int coresight_enable(struct coresight_device *csdev)
 	if (csdev->enable)
 		goto out;
 
-	path = coresight_build_path(csdev);
+	path = coresight_build_path(csdev, NULL);
 	if (IS_ERR(path)) {
 		pr_err("building path(s) failed\n");
 		ret = PTR_ERR(path);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH V3 6/6] coresight: etm-perf: incorporating sink definition from cmd line
  2016-07-28 21:42 ` Mathieu Poirier
@ 2016-07-28 21:42   ` Mathieu Poirier
  -1 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-07-28 21:42 UTC (permalink / raw)
  To: acme, jolsa
  Cc: peterz, mingo, linux-kernel, linux-arm-kernel, Mathieu Poirier

Now that PMU specific configuration is available as part of the event,
lookup the sink identified by users from the perf command line and build
a path from source to sink.

With this functionality it is no longer required to select a sink in a
separate step (from sysFS) before a perf trace session can be started.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 drivers/hwtracing/coresight/coresight-etm-perf.c | 101 ++++++++++++++++++++++-
 1 file changed, 100 insertions(+), 1 deletion(-)

diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
index f8c7a8733b23..5658a7411a66 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -22,6 +22,7 @@
 #include <linux/list.h>
 #include <linux/mm.h>
 #include <linux/init.h>
+#include <linux/parser.h>
 #include <linux/perf_event.h>
 #include <linux/slab.h>
 #include <linux/types.h>
@@ -71,11 +72,20 @@ static const struct attribute_group *etm_pmu_attr_groups[] = {
 
 static void etm_event_read(struct perf_event *event) {}
 
+static void etm_event_destroy(struct perf_event *event)
+{
+	kfree(event->hw.drv_configs);
+	event->hw.drv_configs = NULL;
+}
+
 static int etm_event_init(struct perf_event *event)
 {
 	if (event->attr.type != etm_pmu.type)
 		return -ENOENT;
 
+	event->destroy = etm_event_destroy;
+	event->hw.drv_configs = NULL;
+
 	return 0;
 }
 
@@ -159,6 +169,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
 			   int nr_pages, bool overwrite)
 {
 	int cpu;
+	char *cmdl_sink;
 	cpumask_t *mask;
 	struct coresight_device *sink;
 	struct etm_event_data *event_data = NULL;
@@ -171,6 +182,12 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
 
 	mask = &event_data->mask;
 
+	/*
+	 * If a sink was specified from the perf cmdline it will be part of
+	 * the event's drv_configs.
+	 */
+	cmdl_sink = (char *)event->hw.drv_configs;
+
 	/* Setup the path for each CPU in a trace session */
 	for_each_cpu(cpu, mask) {
 		struct coresight_device *csdev;
@@ -184,7 +201,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
 		 * list of devices from source to sink that can be
 		 * referenced later when the path is actually needed.
 		 */
-		event_data->path[cpu] = coresight_build_path(csdev, NULL);
+		event_data->path[cpu] = coresight_build_path(csdev, cmdl_sink);
 		if (!event_data->path[cpu])
 			goto err;
 	}
@@ -342,6 +359,87 @@ static void etm_event_del(struct perf_event *event, int mode)
 	etm_event_stop(event, PERF_EF_UPDATE);
 }
 
+enum {
+	ETM_TOKEN_SINK_CPU,
+	ETM_TOKEN_SINK,
+	ETM_TOKEN_ERR,
+};
+
+static const match_table_t drv_cfg_tokens = {
+	{ETM_TOKEN_SINK_CPU, "sink=cpu%d:%s"},
+	{ETM_TOKEN_SINK, "sink=%s"},
+	{ETM_TOKEN_ERR, NULL},
+};
+
+static int etm_set_drv_configs(struct perf_event *event, void __user *arg)
+{
+	char *config, *sink = NULL;
+	int cpu = -1, token, ret = 0;
+	substring_t args[MAX_OPT_ARGS];
+
+	/* Only one sink per event */
+	if (event->hw.drv_configs != NULL) {
+		ret = -EINVAL;
+		goto err;
+	}
+
+	/* Make user supplied input usable */
+	config = strndup_user(arg, PAGE_SIZE);
+	if (IS_ERR(config)) {
+		ret = PTR_ERR(config);
+		goto err;
+	}
+
+	/* See above declared @drv_cfg_tokens for the usable formats */
+	token = match_token(config, drv_cfg_tokens, args);
+	switch (token) {
+	case ETM_TOKEN_SINK:
+		/* Just a sink has been specified */
+		sink = match_strdup(&args[0]);
+		if (IS_ERR(sink)) {
+			ret = PTR_ERR(sink);
+			goto err;
+		}
+		break;
+	case ETM_TOKEN_SINK_CPU:
+		/* We have a sink and a CPU */
+
+		/* First get the cpu */
+		if (match_int(&args[0], &cpu)) {
+			ret = -EINVAL;
+			goto err;
+		}
+
+		/* Then the sink */
+		sink = match_strdup(&args[1]);
+		if (IS_ERR(sink)) {
+			ret = PTR_ERR(sink);
+			goto err;
+		}
+		break;
+	default:
+		ret = -EINVAL;
+		goto err;
+	}
+
+	/*
+	 * If the CPUs don't match the sink is destined to another path.  This
+	 * isn't as an error hence not setting @ret.
+	 */
+	if (event->cpu != cpu)
+		goto err;
+
+	/* We have a valid configuration */
+	event->hw.drv_configs = sink;
+
+out:
+	return ret;
+
+err:
+	kfree(sink);
+	goto out;
+}
+
 int etm_perf_symlink(struct coresight_device *csdev, bool link)
 {
 	char entry[sizeof("cpu9999999")];
@@ -383,6 +481,7 @@ static int __init etm_perf_init(void)
 	etm_pmu.stop		= etm_event_stop;
 	etm_pmu.add		= etm_event_add;
 	etm_pmu.del		= etm_event_del;
+	etm_pmu.set_drv_configs	= etm_set_drv_configs;
 
 	ret = perf_pmu_register(&etm_pmu, CORESIGHT_ETM_PMU_NAME, -1);
 	if (ret == 0)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH V3 6/6] coresight: etm-perf: incorporating sink definition from cmd line
@ 2016-07-28 21:42   ` Mathieu Poirier
  0 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-07-28 21:42 UTC (permalink / raw)
  To: linux-arm-kernel

Now that PMU specific configuration is available as part of the event,
lookup the sink identified by users from the perf command line and build
a path from source to sink.

With this functionality it is no longer required to select a sink in a
separate step (from sysFS) before a perf trace session can be started.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 drivers/hwtracing/coresight/coresight-etm-perf.c | 101 ++++++++++++++++++++++-
 1 file changed, 100 insertions(+), 1 deletion(-)

diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
index f8c7a8733b23..5658a7411a66 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -22,6 +22,7 @@
 #include <linux/list.h>
 #include <linux/mm.h>
 #include <linux/init.h>
+#include <linux/parser.h>
 #include <linux/perf_event.h>
 #include <linux/slab.h>
 #include <linux/types.h>
@@ -71,11 +72,20 @@ static const struct attribute_group *etm_pmu_attr_groups[] = {
 
 static void etm_event_read(struct perf_event *event) {}
 
+static void etm_event_destroy(struct perf_event *event)
+{
+	kfree(event->hw.drv_configs);
+	event->hw.drv_configs = NULL;
+}
+
 static int etm_event_init(struct perf_event *event)
 {
 	if (event->attr.type != etm_pmu.type)
 		return -ENOENT;
 
+	event->destroy = etm_event_destroy;
+	event->hw.drv_configs = NULL;
+
 	return 0;
 }
 
@@ -159,6 +169,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
 			   int nr_pages, bool overwrite)
 {
 	int cpu;
+	char *cmdl_sink;
 	cpumask_t *mask;
 	struct coresight_device *sink;
 	struct etm_event_data *event_data = NULL;
@@ -171,6 +182,12 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
 
 	mask = &event_data->mask;
 
+	/*
+	 * If a sink was specified from the perf cmdline it will be part of
+	 * the event's drv_configs.
+	 */
+	cmdl_sink = (char *)event->hw.drv_configs;
+
 	/* Setup the path for each CPU in a trace session */
 	for_each_cpu(cpu, mask) {
 		struct coresight_device *csdev;
@@ -184,7 +201,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
 		 * list of devices from source to sink that can be
 		 * referenced later when the path is actually needed.
 		 */
-		event_data->path[cpu] = coresight_build_path(csdev, NULL);
+		event_data->path[cpu] = coresight_build_path(csdev, cmdl_sink);
 		if (!event_data->path[cpu])
 			goto err;
 	}
@@ -342,6 +359,87 @@ static void etm_event_del(struct perf_event *event, int mode)
 	etm_event_stop(event, PERF_EF_UPDATE);
 }
 
+enum {
+	ETM_TOKEN_SINK_CPU,
+	ETM_TOKEN_SINK,
+	ETM_TOKEN_ERR,
+};
+
+static const match_table_t drv_cfg_tokens = {
+	{ETM_TOKEN_SINK_CPU, "sink=cpu%d:%s"},
+	{ETM_TOKEN_SINK, "sink=%s"},
+	{ETM_TOKEN_ERR, NULL},
+};
+
+static int etm_set_drv_configs(struct perf_event *event, void __user *arg)
+{
+	char *config, *sink = NULL;
+	int cpu = -1, token, ret = 0;
+	substring_t args[MAX_OPT_ARGS];
+
+	/* Only one sink per event */
+	if (event->hw.drv_configs != NULL) {
+		ret = -EINVAL;
+		goto err;
+	}
+
+	/* Make user supplied input usable */
+	config = strndup_user(arg, PAGE_SIZE);
+	if (IS_ERR(config)) {
+		ret = PTR_ERR(config);
+		goto err;
+	}
+
+	/* See above declared @drv_cfg_tokens for the usable formats */
+	token = match_token(config, drv_cfg_tokens, args);
+	switch (token) {
+	case ETM_TOKEN_SINK:
+		/* Just a sink has been specified */
+		sink = match_strdup(&args[0]);
+		if (IS_ERR(sink)) {
+			ret = PTR_ERR(sink);
+			goto err;
+		}
+		break;
+	case ETM_TOKEN_SINK_CPU:
+		/* We have a sink and a CPU */
+
+		/* First get the cpu */
+		if (match_int(&args[0], &cpu)) {
+			ret = -EINVAL;
+			goto err;
+		}
+
+		/* Then the sink */
+		sink = match_strdup(&args[1]);
+		if (IS_ERR(sink)) {
+			ret = PTR_ERR(sink);
+			goto err;
+		}
+		break;
+	default:
+		ret = -EINVAL;
+		goto err;
+	}
+
+	/*
+	 * If the CPUs don't match the sink is destined to another path.  This
+	 * isn't as an error hence not setting @ret.
+	 */
+	if (event->cpu != cpu)
+		goto err;
+
+	/* We have a valid configuration */
+	event->hw.drv_configs = sink;
+
+out:
+	return ret;
+
+err:
+	kfree(sink);
+	goto out;
+}
+
 int etm_perf_symlink(struct coresight_device *csdev, bool link)
 {
 	char entry[sizeof("cpu9999999")];
@@ -383,6 +481,7 @@ static int __init etm_perf_init(void)
 	etm_pmu.stop		= etm_event_stop;
 	etm_pmu.add		= etm_event_add;
 	etm_pmu.del		= etm_event_del;
+	etm_pmu.set_drv_configs	= etm_set_drv_configs;
 
 	ret = perf_pmu_register(&etm_pmu, CORESIGHT_ETM_PMU_NAME, -1);
 	if (ret == 0)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* Re: [PATCH V3 3/6] perf tools: add infrastructure for PMU specific configuration
  2016-07-28 21:42   ` Mathieu Poirier
@ 2016-07-31 12:02     ` Jiri Olsa
  -1 siblings, 0 replies; 42+ messages in thread
From: Jiri Olsa @ 2016-07-31 12:02 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: acme, jolsa, peterz, mingo, linux-kernel, linux-arm-kernel

On Thu, Jul 28, 2016 at 03:42:20PM -0600, Mathieu Poirier wrote:
> This patch adds PMU driver specific configuration to the parser
> infrastructure by preceding any term with the '@' letter.  As such
> doing something like:
> 
> perf record -e some_event/@cfg1,@cfg2=config/ ...
> 
> will see 'cfg1' and 'cfg2=config' being added to the list of evsel config
> terms.  Token 'cfg1' and 'cfg2=config' are not processed in user space
> and are meant to be interpreted by the PMU driver.
> 
> First the lexer/parser are supplemented with the required definitions to
> recognise the driver specific configuration.  From there they are simply
> added to the list of event terms.  The bulk of the work is done in
> function "parse_events_add_pmu()" where driver config event terms are
> added to a new list of driver config terms, which in turn spliced with
> the event's new driver configuration list.
> 
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH V3 3/6] perf tools: add infrastructure for PMU specific configuration
@ 2016-07-31 12:02     ` Jiri Olsa
  0 siblings, 0 replies; 42+ messages in thread
From: Jiri Olsa @ 2016-07-31 12:02 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jul 28, 2016 at 03:42:20PM -0600, Mathieu Poirier wrote:
> This patch adds PMU driver specific configuration to the parser
> infrastructure by preceding any term with the '@' letter.  As such
> doing something like:
> 
> perf record -e some_event/@cfg1, at cfg2=config/ ...
> 
> will see 'cfg1' and 'cfg2=config' being added to the list of evsel config
> terms.  Token 'cfg1' and 'cfg2=config' are not processed in user space
> and are meant to be interpreted by the PMU driver.
> 
> First the lexer/parser are supplemented with the required definitions to
> recognise the driver specific configuration.  From there they are simply
> added to the list of event terms.  The bulk of the work is done in
> function "parse_events_add_pmu()" where driver config event terms are
> added to a new list of driver config terms, which in turn spliced with
> the event's new driver configuration list.
> 
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH V3 4/6] perf tools: pushing driver configuration down to the kernel
  2016-07-28 21:42   ` Mathieu Poirier
@ 2016-07-31 12:03     ` Jiri Olsa
  -1 siblings, 0 replies; 42+ messages in thread
From: Jiri Olsa @ 2016-07-31 12:03 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: acme, jolsa, peterz, mingo, linux-kernel, linux-arm-kernel

On Thu, Jul 28, 2016 at 03:42:21PM -0600, Mathieu Poirier wrote:
> Now that PMU specific driver configuration are queued in
> evsel::config_terms, all we need to do is re-use the current
> ioctl() mechanism to push down the information to the kernel
> driver.
> 
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> ---
>  tools/perf/builtin-record.c |  9 +++++++++
>  tools/perf/builtin-stat.c   |  8 ++++++++

how about perf top?

jirka

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH V3 4/6] perf tools: pushing driver configuration down to the kernel
@ 2016-07-31 12:03     ` Jiri Olsa
  0 siblings, 0 replies; 42+ messages in thread
From: Jiri Olsa @ 2016-07-31 12:03 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jul 28, 2016 at 03:42:21PM -0600, Mathieu Poirier wrote:
> Now that PMU specific driver configuration are queued in
> evsel::config_terms, all we need to do is re-use the current
> ioctl() mechanism to push down the information to the kernel
> driver.
> 
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> ---
>  tools/perf/builtin-record.c |  9 +++++++++
>  tools/perf/builtin-stat.c   |  8 ++++++++

how about perf top?

jirka

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH V3 4/6] perf tools: pushing driver configuration down to the kernel
  2016-07-31 12:03     ` Jiri Olsa
@ 2016-08-03 21:46       ` Mathieu Poirier
  -1 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-08-03 21:46 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, jolsa, Peter Zijlstra, Ingo Molnar,
	linux-kernel, linux-arm-kernel

On 31 July 2016 at 06:03, Jiri Olsa <jolsa@redhat.com> wrote:
> On Thu, Jul 28, 2016 at 03:42:21PM -0600, Mathieu Poirier wrote:
>> Now that PMU specific driver configuration are queued in
>> evsel::config_terms, all we need to do is re-use the current
>> ioctl() mechanism to push down the information to the kernel
>> driver.
>>
>> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
>> ---
>>  tools/perf/builtin-record.c |  9 +++++++++
>>  tools/perf/builtin-stat.c   |  8 ++++++++
>
> how about perf top?

It took me a while to notice the "event" option in cmd_top().  You are
correct, it applies there as well.

Mathieu

>
> jirka

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH V3 4/6] perf tools: pushing driver configuration down to the kernel
@ 2016-08-03 21:46       ` Mathieu Poirier
  0 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-08-03 21:46 UTC (permalink / raw)
  To: linux-arm-kernel

On 31 July 2016 at 06:03, Jiri Olsa <jolsa@redhat.com> wrote:
> On Thu, Jul 28, 2016 at 03:42:21PM -0600, Mathieu Poirier wrote:
>> Now that PMU specific driver configuration are queued in
>> evsel::config_terms, all we need to do is re-use the current
>> ioctl() mechanism to push down the information to the kernel
>> driver.
>>
>> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
>> ---
>>  tools/perf/builtin-record.c |  9 +++++++++
>>  tools/perf/builtin-stat.c   |  8 ++++++++
>
> how about perf top?

It took me a while to notice the "event" option in cmd_top().  You are
correct, it applies there as well.

Mathieu

>
> jirka

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH V3 1/6] perf/core: Adding PMU driver specific configuration
  2016-07-28 21:42   ` Mathieu Poirier
@ 2016-08-04 16:58     ` Peter Zijlstra
  -1 siblings, 0 replies; 42+ messages in thread
From: Peter Zijlstra @ 2016-08-04 16:58 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: acme, jolsa, mingo, linux-kernel, linux-arm-kernel, Vince Weaver,
	Michael Kerrisk (man-pages)

On Thu, Jul 28, 2016 at 03:42:18PM -0600, Mathieu Poirier wrote:
> This patch somewhat mimics the work done on address filters to
> add the infrastructure needed to pass PMU specific HW
> configuration to the driver before a session starts.
> 
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>

> diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
> index c66a485a24ac..90fbc5fd3925 100644
> --- a/include/uapi/linux/perf_event.h
> +++ b/include/uapi/linux/perf_event.h
> @@ -407,6 +407,7 @@ struct perf_event_attr {
>  #define PERF_EVENT_IOC_ID		_IOR('$', 7, __u64 *)
>  #define PERF_EVENT_IOC_SET_BPF		_IOW('$', 8, __u32)
>  #define PERF_EVENT_IOC_PAUSE_OUTPUT	_IOW('$', 9, __u32)
> +#define PERF_EVENT_IOC_SET_DRV_CONFIGS	_IOW('$', 10, char *)

Please also do a manpages patch.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH V3 1/6] perf/core: Adding PMU driver specific configuration
@ 2016-08-04 16:58     ` Peter Zijlstra
  0 siblings, 0 replies; 42+ messages in thread
From: Peter Zijlstra @ 2016-08-04 16:58 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jul 28, 2016 at 03:42:18PM -0600, Mathieu Poirier wrote:
> This patch somewhat mimics the work done on address filters to
> add the infrastructure needed to pass PMU specific HW
> configuration to the driver before a session starts.
> 
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>

> diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
> index c66a485a24ac..90fbc5fd3925 100644
> --- a/include/uapi/linux/perf_event.h
> +++ b/include/uapi/linux/perf_event.h
> @@ -407,6 +407,7 @@ struct perf_event_attr {
>  #define PERF_EVENT_IOC_ID		_IOR('$', 7, __u64 *)
>  #define PERF_EVENT_IOC_SET_BPF		_IOW('$', 8, __u32)
>  #define PERF_EVENT_IOC_PAUSE_OUTPUT	_IOW('$', 9, __u32)
> +#define PERF_EVENT_IOC_SET_DRV_CONFIGS	_IOW('$', 10, char *)

Please also do a manpages patch.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH V3 1/6] perf/core: Adding PMU driver specific configuration
  2016-07-28 21:42   ` Mathieu Poirier
@ 2016-08-04 16:59     ` Peter Zijlstra
  -1 siblings, 0 replies; 42+ messages in thread
From: Peter Zijlstra @ 2016-08-04 16:59 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: acme, jolsa, mingo, linux-kernel, linux-arm-kernel, Alexander Shishkin

On Thu, Jul 28, 2016 at 03:42:18PM -0600, Mathieu Poirier wrote:
> This patch somewhat mimics the work done on address filters to
> add the infrastructure needed to pass PMU specific HW
> configuration to the driver before a session starts.

I'm thinking we want to specify a syntax and validate the string matches
the syntax in the generic code.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH V3 1/6] perf/core: Adding PMU driver specific configuration
@ 2016-08-04 16:59     ` Peter Zijlstra
  0 siblings, 0 replies; 42+ messages in thread
From: Peter Zijlstra @ 2016-08-04 16:59 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jul 28, 2016 at 03:42:18PM -0600, Mathieu Poirier wrote:
> This patch somewhat mimics the work done on address filters to
> add the infrastructure needed to pass PMU specific HW
> configuration to the driver before a session starts.

I'm thinking we want to specify a syntax and validate the string matches
the syntax in the generic code.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH V3 2/6] perf: Passing struct perf_event to function setup_aux()
  2016-07-28 21:42   ` Mathieu Poirier
@ 2016-08-04 17:19     ` Peter Zijlstra
  -1 siblings, 0 replies; 42+ messages in thread
From: Peter Zijlstra @ 2016-08-04 17:19 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: acme, jolsa, mingo, linux-kernel, linux-arm-kernel, Alexander Shishkin

On Thu, Jul 28, 2016 at 03:42:19PM -0600, Mathieu Poirier wrote:
> Some information, like driver specific configuration, is found
> in the hw_perf_event  structure.  As such pass a 'struct perf_event'
> to function setup_aux() rather than just the CPU number so that
> individual drivers can make the right configuration when setting
> up a session.
> 
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>

Yeah, no objection to this.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH V3 2/6] perf: Passing struct perf_event to function setup_aux()
@ 2016-08-04 17:19     ` Peter Zijlstra
  0 siblings, 0 replies; 42+ messages in thread
From: Peter Zijlstra @ 2016-08-04 17:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jul 28, 2016 at 03:42:19PM -0600, Mathieu Poirier wrote:
> Some information, like driver specific configuration, is found
> in the hw_perf_event  structure.  As such pass a 'struct perf_event'
> to function setup_aux() rather than just the CPU number so that
> individual drivers can make the right configuration when setting
> up a session.
> 
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>

Yeah, no objection to this.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH V3 1/6] perf/core: Adding PMU driver specific configuration
  2016-08-04 16:58     ` Peter Zijlstra
@ 2016-08-05 15:35       ` Mathieu Poirier
  -1 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-08-05 15:35 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Arnaldo Carvalho de Melo, jolsa, Ingo Molnar, linux-kernel,
	linux-arm-kernel, Vince Weaver, Michael Kerrisk (man-pages)

On 4 August 2016 at 10:58, Peter Zijlstra <peterz@infradead.org> wrote:
> On Thu, Jul 28, 2016 at 03:42:18PM -0600, Mathieu Poirier wrote:
>> This patch somewhat mimics the work done on address filters to
>> add the infrastructure needed to pass PMU specific HW
>> configuration to the driver before a session starts.
>>
>> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
>
>> diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
>> index c66a485a24ac..90fbc5fd3925 100644
>> --- a/include/uapi/linux/perf_event.h
>> +++ b/include/uapi/linux/perf_event.h
>> @@ -407,6 +407,7 @@ struct perf_event_attr {
>>  #define PERF_EVENT_IOC_ID            _IOR('$', 7, __u64 *)
>>  #define PERF_EVENT_IOC_SET_BPF               _IOW('$', 8, __u32)
>>  #define PERF_EVENT_IOC_PAUSE_OUTPUT  _IOW('$', 9, __u32)
>> +#define PERF_EVENT_IOC_SET_DRV_CONFIGS       _IOW('$', 10, char *)
>
> Please also do a manpages patch.

Patch 3/6 in this set documents the new option
(tools/perf/Documentation/perf-record.tx).  Is this what you were
looking for?  If not please expand on the information you want to see
added add and where.

Thanks,
Mathieu

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH V3 1/6] perf/core: Adding PMU driver specific configuration
@ 2016-08-05 15:35       ` Mathieu Poirier
  0 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-08-05 15:35 UTC (permalink / raw)
  To: linux-arm-kernel

On 4 August 2016 at 10:58, Peter Zijlstra <peterz@infradead.org> wrote:
> On Thu, Jul 28, 2016 at 03:42:18PM -0600, Mathieu Poirier wrote:
>> This patch somewhat mimics the work done on address filters to
>> add the infrastructure needed to pass PMU specific HW
>> configuration to the driver before a session starts.
>>
>> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
>
>> diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
>> index c66a485a24ac..90fbc5fd3925 100644
>> --- a/include/uapi/linux/perf_event.h
>> +++ b/include/uapi/linux/perf_event.h
>> @@ -407,6 +407,7 @@ struct perf_event_attr {
>>  #define PERF_EVENT_IOC_ID            _IOR('$', 7, __u64 *)
>>  #define PERF_EVENT_IOC_SET_BPF               _IOW('$', 8, __u32)
>>  #define PERF_EVENT_IOC_PAUSE_OUTPUT  _IOW('$', 9, __u32)
>> +#define PERF_EVENT_IOC_SET_DRV_CONFIGS       _IOW('$', 10, char *)
>
> Please also do a manpages patch.

Patch 3/6 in this set documents the new option
(tools/perf/Documentation/perf-record.tx).  Is this what you were
looking for?  If not please expand on the information you want to see
added add and where.

Thanks,
Mathieu

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH V3 1/6] perf/core: Adding PMU driver specific configuration
  2016-08-04 16:59     ` Peter Zijlstra
@ 2016-08-05 15:41       ` Mathieu Poirier
  -1 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-08-05 15:41 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Arnaldo Carvalho de Melo, jolsa, Ingo Molnar, linux-kernel,
	linux-arm-kernel, Alexander Shishkin

On 4 August 2016 at 10:59, Peter Zijlstra <peterz@infradead.org> wrote:
> On Thu, Jul 28, 2016 at 03:42:18PM -0600, Mathieu Poirier wrote:
>> This patch somewhat mimics the work done on address filters to
>> add the infrastructure needed to pass PMU specific HW
>> configuration to the driver before a session starts.
>
> I'm thinking we want to specify a syntax and validate the string matches
> the syntax in the generic code.

The syntax is checked in the lexer making sure that nothing other than
@cfg or @cfg=config is sent to the kernel.  From there validation is
done in the PMU driver that implements the set_drv_configs()
interface.

I am not sure to get you point here - can I ask you to provide more details?

Thanks,
Mathieu

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH V3 1/6] perf/core: Adding PMU driver specific configuration
@ 2016-08-05 15:41       ` Mathieu Poirier
  0 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-08-05 15:41 UTC (permalink / raw)
  To: linux-arm-kernel

On 4 August 2016 at 10:59, Peter Zijlstra <peterz@infradead.org> wrote:
> On Thu, Jul 28, 2016 at 03:42:18PM -0600, Mathieu Poirier wrote:
>> This patch somewhat mimics the work done on address filters to
>> add the infrastructure needed to pass PMU specific HW
>> configuration to the driver before a session starts.
>
> I'm thinking we want to specify a syntax and validate the string matches
> the syntax in the generic code.

The syntax is checked in the lexer making sure that nothing other than
@cfg or @cfg=config is sent to the kernel.  From there validation is
done in the PMU driver that implements the set_drv_configs()
interface.

I am not sure to get you point here - can I ask you to provide more details?

Thanks,
Mathieu

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH V3 1/6] perf/core: Adding PMU driver specific configuration
  2016-08-05 15:35       ` Mathieu Poirier
@ 2016-08-05 15:53         ` Peter Zijlstra
  -1 siblings, 0 replies; 42+ messages in thread
From: Peter Zijlstra @ 2016-08-05 15:53 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: Arnaldo Carvalho de Melo, jolsa, Ingo Molnar, linux-kernel,
	linux-arm-kernel, Vince Weaver, Michael Kerrisk (man-pages)

On Fri, Aug 05, 2016 at 09:35:05AM -0600, Mathieu Poirier wrote:
> On 4 August 2016 at 10:58, Peter Zijlstra <peterz@infradead.org> wrote:
> > On Thu, Jul 28, 2016 at 03:42:18PM -0600, Mathieu Poirier wrote:
> >> This patch somewhat mimics the work done on address filters to
> >> add the infrastructure needed to pass PMU specific HW
> >> configuration to the driver before a session starts.
> >>
> >> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> >
> >> diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
> >> index c66a485a24ac..90fbc5fd3925 100644
> >> --- a/include/uapi/linux/perf_event.h
> >> +++ b/include/uapi/linux/perf_event.h
> >> @@ -407,6 +407,7 @@ struct perf_event_attr {
> >>  #define PERF_EVENT_IOC_ID            _IOR('$', 7, __u64 *)
> >>  #define PERF_EVENT_IOC_SET_BPF               _IOW('$', 8, __u32)
> >>  #define PERF_EVENT_IOC_PAUSE_OUTPUT  _IOW('$', 9, __u32)
> >> +#define PERF_EVENT_IOC_SET_DRV_CONFIGS       _IOW('$', 10, char *)
> >
> > Please also do a manpages patch.
> 
> Patch 3/6 in this set documents the new option
> (tools/perf/Documentation/perf-record.tx).  Is this what you were
> looking for?  If not please expand on the information you want to see
> added add and where.

Since you add an IOCTL (with preferably more structure than present in
this patch, see the other email) this needs to be documented in the
syscall manpage.

  http://git.kernel.org/cgit/docs/man-pages/man-pages.git/tree/man2/perf_event_open.2

  http://www.man7.org/linux/man-pages/man2/perf_event_open.2.html

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH V3 1/6] perf/core: Adding PMU driver specific configuration
@ 2016-08-05 15:53         ` Peter Zijlstra
  0 siblings, 0 replies; 42+ messages in thread
From: Peter Zijlstra @ 2016-08-05 15:53 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Aug 05, 2016 at 09:35:05AM -0600, Mathieu Poirier wrote:
> On 4 August 2016 at 10:58, Peter Zijlstra <peterz@infradead.org> wrote:
> > On Thu, Jul 28, 2016 at 03:42:18PM -0600, Mathieu Poirier wrote:
> >> This patch somewhat mimics the work done on address filters to
> >> add the infrastructure needed to pass PMU specific HW
> >> configuration to the driver before a session starts.
> >>
> >> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> >
> >> diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
> >> index c66a485a24ac..90fbc5fd3925 100644
> >> --- a/include/uapi/linux/perf_event.h
> >> +++ b/include/uapi/linux/perf_event.h
> >> @@ -407,6 +407,7 @@ struct perf_event_attr {
> >>  #define PERF_EVENT_IOC_ID            _IOR('$', 7, __u64 *)
> >>  #define PERF_EVENT_IOC_SET_BPF               _IOW('$', 8, __u32)
> >>  #define PERF_EVENT_IOC_PAUSE_OUTPUT  _IOW('$', 9, __u32)
> >> +#define PERF_EVENT_IOC_SET_DRV_CONFIGS       _IOW('$', 10, char *)
> >
> > Please also do a manpages patch.
> 
> Patch 3/6 in this set documents the new option
> (tools/perf/Documentation/perf-record.tx).  Is this what you were
> looking for?  If not please expand on the information you want to see
> added add and where.

Since you add an IOCTL (with preferably more structure than present in
this patch, see the other email) this needs to be documented in the
syscall manpage.

  http://git.kernel.org/cgit/docs/man-pages/man-pages.git/tree/man2/perf_event_open.2

  http://www.man7.org/linux/man-pages/man2/perf_event_open.2.html

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH V3 1/6] perf/core: Adding PMU driver specific configuration
  2016-08-05 15:41       ` Mathieu Poirier
@ 2016-08-05 15:54         ` Peter Zijlstra
  -1 siblings, 0 replies; 42+ messages in thread
From: Peter Zijlstra @ 2016-08-05 15:54 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: Arnaldo Carvalho de Melo, jolsa, Ingo Molnar, linux-kernel,
	linux-arm-kernel, Alexander Shishkin

On Fri, Aug 05, 2016 at 09:41:15AM -0600, Mathieu Poirier wrote:
> On 4 August 2016 at 10:59, Peter Zijlstra <peterz@infradead.org> wrote:
> > On Thu, Jul 28, 2016 at 03:42:18PM -0600, Mathieu Poirier wrote:
> >> This patch somewhat mimics the work done on address filters to
> >> add the infrastructure needed to pass PMU specific HW
> >> configuration to the driver before a session starts.
> >
> > I'm thinking we want to specify a syntax and validate the string matches
> > the syntax in the generic code.
> 
> The syntax is checked in the lexer making sure that nothing other than
> @cfg or @cfg=config is sent to the kernel.  From there validation is
> done in the PMU driver that implements the set_drv_configs()
> interface.
> 
> I am not sure to get you point here - can I ask you to provide more details?

What keeps random userspace from sending malformed strings in? There's
more userspace than just the perf tool.

The kernel needs to validate structure.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH V3 1/6] perf/core: Adding PMU driver specific configuration
@ 2016-08-05 15:54         ` Peter Zijlstra
  0 siblings, 0 replies; 42+ messages in thread
From: Peter Zijlstra @ 2016-08-05 15:54 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Aug 05, 2016 at 09:41:15AM -0600, Mathieu Poirier wrote:
> On 4 August 2016 at 10:59, Peter Zijlstra <peterz@infradead.org> wrote:
> > On Thu, Jul 28, 2016 at 03:42:18PM -0600, Mathieu Poirier wrote:
> >> This patch somewhat mimics the work done on address filters to
> >> add the infrastructure needed to pass PMU specific HW
> >> configuration to the driver before a session starts.
> >
> > I'm thinking we want to specify a syntax and validate the string matches
> > the syntax in the generic code.
> 
> The syntax is checked in the lexer making sure that nothing other than
> @cfg or @cfg=config is sent to the kernel.  From there validation is
> done in the PMU driver that implements the set_drv_configs()
> interface.
> 
> I am not sure to get you point here - can I ask you to provide more details?

What keeps random userspace from sending malformed strings in? There's
more userspace than just the perf tool.

The kernel needs to validate structure.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH V3 2/6] perf: Passing struct perf_event to function setup_aux()
  2016-08-04 17:19     ` Peter Zijlstra
@ 2016-08-08 10:49       ` Alexander Shishkin
  -1 siblings, 0 replies; 42+ messages in thread
From: Alexander Shishkin @ 2016-08-08 10:49 UTC (permalink / raw)
  To: Peter Zijlstra, Mathieu Poirier
  Cc: acme, jolsa, mingo, linux-kernel, linux-arm-kernel

Peter Zijlstra <peterz@infradead.org> writes:

> On Thu, Jul 28, 2016 at 03:42:19PM -0600, Mathieu Poirier wrote:
>> Some information, like driver specific configuration, is found
>> in the hw_perf_event  structure.  As such pass a 'struct perf_event'
>> to function setup_aux() rather than just the CPU number so that
>> individual drivers can make the right configuration when setting
>> up a session.
>> 
>> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
>> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
>
> Yeah, no objection to this.

Sure, but I'd like a commit message that actually describes *what*
information and *why*.

Regards,
--
Alex

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH V3 2/6] perf: Passing struct perf_event to function setup_aux()
@ 2016-08-08 10:49       ` Alexander Shishkin
  0 siblings, 0 replies; 42+ messages in thread
From: Alexander Shishkin @ 2016-08-08 10:49 UTC (permalink / raw)
  To: linux-arm-kernel

Peter Zijlstra <peterz@infradead.org> writes:

> On Thu, Jul 28, 2016 at 03:42:19PM -0600, Mathieu Poirier wrote:
>> Some information, like driver specific configuration, is found
>> in the hw_perf_event  structure.  As such pass a 'struct perf_event'
>> to function setup_aux() rather than just the CPU number so that
>> individual drivers can make the right configuration when setting
>> up a session.
>> 
>> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
>> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
>
> Yeah, no objection to this.

Sure, but I'd like a commit message that actually describes *what*
information and *why*.

Regards,
--
Alex

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH V3 2/6] perf: Passing struct perf_event to function setup_aux()
  2016-08-08 10:49       ` Alexander Shishkin
@ 2016-08-08 14:38         ` Mathieu Poirier
  -1 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-08-08 14:38 UTC (permalink / raw)
  To: Alexander Shishkin
  Cc: Peter Zijlstra, Arnaldo Carvalho de Melo, jolsa, Ingo Molnar,
	linux-kernel, linux-arm-kernel

On 8 August 2016 at 04:49, Alexander Shishkin
<alexander.shishkin@linux.intel.com> wrote:
> Peter Zijlstra <peterz@infradead.org> writes:
>
>> On Thu, Jul 28, 2016 at 03:42:19PM -0600, Mathieu Poirier wrote:
>>> Some information, like driver specific configuration, is found
>>> in the hw_perf_event  structure.  As such pass a 'struct perf_event'
>>> to function setup_aux() rather than just the CPU number so that
>>> individual drivers can make the right configuration when setting
>>> up a session.
>>>
>>> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
>>> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
>>
>> Yeah, no objection to this.
>
> Sure, but I'd like a commit message that actually describes *what*
> information and *why*.

Sure, I'll make it more explicit in the next revision.

Mathieu

>
> Regards,
> --
> Alex

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH V3 2/6] perf: Passing struct perf_event to function setup_aux()
@ 2016-08-08 14:38         ` Mathieu Poirier
  0 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-08-08 14:38 UTC (permalink / raw)
  To: linux-arm-kernel

On 8 August 2016 at 04:49, Alexander Shishkin
<alexander.shishkin@linux.intel.com> wrote:
> Peter Zijlstra <peterz@infradead.org> writes:
>
>> On Thu, Jul 28, 2016 at 03:42:19PM -0600, Mathieu Poirier wrote:
>>> Some information, like driver specific configuration, is found
>>> in the hw_perf_event  structure.  As such pass a 'struct perf_event'
>>> to function setup_aux() rather than just the CPU number so that
>>> individual drivers can make the right configuration when setting
>>> up a session.
>>>
>>> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
>>> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
>>
>> Yeah, no objection to this.
>
> Sure, but I'd like a commit message that actually describes *what*
> information and *why*.

Sure, I'll make it more explicit in the next revision.

Mathieu

>
> Regards,
> --
> Alex

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH V3 1/6] perf/core: Adding PMU driver specific configuration
  2016-08-05 15:53         ` Peter Zijlstra
@ 2016-08-10 23:07           ` Mathieu Poirier
  -1 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-08-10 23:07 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Arnaldo Carvalho de Melo, jolsa, Ingo Molnar, linux-kernel,
	linux-arm-kernel, Vince Weaver, Michael Kerrisk (man-pages)

On 5 August 2016 at 09:53, Peter Zijlstra <peterz@infradead.org> wrote:
> On Fri, Aug 05, 2016 at 09:35:05AM -0600, Mathieu Poirier wrote:
>> On 4 August 2016 at 10:58, Peter Zijlstra <peterz@infradead.org> wrote:
>> > On Thu, Jul 28, 2016 at 03:42:18PM -0600, Mathieu Poirier wrote:
>> >> This patch somewhat mimics the work done on address filters to
>> >> add the infrastructure needed to pass PMU specific HW
>> >> configuration to the driver before a session starts.
>> >>
>> >> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
>> >
>> >> diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
>> >> index c66a485a24ac..90fbc5fd3925 100644
>> >> --- a/include/uapi/linux/perf_event.h
>> >> +++ b/include/uapi/linux/perf_event.h
>> >> @@ -407,6 +407,7 @@ struct perf_event_attr {
>> >>  #define PERF_EVENT_IOC_ID            _IOR('$', 7, __u64 *)
>> >>  #define PERF_EVENT_IOC_SET_BPF               _IOW('$', 8, __u32)
>> >>  #define PERF_EVENT_IOC_PAUSE_OUTPUT  _IOW('$', 9, __u32)
>> >> +#define PERF_EVENT_IOC_SET_DRV_CONFIGS       _IOW('$', 10, char *)
>> >
>> > Please also do a manpages patch.
>>
>> Patch 3/6 in this set documents the new option
>> (tools/perf/Documentation/perf-record.tx).  Is this what you were
>> looking for?  If not please expand on the information you want to see
>> added add and where.
>
> Since you add an IOCTL (with preferably more structure than present in
> this patch, see the other email) this needs to be documented in the
> syscall manpage.
>
>   http://git.kernel.org/cgit/docs/man-pages/man-pages.git/tree/man2/perf_event_open.2
>
>   http://www.man7.org/linux/man-pages/man2/perf_event_open.2.html

After a little bit of digging around I understand that manpages have
to be written _after_ the new ioctl call has been added - at least
that's what I deduce when looking at what Vince Weaver did for the BPF
support:

commit b0f7b411bed0505937f0f51d6499d0c6c56f4b8c
Author: Vince Weaver <vincent.weaver@maine.edu>
Date:   Thu Jul 23 13:10:21 2015 -0400

    perf_event_open.2: 4.1 PERF_EVENT_IOC_SET_BPF support

    This manpage patch relates to the addition of the
    PERF_EVENT_IOC_SET_BPF ioctl in the following commit:

        commit 2541517c32be2531e0da59dfd7efc1ce844644f5
        Author: Alexei Starovoitov <ast@plumgrid.com>

        tracing, perf: Implement BPF programs attached to kprobes

        Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
        Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
        Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
        Cc: Andrew Morton <akpm@linux-foundation.org>
        Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
        Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
        Cc: Daniel Borkmann <daniel@iogearbox.net>
        Cc: David S. Miller <davem@davemloft.net>
        Cc: Jiri Olsa <jolsa@redhat.com>
        Cc: Linus Torvalds <torvalds@linux-foundation.org>
        Cc: Namhyung Kim <namhyung@kernel.org>
        Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
        Cc: Peter Zijlstra <peterz@infradead.org>
        Link: http://lkml.kernel.org/r/1427312966-8434-4-git-send-email-ast@plumgrid.com
        Signed-off-by: Ingo Molnar <mingo@kernel.org>

    Signed-off-by: Vince Weaver <vincent.weaver@maine.edu>
    Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>

Am I correct here or you want to proceed differently?

Thanks for the guidance,
Mathieu

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH V3 1/6] perf/core: Adding PMU driver specific configuration
@ 2016-08-10 23:07           ` Mathieu Poirier
  0 siblings, 0 replies; 42+ messages in thread
From: Mathieu Poirier @ 2016-08-10 23:07 UTC (permalink / raw)
  To: linux-arm-kernel

On 5 August 2016 at 09:53, Peter Zijlstra <peterz@infradead.org> wrote:
> On Fri, Aug 05, 2016 at 09:35:05AM -0600, Mathieu Poirier wrote:
>> On 4 August 2016 at 10:58, Peter Zijlstra <peterz@infradead.org> wrote:
>> > On Thu, Jul 28, 2016 at 03:42:18PM -0600, Mathieu Poirier wrote:
>> >> This patch somewhat mimics the work done on address filters to
>> >> add the infrastructure needed to pass PMU specific HW
>> >> configuration to the driver before a session starts.
>> >>
>> >> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
>> >
>> >> diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
>> >> index c66a485a24ac..90fbc5fd3925 100644
>> >> --- a/include/uapi/linux/perf_event.h
>> >> +++ b/include/uapi/linux/perf_event.h
>> >> @@ -407,6 +407,7 @@ struct perf_event_attr {
>> >>  #define PERF_EVENT_IOC_ID            _IOR('$', 7, __u64 *)
>> >>  #define PERF_EVENT_IOC_SET_BPF               _IOW('$', 8, __u32)
>> >>  #define PERF_EVENT_IOC_PAUSE_OUTPUT  _IOW('$', 9, __u32)
>> >> +#define PERF_EVENT_IOC_SET_DRV_CONFIGS       _IOW('$', 10, char *)
>> >
>> > Please also do a manpages patch.
>>
>> Patch 3/6 in this set documents the new option
>> (tools/perf/Documentation/perf-record.tx).  Is this what you were
>> looking for?  If not please expand on the information you want to see
>> added add and where.
>
> Since you add an IOCTL (with preferably more structure than present in
> this patch, see the other email) this needs to be documented in the
> syscall manpage.
>
>   http://git.kernel.org/cgit/docs/man-pages/man-pages.git/tree/man2/perf_event_open.2
>
>   http://www.man7.org/linux/man-pages/man2/perf_event_open.2.html

After a little bit of digging around I understand that manpages have
to be written _after_ the new ioctl call has been added - at least
that's what I deduce when looking at what Vince Weaver did for the BPF
support:

commit b0f7b411bed0505937f0f51d6499d0c6c56f4b8c
Author: Vince Weaver <vincent.weaver@maine.edu>
Date:   Thu Jul 23 13:10:21 2015 -0400

    perf_event_open.2: 4.1 PERF_EVENT_IOC_SET_BPF support

    This manpage patch relates to the addition of the
    PERF_EVENT_IOC_SET_BPF ioctl in the following commit:

        commit 2541517c32be2531e0da59dfd7efc1ce844644f5
        Author: Alexei Starovoitov <ast@plumgrid.com>

        tracing, perf: Implement BPF programs attached to kprobes

        Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
        Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
        Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
        Cc: Andrew Morton <akpm@linux-foundation.org>
        Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
        Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
        Cc: Daniel Borkmann <daniel@iogearbox.net>
        Cc: David S. Miller <davem@davemloft.net>
        Cc: Jiri Olsa <jolsa@redhat.com>
        Cc: Linus Torvalds <torvalds@linux-foundation.org>
        Cc: Namhyung Kim <namhyung@kernel.org>
        Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
        Cc: Peter Zijlstra <peterz@infradead.org>
        Link: http://lkml.kernel.org/r/1427312966-8434-4-git-send-email-ast at plumgrid.com
        Signed-off-by: Ingo Molnar <mingo@kernel.org>

    Signed-off-by: Vince Weaver <vincent.weaver@maine.edu>
    Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>

Am I correct here or you want to proceed differently?

Thanks for the guidance,
Mathieu

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH V3 1/6] perf/core: Adding PMU driver specific configuration
  2016-08-10 23:07           ` Mathieu Poirier
@ 2016-08-11  3:27             ` Vince Weaver
  -1 siblings, 0 replies; 42+ messages in thread
From: Vince Weaver @ 2016-08-11  3:27 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: Peter Zijlstra, Arnaldo Carvalho de Melo, jolsa, Ingo Molnar,
	linux-kernel, linux-arm-kernel, Michael Kerrisk (man-pages)

On Wed, 10 Aug 2016, Mathieu Poirier wrote:
> 
> After a little bit of digging around I understand that manpages have
> to be written _after_ the new ioctl call has been added - at least
> that's what I deduce when looking at what Vince Weaver did for the BPF
> support:

The manpage patch doesn't get applied until a feature hits a release 
kernel (because sometimes features are backed out at the last minute).

It is good to have a manpage update ready at the time of your initial 
patch submission though for a variety of reasons

1. It helps the patch reviewers see what ABI change is being proposed
2. It is better to catch mistakes in the ABI early rather than trying
	to fix them after it's hit a released kernel and it's too late
3. By the time the kernel is released, you might have forgotten details
	about the change, or moved on to other things, and then it's up
	to me to try to figure out the purpose of the change and
	unfortunately this isn't always obvious from the git commit logs.

Vince

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH V3 1/6] perf/core: Adding PMU driver specific configuration
@ 2016-08-11  3:27             ` Vince Weaver
  0 siblings, 0 replies; 42+ messages in thread
From: Vince Weaver @ 2016-08-11  3:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 10 Aug 2016, Mathieu Poirier wrote:
> 
> After a little bit of digging around I understand that manpages have
> to be written _after_ the new ioctl call has been added - at least
> that's what I deduce when looking at what Vince Weaver did for the BPF
> support:

The manpage patch doesn't get applied until a feature hits a release 
kernel (because sometimes features are backed out at the last minute).

It is good to have a manpage update ready at the time of your initial 
patch submission though for a variety of reasons

1. It helps the patch reviewers see what ABI change is being proposed
2. It is better to catch mistakes in the ABI early rather than trying
	to fix them after it's hit a released kernel and it's too late
3. By the time the kernel is released, you might have forgotten details
	about the change, or moved on to other things, and then it's up
	to me to try to figure out the purpose of the change and
	unfortunately this isn't always obvious from the git commit logs.

Vince

^ permalink raw reply	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2016-08-11  3:27 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-28 21:42 [PATCH V3 0/6] perf: Driver specific configuration for PMU Mathieu Poirier
2016-07-28 21:42 ` Mathieu Poirier
2016-07-28 21:42 ` [PATCH V3 1/6] perf/core: Adding PMU driver specific configuration Mathieu Poirier
2016-07-28 21:42   ` Mathieu Poirier
2016-08-04 16:58   ` Peter Zijlstra
2016-08-04 16:58     ` Peter Zijlstra
2016-08-05 15:35     ` Mathieu Poirier
2016-08-05 15:35       ` Mathieu Poirier
2016-08-05 15:53       ` Peter Zijlstra
2016-08-05 15:53         ` Peter Zijlstra
2016-08-10 23:07         ` Mathieu Poirier
2016-08-10 23:07           ` Mathieu Poirier
2016-08-11  3:27           ` Vince Weaver
2016-08-11  3:27             ` Vince Weaver
2016-08-04 16:59   ` Peter Zijlstra
2016-08-04 16:59     ` Peter Zijlstra
2016-08-05 15:41     ` Mathieu Poirier
2016-08-05 15:41       ` Mathieu Poirier
2016-08-05 15:54       ` Peter Zijlstra
2016-08-05 15:54         ` Peter Zijlstra
2016-07-28 21:42 ` [PATCH V3 2/6] perf: Passing struct perf_event to function setup_aux() Mathieu Poirier
2016-07-28 21:42   ` Mathieu Poirier
2016-08-04 17:19   ` Peter Zijlstra
2016-08-04 17:19     ` Peter Zijlstra
2016-08-08 10:49     ` Alexander Shishkin
2016-08-08 10:49       ` Alexander Shishkin
2016-08-08 14:38       ` Mathieu Poirier
2016-08-08 14:38         ` Mathieu Poirier
2016-07-28 21:42 ` [PATCH V3 3/6] perf tools: add infrastructure for PMU specific configuration Mathieu Poirier
2016-07-28 21:42   ` Mathieu Poirier
2016-07-31 12:02   ` Jiri Olsa
2016-07-31 12:02     ` Jiri Olsa
2016-07-28 21:42 ` [PATCH V3 4/6] perf tools: pushing driver configuration down to the kernel Mathieu Poirier
2016-07-28 21:42   ` Mathieu Poirier
2016-07-31 12:03   ` Jiri Olsa
2016-07-31 12:03     ` Jiri Olsa
2016-08-03 21:46     ` Mathieu Poirier
2016-08-03 21:46       ` Mathieu Poirier
2016-07-28 21:42 ` [PATCH V3 5/6] coresight: adding sink parameter to function coresight_build_path() Mathieu Poirier
2016-07-28 21:42   ` Mathieu Poirier
2016-07-28 21:42 ` [PATCH V3 6/6] coresight: etm-perf: incorporating sink definition from cmd line Mathieu Poirier
2016-07-28 21:42   ` Mathieu Poirier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.