For CPU-wide scenarios trace generated by multiple CPUs can be aggregated by a single sink. This patch paves the way to uses the pid of the process being monitored to allocate and free sink buffer memory along with regimenting access to what source a sink can collect data for.
Signed-off-by: Mathieu Poirier mathieu.poirier@linaro.org --- drivers/hwtracing/coresight/coresight-etb10.c | 3 ++- drivers/hwtracing/coresight/coresight-etm-perf.c | 4 +++- drivers/hwtracing/coresight/coresight-tmc-etf.c | 6 ++++-- drivers/hwtracing/coresight/coresight-tmc-etr.c | 5 +++-- include/linux/coresight.h | 4 +++- 5 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index d3dce9399349..493d4f4143a1 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -355,7 +355,8 @@ static int etb_disable(struct coresight_device *csdev) }
static void *etb_alloc_buffer(struct coresight_device *csdev, int cpu, - void **pages, int nr_pages, bool overwrite) + pid_t pid, void **pages, int nr_pages, + bool overwrite) { int node; struct cs_buffers *buf; diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index 806b3dd5872d..76d3e8f1041c 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -13,6 +13,7 @@ #include <linux/init.h> #include <linux/perf_event.h> #include <linux/percpu-defs.h> +#include <linux/sched.h> /* for task_pid_nr() */ #include <linux/slab.h> #include <linux/stringhash.h> #include <linux/types.h> @@ -210,6 +211,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, u32 id; int cpu = event->cpu; cpumask_t *mask; + pid_t pid = task_pid_nr(event->owner); struct coresight_device *sink; struct etm_event_data *event_data = NULL;
@@ -277,7 +279,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
/* Allocate the sink buffer for this session */ event_data->snk_config = - sink_ops(sink)->alloc_buffer(sink, cpu, pages, + sink_ops(sink)->alloc_buffer(sink, cpu, pid, pages, nr_pages, overwrite); if (!event_data->snk_config) goto err; diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index 9e449ef84883..3bb407132a1a 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -9,6 +9,7 @@ #include <linux/coresight.h> #include <linux/perf_event.h> #include <linux/slab.h> +#include <linux/types.h> #include "coresight-priv.h" #include "coresight-tmc.h" #include "coresight-etm-perf.h" @@ -350,8 +351,9 @@ static void tmc_disable_etf_link(struct coresight_device *csdev, dev_dbg(drvdata->dev, "TMC-ETF disabled\n"); }
-static void *tmc_alloc_etf_buffer(struct coresight_device *csdev, int cpu, - void **pages, int nr_pages, bool overwrite) +static void *tmc_alloc_etf_buffer(struct coresight_device *csdev, + int cpu, pid_t pid, void **pages, + int nr_pages, bool overwrite) { int node; struct cs_buffers *buf; diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index 8d71ea110ff3..be50591e2dcc 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -9,6 +9,7 @@ #include <linux/dma-mapping.h> #include <linux/iommu.h> #include <linux/slab.h> +#include <linux/types.h> #include <linux/vmalloc.h> #include "coresight-catu.h" #include "coresight-etm-perf.h" @@ -1209,8 +1210,8 @@ tmc_etr_setup_perf_buf(struct tmc_drvdata *drvdata, int node, int nr_pages, }
-static void *tmc_alloc_etr_buffer(struct coresight_device *csdev, - int cpu, void **pages, int nr_pages, +static void *tmc_alloc_etr_buffer(struct coresight_device *csdev, int cpu, + pid_t pid, void **pages, int nr_pages, bool snapshot) { struct etr_perf_buffer *etr_perf; diff --git a/include/linux/coresight.h b/include/linux/coresight.h index 189cc6ddc92b..21c53cc21f4b 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -9,6 +9,7 @@ #include <linux/device.h> #include <linux/perf_event.h> #include <linux/sched.h> +#include <linux/types.h>
/* Peripheral id registers (0xFD0-0xFEC) */ #define CORESIGHT_PERIPHIDR4 0xfd0 @@ -194,7 +195,8 @@ struct coresight_ops_sink { int (*enable)(struct coresight_device *csdev, u32 mode, void *data); int (*disable)(struct coresight_device *csdev); void *(*alloc_buffer)(struct coresight_device *csdev, int cpu, - void **pages, int nr_pages, bool overwrite); + pid_t pid, void **pages, int nr_pages, + bool overwrite); void (*free_buffer)(void *config); unsigned long (*update_buffer)(struct coresight_device *csdev, struct perf_output_handle *handle,