* [PATCH 0/6] coresight: next v5.0-rc5
@ 2019-02-05 23:24 Mathieu Poirier
2019-02-05 23:24 ` [PATCH 1/6] coresight: cpu-debug: Support for CA73 CPUs Mathieu Poirier
` (5 more replies)
0 siblings, 6 replies; 12+ messages in thread
From: Mathieu Poirier @ 2019-02-05 23:24 UTC (permalink / raw)
To: gregkh; +Cc: linux-arm-kernel, linux-kernel
Hi Greg,
Here is what I collected for inclusion in the 5.1 cycle, please have a look when
you have a minute.
Applies cleanly on the char-misc-next branch (9f23379c67fa).
Thanks,
Mathieu
Leo Yan (1):
coresight: cpu-debug: Support for CA73 CPUs
Mathieu Poirier (3):
perf/aux: Make perf_event accessible to setup_aux()
coresight: perf: Add "sinks" group to PMU directory
coresight: Use event attributes for sink selection
Rob Herring (1):
coresight: Use of_node_name_eq for node name comparisons
YueHaibing (1):
coresight: stm: Remove set but not used variable 'res_size'
arch/s390/kernel/perf_cpum_sf.c | 6 +-
arch/x86/events/intel/bts.c | 4 +-
arch/x86/events/intel/pt.c | 5 +-
.../hwtracing/coresight/coresight-cpu-debug.c | 4 +
.../hwtracing/coresight/coresight-etm-perf.c | 112 +++++++++++++++---
.../hwtracing/coresight/coresight-etm-perf.h | 6 +-
drivers/hwtracing/coresight/coresight-priv.h | 1 +
drivers/hwtracing/coresight/coresight-stm.c | 12 +-
drivers/hwtracing/coresight/coresight.c | 60 ++++++++++
drivers/hwtracing/coresight/of_coresight.c | 4 +-
drivers/perf/arm_spe_pmu.c | 6 +-
include/linux/coresight.h | 7 +-
include/linux/perf_event.h | 2 +-
kernel/events/ring_buffer.c | 2 +-
14 files changed, 192 insertions(+), 39 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/6] coresight: cpu-debug: Support for CA73 CPUs
2019-02-05 23:24 [PATCH 0/6] coresight: next v5.0-rc5 Mathieu Poirier
@ 2019-02-05 23:24 ` Mathieu Poirier
2019-02-05 23:24 ` [PATCH 2/6] coresight: stm: Remove set but not used variable 'res_size' Mathieu Poirier
` (4 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: Mathieu Poirier @ 2019-02-05 23:24 UTC (permalink / raw)
To: gregkh; +Cc: linux-arm-kernel, linux-kernel
From: Leo Yan <leo.yan@linaro.org>
This patch is to add the AMBA device ID for CA73 CPU, so that CPU debug
module can be initialized successfully when a SoC contain CA73 CPUs.
This patch has been verified on 96boards Hikey960.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
drivers/hwtracing/coresight/coresight-cpu-debug.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/hwtracing/coresight/coresight-cpu-debug.c b/drivers/hwtracing/coresight/coresight-cpu-debug.c
index 45b2460f3166..e8819d750938 100644
--- a/drivers/hwtracing/coresight/coresight-cpu-debug.c
+++ b/drivers/hwtracing/coresight/coresight-cpu-debug.c
@@ -668,6 +668,10 @@ static const struct amba_id debug_ids[] = {
.id = 0x000bbd08,
.mask = 0x000fffff,
},
+ { /* Debug for Cortex-A73 */
+ .id = 0x000bbd09,
+ .mask = 0x000fffff,
+ },
{ 0, 0 },
};
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/6] coresight: stm: Remove set but not used variable 'res_size'
2019-02-05 23:24 [PATCH 0/6] coresight: next v5.0-rc5 Mathieu Poirier
2019-02-05 23:24 ` [PATCH 1/6] coresight: cpu-debug: Support for CA73 CPUs Mathieu Poirier
@ 2019-02-05 23:24 ` Mathieu Poirier
2019-02-05 23:24 ` [PATCH 3/6] coresight: Use of_node_name_eq for node name comparisons Mathieu Poirier
` (3 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: Mathieu Poirier @ 2019-02-05 23:24 UTC (permalink / raw)
To: gregkh; +Cc: linux-arm-kernel, linux-kernel
From: YueHaibing <yuehaibing@huawei.com>
Fixes gcc '-Wunused-but-set-variable' warning:
drivers/hwtracing/coresight/coresight-stm.c: In function 'stm_probe':
drivers/hwtracing/coresight/coresight-stm.c:796:9: warning:
variable 'res_size' set but not used [-Wunused-but-set-variable]
It never used since introduction in commit 237483aa5cf4 ("coresight: stm:
adding driver for CoreSight STM component")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Tested-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
drivers/hwtracing/coresight/coresight-stm.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c
index ef339ff22090..f07825df5c7a 100644
--- a/drivers/hwtracing/coresight/coresight-stm.c
+++ b/drivers/hwtracing/coresight/coresight-stm.c
@@ -793,7 +793,7 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
struct stm_drvdata *drvdata;
struct resource *res = &adev->res;
struct resource ch_res;
- size_t res_size, bitmap_size;
+ size_t bitmap_size;
struct coresight_desc desc = { 0 };
struct device_node *np = adev->dev.of_node;
@@ -833,15 +833,11 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
drvdata->write_bytes = stm_fundamental_data_size(drvdata);
- if (boot_nr_channel) {
+ if (boot_nr_channel)
drvdata->numsp = boot_nr_channel;
- res_size = min((resource_size_t)(boot_nr_channel *
- BYTES_PER_CHANNEL), resource_size(res));
- } else {
+ else
drvdata->numsp = stm_num_stimulus_port(drvdata);
- res_size = min((resource_size_t)(drvdata->numsp *
- BYTES_PER_CHANNEL), resource_size(res));
- }
+
bitmap_size = BITS_TO_LONGS(drvdata->numsp) * sizeof(long);
guaranteed = devm_kzalloc(dev, bitmap_size, GFP_KERNEL);
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/6] coresight: Use of_node_name_eq for node name comparisons
2019-02-05 23:24 [PATCH 0/6] coresight: next v5.0-rc5 Mathieu Poirier
2019-02-05 23:24 ` [PATCH 1/6] coresight: cpu-debug: Support for CA73 CPUs Mathieu Poirier
2019-02-05 23:24 ` [PATCH 2/6] coresight: stm: Remove set but not used variable 'res_size' Mathieu Poirier
@ 2019-02-05 23:24 ` Mathieu Poirier
2019-02-05 23:24 ` [PATCH 4/6] perf/aux: Make perf_event accessible to setup_aux() Mathieu Poirier
` (2 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: Mathieu Poirier @ 2019-02-05 23:24 UTC (permalink / raw)
To: gregkh; +Cc: linux-arm-kernel, linux-kernel
From: Rob Herring <robh@kernel.org>
Convert string compares of DT node names to use of_node_name_eq helper
instead. This removes direct access to the node name pointer.
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
drivers/hwtracing/coresight/of_coresight.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c
index 89092f83567e..7045930fc958 100644
--- a/drivers/hwtracing/coresight/of_coresight.c
+++ b/drivers/hwtracing/coresight/of_coresight.c
@@ -80,8 +80,8 @@ static struct device_node *of_coresight_get_port_parent(struct device_node *ep)
* Skip one-level up to the real device node, if we
* are using the new bindings.
*/
- if (!of_node_cmp(parent->name, "in-ports") ||
- !of_node_cmp(parent->name, "out-ports"))
+ if (of_node_name_eq(parent, "in-ports") ||
+ of_node_name_eq(parent, "out-ports"))
parent = of_get_next_parent(parent);
return parent;
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/6] perf/aux: Make perf_event accessible to setup_aux()
2019-02-05 23:24 [PATCH 0/6] coresight: next v5.0-rc5 Mathieu Poirier
` (2 preceding siblings ...)
2019-02-05 23:24 ` [PATCH 3/6] coresight: Use of_node_name_eq for node name comparisons Mathieu Poirier
@ 2019-02-05 23:24 ` Mathieu Poirier
2019-02-05 23:24 ` [PATCH 5/6] coresight: perf: Add "sinks" group to PMU directory Mathieu Poirier
2019-02-05 23:24 ` [PATCH 6/6] coresight: Use event attributes for sink selection Mathieu Poirier
5 siblings, 0 replies; 12+ messages in thread
From: Mathieu Poirier @ 2019-02-05 23:24 UTC (permalink / raw)
To: gregkh; +Cc: linux-arm-kernel, linux-kernel
When pmu::setup_aux() is called the coresight PMU needs to know which
sink to use for the session by looking up the information in the
event's attr::config2 field.
As such simply replace the cpu information by the complete perf_event
structure and change all affected customers.
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/s390/kernel/perf_cpum_sf.c | 6 +++---
arch/x86/events/intel/bts.c | 4 +++-
arch/x86/events/intel/pt.c | 5 +++--
drivers/hwtracing/coresight/coresight-etm-perf.c | 6 +++---
drivers/perf/arm_spe_pmu.c | 6 +++---
include/linux/perf_event.h | 2 +-
kernel/events/ring_buffer.c | 2 +-
7 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c
index bfabeb1889cc..1266194afb02 100644
--- a/arch/s390/kernel/perf_cpum_sf.c
+++ b/arch/s390/kernel/perf_cpum_sf.c
@@ -1600,7 +1600,7 @@ static void aux_sdb_init(unsigned long sdb)
/*
* aux_buffer_setup() - Setup AUX buffer for diagnostic mode sampling
- * @cpu: On which to allocate, -1 means current
+ * @event: Event the buffer is setup for, event->cpu == -1 means current
* @pages: Array of pointers to buffer pages passed from perf core
* @nr_pages: Total pages
* @snapshot: Flag for snapshot mode
@@ -1612,8 +1612,8 @@ static void aux_sdb_init(unsigned long sdb)
*
* Return the private AUX buffer structure if success or NULL if fails.
*/
-static void *aux_buffer_setup(int cpu, void **pages, int nr_pages,
- bool snapshot)
+static void *aux_buffer_setup(struct perf_event *event, void **pages,
+ int nr_pages, bool snapshot)
{
struct sf_buffer *sfb;
struct aux_buffer *aux;
diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c
index a01ef1b0f883..7cdd7b13bbda 100644
--- a/arch/x86/events/intel/bts.c
+++ b/arch/x86/events/intel/bts.c
@@ -77,10 +77,12 @@ 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)
{
struct bts_buffer *buf;
struct page *page;
+ int cpu = event->cpu;
int node = (cpu == -1) ? cpu : cpu_to_node(cpu);
unsigned long offset;
size_t size = nr_pages << PAGE_SHIFT;
diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
index 9494ca68fd9d..c0e86ff21f81 100644
--- a/arch/x86/events/intel/pt.c
+++ b/arch/x86/events/intel/pt.c
@@ -1114,10 +1114,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 abe8249b893b..f21eb28b6782 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -177,15 +177,15 @@ 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;
+ int cpu = event->cpu;
cpumask_t *mask;
struct coresight_device *sink;
struct etm_event_data *event_data = NULL;
- event_data = alloc_event_data(event_cpu);
+ event_data = alloc_event_data(cpu);
if (!event_data)
return NULL;
INIT_WORK(&event_data->work, free_event_data);
diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c
index 8e46a9dad2fa..7cb766dafe85 100644
--- a/drivers/perf/arm_spe_pmu.c
+++ b/drivers/perf/arm_spe_pmu.c
@@ -824,10 +824,10 @@ static void arm_spe_pmu_read(struct perf_event *event)
{
}
-static void *arm_spe_pmu_setup_aux(int cpu, void **pages, int nr_pages,
- bool snapshot)
+static void *arm_spe_pmu_setup_aux(struct perf_event *event, void **pages,
+ int nr_pages, bool snapshot)
{
- int i;
+ int i, cpu = event->cpu;
struct page **pglist;
struct arm_spe_pmu_buf *buf;
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 1d5c551a5add..3e49b2144808 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -409,7 +409,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 4a9937076331..857308295f63 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -658,7 +658,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.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 5/6] coresight: perf: Add "sinks" group to PMU directory
2019-02-05 23:24 [PATCH 0/6] coresight: next v5.0-rc5 Mathieu Poirier
` (3 preceding siblings ...)
2019-02-05 23:24 ` [PATCH 4/6] perf/aux: Make perf_event accessible to setup_aux() Mathieu Poirier
@ 2019-02-05 23:24 ` Mathieu Poirier
2019-02-05 23:24 ` [PATCH 6/6] coresight: Use event attributes for sink selection Mathieu Poirier
5 siblings, 0 replies; 12+ messages in thread
From: Mathieu Poirier @ 2019-02-05 23:24 UTC (permalink / raw)
To: gregkh; +Cc: linux-arm-kernel, linux-kernel
Add a "sinks" directory entry so that users can see all the sinks
available in the system in a single place. Individual sink are added
as they are registered with the coresight bus.
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
.../hwtracing/coresight/coresight-etm-perf.c | 82 +++++++++++++++++++
.../hwtracing/coresight/coresight-etm-perf.h | 6 +-
drivers/hwtracing/coresight/coresight.c | 18 ++++
include/linux/coresight.h | 7 +-
4 files changed, 110 insertions(+), 3 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
index f21eb28b6782..cdbdb28dc175 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -14,6 +14,7 @@
#include <linux/perf_event.h>
#include <linux/percpu-defs.h>
#include <linux/slab.h>
+#include <linux/stringhash.h>
#include <linux/types.h>
#include <linux/workqueue.h>
@@ -43,8 +44,18 @@ static const struct attribute_group etm_pmu_format_group = {
.attrs = etm_config_formats_attr,
};
+static struct attribute *etm_config_sinks_attr[] = {
+ NULL,
+};
+
+static const struct attribute_group etm_pmu_sinks_group = {
+ .name = "sinks",
+ .attrs = etm_config_sinks_attr,
+};
+
static const struct attribute_group *etm_pmu_attr_groups[] = {
&etm_pmu_format_group,
+ &etm_pmu_sinks_group,
NULL,
};
@@ -479,6 +490,77 @@ int etm_perf_symlink(struct coresight_device *csdev, bool link)
return 0;
}
+static ssize_t etm_perf_sink_name_show(struct device *dev,
+ struct device_attribute *dattr,
+ char *buf)
+{
+ struct dev_ext_attribute *ea;
+
+ ea = container_of(dattr, struct dev_ext_attribute, attr);
+ return scnprintf(buf, PAGE_SIZE, "0x%lx\n", (unsigned long)(ea->var));
+}
+
+int etm_perf_add_symlink_sink(struct coresight_device *csdev)
+{
+ int ret;
+ unsigned long hash;
+ const char *name;
+ struct device *pmu_dev = etm_pmu.dev;
+ struct device *pdev = csdev->dev.parent;
+ struct dev_ext_attribute *ea;
+
+ if (csdev->type != CORESIGHT_DEV_TYPE_SINK &&
+ csdev->type != CORESIGHT_DEV_TYPE_LINKSINK)
+ return -EINVAL;
+
+ if (csdev->ea != NULL)
+ return -EINVAL;
+
+ if (!etm_perf_up)
+ return -EPROBE_DEFER;
+
+ ea = devm_kzalloc(pdev, sizeof(*ea), GFP_KERNEL);
+ if (!ea)
+ return -ENOMEM;
+
+ name = dev_name(pdev);
+ /* See function coresight_get_sink_by_id() to know where this is used */
+ hash = hashlen_hash(hashlen_string(NULL, name));
+
+ ea->attr.attr.name = devm_kstrdup(pdev, name, GFP_KERNEL);
+ if (!ea->attr.attr.name)
+ return -ENOMEM;
+
+ ea->attr.attr.mode = 0444;
+ ea->attr.show = etm_perf_sink_name_show;
+ ea->var = (unsigned long *)hash;
+
+ ret = sysfs_add_file_to_group(&pmu_dev->kobj,
+ &ea->attr.attr, "sinks");
+
+ if (!ret)
+ csdev->ea = ea;
+
+ return ret;
+}
+
+void etm_perf_del_symlink_sink(struct coresight_device *csdev)
+{
+ struct device *pmu_dev = etm_pmu.dev;
+ struct dev_ext_attribute *ea = csdev->ea;
+
+ if (csdev->type != CORESIGHT_DEV_TYPE_SINK &&
+ csdev->type != CORESIGHT_DEV_TYPE_LINKSINK)
+ return;
+
+ if (!ea)
+ return;
+
+ sysfs_remove_file_from_group(&pmu_dev->kobj,
+ &ea->attr.attr, "sinks");
+ csdev->ea = NULL;
+}
+
static int __init etm_perf_init(void)
{
int ret;
diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.h b/drivers/hwtracing/coresight/coresight-etm-perf.h
index da7d9336a15c..015213abe00a 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.h
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.h
@@ -59,6 +59,8 @@ struct etm_event_data {
#ifdef CONFIG_CORESIGHT
int etm_perf_symlink(struct coresight_device *csdev, bool link);
+int etm_perf_add_symlink_sink(struct coresight_device *csdev);
+void etm_perf_del_symlink_sink(struct coresight_device *csdev);
static inline void *etm_perf_sink_config(struct perf_output_handle *handle)
{
struct etm_event_data *data = perf_get_aux(handle);
@@ -70,7 +72,9 @@ static inline void *etm_perf_sink_config(struct perf_output_handle *handle)
#else
static inline int etm_perf_symlink(struct coresight_device *csdev, bool link)
{ return -EINVAL; }
-
+int etm_perf_add_symlink_sink(struct coresight_device *csdev)
+{ return -EINVAL; }
+void etm_perf_del_symlink_sink(struct coresight_device *csdev) {}
static inline void *etm_perf_sink_config(struct perf_output_handle *handle)
{
return NULL;
diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
index 2b0df1a0a8df..d7fa90be6f42 100644
--- a/drivers/hwtracing/coresight/coresight.c
+++ b/drivers/hwtracing/coresight/coresight.c
@@ -18,6 +18,7 @@
#include <linux/delay.h>
#include <linux/pm_runtime.h>
+#include "coresight-etm-perf.h"
#include "coresight-priv.h"
static DEFINE_MUTEX(coresight_mutex);
@@ -1167,6 +1168,22 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
goto err_out;
}
+ if (csdev->type == CORESIGHT_DEV_TYPE_SINK ||
+ csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) {
+ ret = etm_perf_add_symlink_sink(csdev);
+
+ if (ret) {
+ device_unregister(&csdev->dev);
+ /*
+ * As with the above, all resources are free'd
+ * explicitly via coresight_device_release() triggered
+ * from put_device(), which is in turn called from
+ * function device_unregister().
+ */
+ goto err_out;
+ }
+ }
+
mutex_lock(&coresight_mutex);
coresight_fixup_device_conns(csdev);
@@ -1185,6 +1202,7 @@ EXPORT_SYMBOL_GPL(coresight_register);
void coresight_unregister(struct coresight_device *csdev)
{
+ etm_perf_del_symlink_sink(csdev);
/* Remove references of that device in the topology */
coresight_remove_conns(csdev);
device_unregister(&csdev->dev);
diff --git a/include/linux/coresight.h b/include/linux/coresight.h
index 46c67a764877..7b87965f7a65 100644
--- a/include/linux/coresight.h
+++ b/include/linux/coresight.h
@@ -154,8 +154,9 @@ struct coresight_connection {
* @orphan: true if the component has connections that haven't been linked.
* @enable: 'true' if component is currently part of an active path.
* @activated: 'true' only if a _sink_ has been activated. A sink can be
- activated but not yet enabled. Enabling for a _sink_
- happens when a source has been selected for that it.
+ * activated but not yet enabled. Enabling for a _sink_
+ * appens when a source has been selected for that it.
+ * @ea: Device attribute for sink representation under PMU directory.
*/
struct coresight_device {
struct coresight_connection *conns;
@@ -168,7 +169,9 @@ struct coresight_device {
atomic_t *refcnt;
bool orphan;
bool enable; /* true only if configured as part of a path */
+ /* sink specific fields */
bool activated; /* true only if a sink is part of a path */
+ struct dev_ext_attribute *ea;
};
#define to_coresight_device(d) container_of(d, struct coresight_device, dev)
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 6/6] coresight: Use event attributes for sink selection
2019-02-05 23:24 [PATCH 0/6] coresight: next v5.0-rc5 Mathieu Poirier
` (4 preceding siblings ...)
2019-02-05 23:24 ` [PATCH 5/6] coresight: perf: Add "sinks" group to PMU directory Mathieu Poirier
@ 2019-02-05 23:24 ` Mathieu Poirier
5 siblings, 0 replies; 12+ messages in thread
From: Mathieu Poirier @ 2019-02-05 23:24 UTC (permalink / raw)
To: gregkh; +Cc: linux-arm-kernel, linux-kernel
This patch uses the information conveyed by perf_event::attr::config2
to select a sink to use for the session. That way a sink can easily be
selected to be used by more than one source, something that isn't currently
possible with the sysfs implementation.
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
.../hwtracing/coresight/coresight-etm-perf.c | 24 +++++------
drivers/hwtracing/coresight/coresight-priv.h | 1 +
drivers/hwtracing/coresight/coresight.c | 42 +++++++++++++++++++
3 files changed, 55 insertions(+), 12 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
index cdbdb28dc175..8c88bf0a1e5f 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -31,11 +31,14 @@ static DEFINE_PER_CPU(struct coresight_device *, csdev_src);
PMU_FORMAT_ATTR(cycacc, "config:" __stringify(ETM_OPT_CYCACC));
PMU_FORMAT_ATTR(timestamp, "config:" __stringify(ETM_OPT_TS));
PMU_FORMAT_ATTR(retstack, "config:" __stringify(ETM_OPT_RETSTK));
+/* Sink ID - same for all ETMs */
+PMU_FORMAT_ATTR(sinkid, "config2:0-31");
static struct attribute *etm_config_formats_attr[] = {
&format_attr_cycacc.attr,
&format_attr_timestamp.attr,
&format_attr_retstack.attr,
+ &format_attr_sinkid.attr,
NULL,
};
@@ -191,6 +194,7 @@ static void etm_free_aux(void *data)
static void *etm_setup_aux(struct perf_event *event, void **pages,
int nr_pages, bool overwrite)
{
+ u32 id;
int cpu = event->cpu;
cpumask_t *mask;
struct coresight_device *sink;
@@ -201,18 +205,14 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
return NULL;
INIT_WORK(&event_data->work, free_event_data);
- /*
- * In theory nothing prevent tracers in a trace session from being
- * associated with different sinks, nor having a sink per tracer. But
- * until we have HW with this kind of topology we need to assume tracers
- * in a trace session are using the same sink. Therefore go through
- * the coresight bus and pick the first enabled sink.
- *
- * When operated from sysFS users are responsible to enable the sink
- * while from perf, the perf tools will do it based on the choice made
- * on the cmd line. As such the "enable_sink" flag in sysFS is reset.
- */
- sink = coresight_get_enabled_sink(true);
+ /* First get the selected sink from user space. */
+ if (event->attr.config2) {
+ id = (u32)event->attr.config2;
+ sink = coresight_get_sink_by_id(id);
+ } else {
+ sink = coresight_get_enabled_sink(true);
+ }
+
if (!sink || !sink_ops(sink)->alloc_buffer)
goto err;
diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h
index 579f34943bf1..b936c6d7e13f 100644
--- a/drivers/hwtracing/coresight/coresight-priv.h
+++ b/drivers/hwtracing/coresight/coresight-priv.h
@@ -147,6 +147,7 @@ void coresight_disable_path(struct list_head *path);
int coresight_enable_path(struct list_head *path, u32 mode, void *sink_data);
struct coresight_device *coresight_get_sink(struct list_head *path);
struct coresight_device *coresight_get_enabled_sink(bool reset);
+struct coresight_device *coresight_get_sink_by_id(u32 id);
struct list_head *coresight_build_path(struct coresight_device *csdev,
struct coresight_device *sink);
void coresight_release_path(struct list_head *path);
diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
index d7fa90be6f42..29cef898afba 100644
--- a/drivers/hwtracing/coresight/coresight.c
+++ b/drivers/hwtracing/coresight/coresight.c
@@ -11,6 +11,7 @@
#include <linux/err.h>
#include <linux/export.h>
#include <linux/slab.h>
+#include <linux/stringhash.h>
#include <linux/mutex.h>
#include <linux/clk.h>
#include <linux/coresight.h>
@@ -541,6 +542,47 @@ struct coresight_device *coresight_get_enabled_sink(bool deactivate)
return dev ? to_coresight_device(dev) : NULL;
}
+static int coresight_sink_by_id(struct device *dev, void *data)
+{
+ struct coresight_device *csdev = to_coresight_device(dev);
+ unsigned long hash;
+
+ if (csdev->type == CORESIGHT_DEV_TYPE_SINK ||
+ csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) {
+
+ if (!csdev->ea)
+ return 0;
+ /*
+ * See function etm_perf_add_symlink_sink() to know where
+ * this comes from.
+ */
+ hash = (unsigned long)csdev->ea->var;
+
+ if ((u32)hash == *(u32 *)data)
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * coresight_get_sink_by_id - returns the sink that matches the id
+ * @id: Id of the sink to match
+ *
+ * The name of a sink is unique, whether it is found on the AMBA bus or
+ * otherwise. As such the hash of that name can easily be used to identify
+ * a sink.
+ */
+struct coresight_device *coresight_get_sink_by_id(u32 id)
+{
+ struct device *dev = NULL;
+
+ dev = bus_find_device(&coresight_bustype, NULL, &id,
+ coresight_sink_by_id);
+
+ return dev ? to_coresight_device(dev) : NULL;
+}
+
/*
* coresight_grab_device - Power up this device and any of the helper
* devices connected to it for trace operation. Since the helper devices
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 4/6] perf/aux: Make perf_event accessible to setup_aux()
2018-07-03 7:31 ` Hendrik Brueckner
@ 2018-07-03 17:37 ` Mathieu Poirier
0 siblings, 0 replies; 12+ messages in thread
From: Mathieu Poirier @ 2018-07-03 17:37 UTC (permalink / raw)
To: brueckner
Cc: Peter Zijlstra, Arnaldo Carvalho de Melo, Ingo Molnar,
Thomas Gleixner, Alexander Shishkin, schwidefsky, heiko.carstens,
Will Deacon, Mark Rutland, Jiri Olsa, Namhyung Kim,
Adrian Hunter, ast, Greg KH, H. Peter Anvin, linux-s390,
Linux Kernel Mailing List, linux-arm-kernel
On Tue, 3 Jul 2018 at 01:31, Hendrik Brueckner <brueckner@linux.ibm.com> wrote:
>
> On Mon, Jul 02, 2018 at 04:33:28PM -0600, Mathieu Poirier wrote:
> > It can be advantagous to have access to all the information conveyed by
> > a perf_event when setting up the AUX buffer, as it is the case when
> > dealing with PMU specific driver configuration communicated to the kernel
> > using an ioctl() call.
> >
> > As such simply replace the cpu information by the complete perf_event
> > structure and change all affected customers.
> >
> > Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> > ---
> > arch/s390/kernel/perf_cpum_sf.c | 4 ++--
> > arch/x86/events/intel/bts.c | 4 +++-
> > arch/x86/events/intel/pt.c | 5 +++--
> > drivers/hwtracing/coresight/coresight-etm-perf.c | 6 +++---
> > drivers/perf/arm_spe_pmu.c | 6 +++---
> > include/linux/perf_event.h | 2 +-
> > kernel/events/ring_buffer.c | 2 +-
> > 7 files changed, 16 insertions(+), 13 deletions(-)
> >
> > diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c
> > index 0292d68e7dde..e06daaa08894 100644
> > --- a/arch/s390/kernel/perf_cpum_sf.c
> > +++ b/arch/s390/kernel/perf_cpum_sf.c
> > @@ -1601,8 +1601,8 @@ static void aux_buffer_free(void *data)
> > *
> > * Return the private AUX buffer structure if success or NULL if fails.
> > */
> > -static void *aux_buffer_setup(int cpu, void **pages, int nr_pages,
> > - bool snapshot)
> > +static void *aux_buffer_setup(struct perf_event *event, void **pages,
> > + int nr_pages, bool snapshot);
>
> Please remove the trailing semi-colon (;) in the function definition causing
> the kbuild error. Also, it would be great if you also could update the
> function comment and replace the @cpu by the @event.
Had I realised it was just as easy to compile for s390 as it is for
ARM64, I would have done so ahead of time. Well done on that front.
All fixed now.
Thanks,
Mathieu
>
> Many thanks.
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/6] perf/aux: Make perf_event accessible to setup_aux()
2018-07-02 22:33 ` [PATCH 4/6] perf/aux: Make perf_event accessible to setup_aux() Mathieu Poirier
2018-07-03 2:05 ` kbuild test robot
2018-07-03 7:31 ` Hendrik Brueckner
@ 2018-07-03 9:27 ` Alexander Shishkin
2 siblings, 0 replies; 12+ messages in thread
From: Alexander Shishkin @ 2018-07-03 9:27 UTC (permalink / raw)
To: Mathieu Poirier
Cc: peterz, acme, mingo, tglx, alexander.shishkin, schwidefsky,
heiko.carstens, will.deacon, mark.rutland, jolsa, namhyung,
adrian.hunter, ast, gregkh, hpa, linux-s390, linux-kernel,
linux-arm-kernel
On Mon, Jul 02, 2018 at 04:33:28PM -0600, Mathieu Poirier wrote:
> It can be advantagous to have access to all the information conveyed by
> a perf_event when setting up the AUX buffer, as it is the case when
> dealing with PMU specific driver configuration communicated to the kernel
> using an ioctl() call.
>
> As such simply replace the cpu information by the complete perf_event
> structure and change all affected customers.
Ok, but can you provide details about which parts of perf_event you need
and how they are used? Is it the attribute? What's the ioctl command in
question? Also, should we worry that the PMU specific configuration isn't
part of the attribute? Or, if not, why? I think we talked about this
before, but I forgot and this patch needs to explain it anyway.
Thanks!
--
Alex
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/6] perf/aux: Make perf_event accessible to setup_aux()
2018-07-02 22:33 ` [PATCH 4/6] perf/aux: Make perf_event accessible to setup_aux() Mathieu Poirier
2018-07-03 2:05 ` kbuild test robot
@ 2018-07-03 7:31 ` Hendrik Brueckner
2018-07-03 17:37 ` Mathieu Poirier
2018-07-03 9:27 ` Alexander Shishkin
2 siblings, 1 reply; 12+ messages in thread
From: Hendrik Brueckner @ 2018-07-03 7:31 UTC (permalink / raw)
To: Mathieu Poirier
Cc: peterz, acme, mingo, tglx, alexander.shishkin, schwidefsky,
heiko.carstens, will.deacon, mark.rutland, jolsa, namhyung,
adrian.hunter, ast, gregkh, hpa, linux-s390, linux-kernel,
linux-arm-kernel
On Mon, Jul 02, 2018 at 04:33:28PM -0600, Mathieu Poirier wrote:
> It can be advantagous to have access to all the information conveyed by
> a perf_event when setting up the AUX buffer, as it is the case when
> dealing with PMU specific driver configuration communicated to the kernel
> using an ioctl() call.
>
> As such simply replace the cpu information by the complete perf_event
> structure and change all affected customers.
>
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> ---
> arch/s390/kernel/perf_cpum_sf.c | 4 ++--
> arch/x86/events/intel/bts.c | 4 +++-
> arch/x86/events/intel/pt.c | 5 +++--
> drivers/hwtracing/coresight/coresight-etm-perf.c | 6 +++---
> drivers/perf/arm_spe_pmu.c | 6 +++---
> include/linux/perf_event.h | 2 +-
> kernel/events/ring_buffer.c | 2 +-
> 7 files changed, 16 insertions(+), 13 deletions(-)
>
> diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c
> index 0292d68e7dde..e06daaa08894 100644
> --- a/arch/s390/kernel/perf_cpum_sf.c
> +++ b/arch/s390/kernel/perf_cpum_sf.c
> @@ -1601,8 +1601,8 @@ static void aux_buffer_free(void *data)
> *
> * Return the private AUX buffer structure if success or NULL if fails.
> */
> -static void *aux_buffer_setup(int cpu, void **pages, int nr_pages,
> - bool snapshot)
> +static void *aux_buffer_setup(struct perf_event *event, void **pages,
> + int nr_pages, bool snapshot);
Please remove the trailing semi-colon (;) in the function definition causing
the kbuild error. Also, it would be great if you also could update the
function comment and replace the @cpu by the @event.
Many thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/6] perf/aux: Make perf_event accessible to setup_aux()
2018-07-02 22:33 ` [PATCH 4/6] perf/aux: Make perf_event accessible to setup_aux() Mathieu Poirier
@ 2018-07-03 2:05 ` kbuild test robot
2018-07-03 7:31 ` Hendrik Brueckner
2018-07-03 9:27 ` Alexander Shishkin
2 siblings, 0 replies; 12+ messages in thread
From: kbuild test robot @ 2018-07-03 2:05 UTC (permalink / raw)
To: Mathieu Poirier
Cc: kbuild-all, peterz, acme, mingo, tglx, alexander.shishkin,
schwidefsky, heiko.carstens, will.deacon, mark.rutland, jolsa,
namhyung, adrian.hunter, ast, gregkh, hpa, mathieu.poirier,
linux-s390, linux-kernel, linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 9745 bytes --]
Hi Mathieu,
I love your patch! Yet something to improve:
[auto build test ERROR on tip/perf/core]
[also build test ERROR on v4.18-rc3 next-20180702]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Mathieu-Poirier/perf-Add-ioctl-for-PMU-driver-configuration/20180703-064327
config: s390-defconfig (attached as .config)
compiler: s390x-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.2.0 make.cross ARCH=s390
All error/warnings (new ones prefixed by >>):
>> arch/s390/kernel/perf_cpum_sf.c:1606:1: error: expected identifier or '(' before '{' token
{
^
>> arch/s390/kernel/perf_cpum_sf.c:1604:14: warning: 'aux_buffer_setup' used but never defined
static void *aux_buffer_setup(struct perf_event *event, void **pages,
^~~~~~~~~~~~~~~~
vim +1606 arch/s390/kernel/perf_cpum_sf.c
ca5955cd Pu Hou 2016-11-11 1589
ca5955cd Pu Hou 2016-11-11 1590 /*
ca5955cd Pu Hou 2016-11-11 1591 * aux_buffer_setup() - Setup AUX buffer for diagnostic mode sampling
ca5955cd Pu Hou 2016-11-11 1592 * @cpu: On which to allocate, -1 means current
ca5955cd Pu Hou 2016-11-11 1593 * @pages: Array of pointers to buffer pages passed from perf core
ca5955cd Pu Hou 2016-11-11 1594 * @nr_pages: Total pages
ca5955cd Pu Hou 2016-11-11 1595 * @snapshot: Flag for snapshot mode
ca5955cd Pu Hou 2016-11-11 1596 *
ca5955cd Pu Hou 2016-11-11 1597 * This is the callback when setup an event using AUX buffer. Perf tool can
ca5955cd Pu Hou 2016-11-11 1598 * trigger this by an additional mmap() call on the event. Unlike the buffer
ca5955cd Pu Hou 2016-11-11 1599 * for basic samples, AUX buffer belongs to the event. It is scheduled with
ca5955cd Pu Hou 2016-11-11 1600 * the task among online cpus when it is a per-thread event.
ca5955cd Pu Hou 2016-11-11 1601 *
ca5955cd Pu Hou 2016-11-11 1602 * Return the private AUX buffer structure if success or NULL if fails.
ca5955cd Pu Hou 2016-11-11 1603 */
ceb39bf0 Mathieu Poirier 2018-07-02 @1604 static void *aux_buffer_setup(struct perf_event *event, void **pages,
ceb39bf0 Mathieu Poirier 2018-07-02 1605 int nr_pages, bool snapshot);
ca5955cd Pu Hou 2016-11-11 @1606 {
ca5955cd Pu Hou 2016-11-11 1607 struct sf_buffer *sfb;
ca5955cd Pu Hou 2016-11-11 1608 struct aux_buffer *aux;
ca5955cd Pu Hou 2016-11-11 1609 unsigned long *new, *tail;
ca5955cd Pu Hou 2016-11-11 1610 int i, n_sdbt;
ca5955cd Pu Hou 2016-11-11 1611
ca5955cd Pu Hou 2016-11-11 1612 if (!nr_pages || !pages)
ca5955cd Pu Hou 2016-11-11 1613 return NULL;
ca5955cd Pu Hou 2016-11-11 1614
ca5955cd Pu Hou 2016-11-11 1615 if (nr_pages > CPUM_SF_MAX_SDB * CPUM_SF_SDB_DIAG_FACTOR) {
ca5955cd Pu Hou 2016-11-11 1616 pr_err("AUX buffer size (%i pages) is larger than the "
ca5955cd Pu Hou 2016-11-11 1617 "maximum sampling buffer limit\n",
ca5955cd Pu Hou 2016-11-11 1618 nr_pages);
ca5955cd Pu Hou 2016-11-11 1619 return NULL;
ca5955cd Pu Hou 2016-11-11 1620 } else if (nr_pages < CPUM_SF_MIN_SDB * CPUM_SF_SDB_DIAG_FACTOR) {
ca5955cd Pu Hou 2016-11-11 1621 pr_err("AUX buffer size (%i pages) is less than the "
ca5955cd Pu Hou 2016-11-11 1622 "minimum sampling buffer limit\n",
ca5955cd Pu Hou 2016-11-11 1623 nr_pages);
ca5955cd Pu Hou 2016-11-11 1624 return NULL;
ca5955cd Pu Hou 2016-11-11 1625 }
ca5955cd Pu Hou 2016-11-11 1626
ca5955cd Pu Hou 2016-11-11 1627 /* Allocate aux_buffer struct for the event */
ca5955cd Pu Hou 2016-11-11 1628 aux = kmalloc(sizeof(struct aux_buffer), GFP_KERNEL);
ca5955cd Pu Hou 2016-11-11 1629 if (!aux)
ca5955cd Pu Hou 2016-11-11 1630 goto no_aux;
ca5955cd Pu Hou 2016-11-11 1631 sfb = &aux->sfb;
ca5955cd Pu Hou 2016-11-11 1632
ca5955cd Pu Hou 2016-11-11 1633 /* Allocate sdbt_index for fast reference */
ca5955cd Pu Hou 2016-11-11 1634 n_sdbt = (nr_pages + CPUM_SF_SDB_PER_TABLE - 1) / CPUM_SF_SDB_PER_TABLE;
ca5955cd Pu Hou 2016-11-11 1635 aux->sdbt_index = kmalloc_array(n_sdbt, sizeof(void *), GFP_KERNEL);
ca5955cd Pu Hou 2016-11-11 1636 if (!aux->sdbt_index)
ca5955cd Pu Hou 2016-11-11 1637 goto no_sdbt_index;
ca5955cd Pu Hou 2016-11-11 1638
ca5955cd Pu Hou 2016-11-11 1639 /* Allocate sdb_index for fast reference */
ca5955cd Pu Hou 2016-11-11 1640 aux->sdb_index = kmalloc_array(nr_pages, sizeof(void *), GFP_KERNEL);
ca5955cd Pu Hou 2016-11-11 1641 if (!aux->sdb_index)
ca5955cd Pu Hou 2016-11-11 1642 goto no_sdb_index;
ca5955cd Pu Hou 2016-11-11 1643
ca5955cd Pu Hou 2016-11-11 1644 /* Allocate the first SDBT */
ca5955cd Pu Hou 2016-11-11 1645 sfb->num_sdbt = 0;
ca5955cd Pu Hou 2016-11-11 1646 sfb->sdbt = (unsigned long *) get_zeroed_page(GFP_KERNEL);
ca5955cd Pu Hou 2016-11-11 1647 if (!sfb->sdbt)
ca5955cd Pu Hou 2016-11-11 1648 goto no_sdbt;
ca5955cd Pu Hou 2016-11-11 1649 aux->sdbt_index[sfb->num_sdbt++] = (unsigned long)sfb->sdbt;
ca5955cd Pu Hou 2016-11-11 1650 tail = sfb->tail = sfb->sdbt;
ca5955cd Pu Hou 2016-11-11 1651
ca5955cd Pu Hou 2016-11-11 1652 /*
ca5955cd Pu Hou 2016-11-11 1653 * Link the provided pages of AUX buffer to SDBT.
ca5955cd Pu Hou 2016-11-11 1654 * Allocate SDBT if needed.
ca5955cd Pu Hou 2016-11-11 1655 */
ca5955cd Pu Hou 2016-11-11 1656 for (i = 0; i < nr_pages; i++, tail++) {
ca5955cd Pu Hou 2016-11-11 1657 if (require_table_link(tail)) {
ca5955cd Pu Hou 2016-11-11 1658 new = (unsigned long *) get_zeroed_page(GFP_KERNEL);
ca5955cd Pu Hou 2016-11-11 1659 if (!new)
ca5955cd Pu Hou 2016-11-11 1660 goto no_sdbt;
ca5955cd Pu Hou 2016-11-11 1661 aux->sdbt_index[sfb->num_sdbt++] = (unsigned long)new;
ca5955cd Pu Hou 2016-11-11 1662 /* Link current page to tail of chain */
ca5955cd Pu Hou 2016-11-11 1663 *tail = (unsigned long)(void *) new + 1;
ca5955cd Pu Hou 2016-11-11 1664 tail = new;
ca5955cd Pu Hou 2016-11-11 1665 }
ca5955cd Pu Hou 2016-11-11 1666 /* Tail is the entry in a SDBT */
ca5955cd Pu Hou 2016-11-11 1667 *tail = (unsigned long)pages[i];
ca5955cd Pu Hou 2016-11-11 1668 aux->sdb_index[i] = (unsigned long)pages[i];
ca5955cd Pu Hou 2016-11-11 1669 }
ca5955cd Pu Hou 2016-11-11 1670 sfb->num_sdb = nr_pages;
ca5955cd Pu Hou 2016-11-11 1671
ca5955cd Pu Hou 2016-11-11 1672 /* Link the last entry in the SDBT to the first SDBT */
ca5955cd Pu Hou 2016-11-11 1673 *tail = (unsigned long) sfb->sdbt + 1;
ca5955cd Pu Hou 2016-11-11 1674 sfb->tail = tail;
ca5955cd Pu Hou 2016-11-11 1675
ca5955cd Pu Hou 2016-11-11 1676 /*
ca5955cd Pu Hou 2016-11-11 1677 * Initial all SDBs are zeroed. Mark it as empty.
ca5955cd Pu Hou 2016-11-11 1678 * So there is no need to clear the full indicator
ca5955cd Pu Hou 2016-11-11 1679 * when this event is first added.
ca5955cd Pu Hou 2016-11-11 1680 */
ca5955cd Pu Hou 2016-11-11 1681 aux->empty_mark = sfb->num_sdb - 1;
ca5955cd Pu Hou 2016-11-11 1682
ca5955cd Pu Hou 2016-11-11 1683 debug_sprintf_event(sfdbg, 4, "aux_buffer_setup: setup %lu SDBTs"
ca5955cd Pu Hou 2016-11-11 1684 " and %lu SDBs\n",
ca5955cd Pu Hou 2016-11-11 1685 sfb->num_sdbt, sfb->num_sdb);
ca5955cd Pu Hou 2016-11-11 1686
ca5955cd Pu Hou 2016-11-11 1687 return aux;
ca5955cd Pu Hou 2016-11-11 1688
ca5955cd Pu Hou 2016-11-11 1689 no_sdbt:
ca5955cd Pu Hou 2016-11-11 1690 /* SDBs (AUX buffer pages) are freed by caller */
ca5955cd Pu Hou 2016-11-11 1691 for (i = 0; i < sfb->num_sdbt; i++)
ca5955cd Pu Hou 2016-11-11 1692 free_page(aux->sdbt_index[i]);
ca5955cd Pu Hou 2016-11-11 1693 kfree(aux->sdb_index);
ca5955cd Pu Hou 2016-11-11 1694 no_sdb_index:
ca5955cd Pu Hou 2016-11-11 1695 kfree(aux->sdbt_index);
ca5955cd Pu Hou 2016-11-11 1696 no_sdbt_index:
ca5955cd Pu Hou 2016-11-11 1697 kfree(aux);
ca5955cd Pu Hou 2016-11-11 1698 no_aux:
ca5955cd Pu Hou 2016-11-11 1699 return NULL;
ca5955cd Pu Hou 2016-11-11 1700 }
ca5955cd Pu Hou 2016-11-11 1701
:::::: The code at line 1606 was first introduced by commit
:::::: ca5955cdeae744edd3dcc65d677e833fc29658c2 s390/cpumf: introduce AUX buffer for dump diagnostic sample data
:::::: TO: Pu Hou <bjhoupu@linux.vnet.ibm.com>
:::::: CC: Martin Schwidefsky <schwidefsky@de.ibm.com>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 10840 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 4/6] perf/aux: Make perf_event accessible to setup_aux()
2018-07-02 22:33 [PATCH 0/6] perf: Add ioctl for PMU driver configuration Mathieu Poirier
@ 2018-07-02 22:33 ` Mathieu Poirier
2018-07-03 2:05 ` kbuild test robot
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Mathieu Poirier @ 2018-07-02 22:33 UTC (permalink / raw)
To: peterz, acme
Cc: mingo, tglx, alexander.shishkin, schwidefsky, heiko.carstens,
will.deacon, mark.rutland, jolsa, namhyung, adrian.hunter, ast,
gregkh, hpa, mathieu.poirier, linux-s390, linux-kernel,
linux-arm-kernel
It can be advantagous to have access to all the information conveyed by
a perf_event when setting up the AUX buffer, as it is the case when
dealing with PMU specific driver configuration communicated to the kernel
using an ioctl() call.
As such simply replace the cpu information by the complete perf_event
structure and change all affected customers.
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
arch/s390/kernel/perf_cpum_sf.c | 4 ++--
arch/x86/events/intel/bts.c | 4 +++-
arch/x86/events/intel/pt.c | 5 +++--
drivers/hwtracing/coresight/coresight-etm-perf.c | 6 +++---
drivers/perf/arm_spe_pmu.c | 6 +++---
include/linux/perf_event.h | 2 +-
kernel/events/ring_buffer.c | 2 +-
7 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c
index 0292d68e7dde..e06daaa08894 100644
--- a/arch/s390/kernel/perf_cpum_sf.c
+++ b/arch/s390/kernel/perf_cpum_sf.c
@@ -1601,8 +1601,8 @@ static void aux_buffer_free(void *data)
*
* Return the private AUX buffer structure if success or NULL if fails.
*/
-static void *aux_buffer_setup(int cpu, void **pages, int nr_pages,
- bool snapshot)
+static void *aux_buffer_setup(struct perf_event *event, void **pages,
+ int nr_pages, bool snapshot);
{
struct sf_buffer *sfb;
struct aux_buffer *aux;
diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c
index 24ffa1e88cf9..7139f6bf27ad 100644
--- a/arch/x86/events/intel/bts.c
+++ b/arch/x86/events/intel/bts.c
@@ -77,10 +77,12 @@ 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)
{
struct bts_buffer *buf;
struct page *page;
+ int cpu = event->cpu;
int node = (cpu == -1) ? cpu : cpu_to_node(cpu);
unsigned long offset;
size_t size = nr_pages << PAGE_SHIFT;
diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
index 8d016ce5b80d..8f4c98fdd03c 100644
--- a/arch/x86/events/intel/pt.c
+++ b/arch/x86/events/intel/pt.c
@@ -1104,10 +1104,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 677695635211..0f5e03e4df22 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -181,15 +181,15 @@ 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;
+ int cpu = event->cpu;
cpumask_t *mask;
struct coresight_device *sink;
struct etm_event_data *event_data = NULL;
- event_data = alloc_event_data(event_cpu);
+ event_data = alloc_event_data(cpu);
if (!event_data)
return NULL;
INIT_WORK(&event_data->work, free_event_data);
diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c
index 54ec278d2fc4..4dcd7bf14dcc 100644
--- a/drivers/perf/arm_spe_pmu.c
+++ b/drivers/perf/arm_spe_pmu.c
@@ -824,10 +824,10 @@ static void arm_spe_pmu_read(struct perf_event *event)
{
}
-static void *arm_spe_pmu_setup_aux(int cpu, void **pages, int nr_pages,
- bool snapshot)
+static void *arm_spe_pmu_setup_aux(struct perf_event *event, void **pages,
+ int nr_pages, bool snapshot)
{
- int i;
+ int i, cpu = event->cpu;
struct page **pglist;
struct arm_spe_pmu_buf *buf;
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 1fa12887ec02..4d9c8f30ca6c 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -409,7 +409,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 5d3cf407e374..4c96c7575224 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -648,7 +648,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] 12+ messages in thread
end of thread, other threads:[~2019-02-05 23:25 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-05 23:24 [PATCH 0/6] coresight: next v5.0-rc5 Mathieu Poirier
2019-02-05 23:24 ` [PATCH 1/6] coresight: cpu-debug: Support for CA73 CPUs Mathieu Poirier
2019-02-05 23:24 ` [PATCH 2/6] coresight: stm: Remove set but not used variable 'res_size' Mathieu Poirier
2019-02-05 23:24 ` [PATCH 3/6] coresight: Use of_node_name_eq for node name comparisons Mathieu Poirier
2019-02-05 23:24 ` [PATCH 4/6] perf/aux: Make perf_event accessible to setup_aux() Mathieu Poirier
2019-02-05 23:24 ` [PATCH 5/6] coresight: perf: Add "sinks" group to PMU directory Mathieu Poirier
2019-02-05 23:24 ` [PATCH 6/6] coresight: Use event attributes for sink selection Mathieu Poirier
-- strict thread matches above, loose matches on Subject: below --
2018-07-02 22:33 [PATCH 0/6] perf: Add ioctl for PMU driver configuration Mathieu Poirier
2018-07-02 22:33 ` [PATCH 4/6] perf/aux: Make perf_event accessible to setup_aux() Mathieu Poirier
2018-07-03 2:05 ` kbuild test robot
2018-07-03 7:31 ` Hendrik Brueckner
2018-07-03 17:37 ` Mathieu Poirier
2018-07-03 9:27 ` Alexander Shishkin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).