perf: Communicate sink via event::attr:config2
Subsystems (7)
v3 cover perf: Communicate sink via event::attr:config2
This is the third revision of a patchset allowing multiple sources to select the same sink for a session which is a prerequisite for the support of CoreSight CPU-wide trace scenarios.
The sink ID is communicated to the kernel by way of the event's configuration attribute (event::attr:config2). The ID itself is an hash of the sink's name, something that is readily available and unique.
With this set the mechanic to communicate sink selection to the kernel via sysfs is no longer needed and removed.
Applies cleanly and tested on 5.0-rc4.
Thanks,
Mathieu
Changes for V3:
* Rebased to rc4.
* Fixed a perf tools command line problem (reported by Suzuki).
* Enhanced error handling in etm_perf_add_symlink_sink().
* Modified memory allocation to used devm_xyx() API.
* Went from using struct device_attribute to struct dev_ext_attribute.
Changes for V2:
* Addressed memory leak in etm_perf_add_symlink_sink()
* Keep track of device attribute for future removal.
* Added PMU attribure for config2.
* Fixed email address signature.
Mathieu Poirier (7):
perf/aux: Make perf_event accessible to setup_aux()
coresight: perf: Add "sinks" group to PMU directory
coresight: Use event attributes for sink selection
perf pmu: Moving EVENT_SOURCE_DEVICE_PATH to PMU header file perf tools: Use event attributes to send sink information to kernel perf tools: Removing CoreSight set_drv_config() API
perf tools: Remove PMU::set_drv_config API
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-etm-perf.c | 112 +++++++++++++++--- .../hwtracing/coresight/coresight-etm-perf.h | 6 +- drivers/hwtracing/coresight/coresight-priv.h | 1 + drivers/hwtracing/coresight/coresight.c | 60 ++++++++++ drivers/perf/arm_spe_pmu.c | 6 +- include/linux/coresight.h | 7 +- include/linux/perf_event.h | 2 +- kernel/events/ring_buffer.c | 2 +- tools/perf/arch/arm/util/cs-etm.c | 98 +++++++-------- tools/perf/arch/arm/util/cs-etm.h | 3 - tools/perf/arch/arm/util/pmu.c | 2 - tools/perf/builtin-record.c | 10 -- tools/perf/builtin-stat.c | 9 -- tools/perf/builtin-top.c | 13 -- tools/perf/util/Build | 1 - tools/perf/util/drv_configs.c | 78 ------------ tools/perf/util/drv_configs.h | 26 ---- tools/perf/util/pmu.c | 2 - tools/perf/util/pmu.h | 2 +- 22 files changed, 227 insertions(+), 228 deletions(-) delete mode 100644 tools/perf/util/drv_configs.c delete mode 100644 tools/perf/util/drv_configs.h
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 1/7 perf/aux: Make perf_event accessible to setup_aux()
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.
--- 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(-)
arch/s390/kernel/perf_cpum_sf.c +3 -3
@@ -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;
arch/x86/events/intel/bts.c +3 -1
@@ -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 ;
arch/x86/events/intel/pt.c +3 -2
@@ -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 ;
drivers/hwtracing/coresight/coresight-etm-perf.c +3 -3
@@ -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);
drivers/perf/arm_spe_pmu.c +3 -3
@@ -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;
include/linux/perf_event.h +1 -1
@@ -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 */
kernel/events/ring_buffer.c +1 -1
@@ -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;
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
tip-bot for Mathieu Poirier
merge bot[tip:perf/core] perf/aux: Make perf_event accessible to setup_aux()
perf/aux: Make perf_event accessible to setup_aux()
Commit-ID: 840018668ce2d96783356204ff282d6c9b0e5f66 Gitweb: https://git.kernel.org/tip/840018668ce2d96783356204ff282d6c9b0e5f66 Author: Mathieu Poirier <[email protected]> AuthorDate: Thu, 31 Jan 2019 11:47:08 -0700 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 6 Feb 2019 10:00:39 -0300
perf/aux: Make perf_event accessible to setup_aux()
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.
--- 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(-)
arch/s390/kernel/perf_cpum_sf.c +3 -3
@@ -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;
arch/x86/events/intel/bts.c +3 -1
@@ -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 ;
arch/x86/events/intel/pt.c +3 -2
@@ -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 ;
drivers/hwtracing/coresight/coresight-etm-perf.c +3 -3
@@ -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);
drivers/perf/arm_spe_pmu.c +3 -3
@@ -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;
include/linux/perf_event.h +1 -1
@@ -410,7 +410,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 */
kernel/events/ring_buffer.c +1 -1
@@ -657,7 +657,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;
PATCH v3 2/7 coresight: perf: Add "sinks" group to PMU directory
In reply to Mathieu PoirierAdd 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.
--- .../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(-)
drivers/hwtracing/coresight/coresight-etm-perf.c +82 -0
@@ -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;
drivers/hwtracing/coresight/coresight-etm-perf.h +5 -1
@@ -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 ;
drivers/hwtracing/coresight/coresight.c +18 -0
@@ -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);
include/linux/coresight.h +5 -2
@@ -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)
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 2/7] coresight: perf: Add "sinks" group to PMU directory
Quoted 6 lines · Mathieu Poirier
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 <[email protected]>
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
tip-bot for Mathieu Poirier
merge bot[tip:perf/core] coresight: perf: Add "sinks" group to PMU directory
In reply to Mathieu Poiriercoresight: perf: Add "sinks" group to PMU directory
Commit-ID: bb8e370bdc141ddff526e5e5ee74210c91fee0b8 Gitweb: https://git.kernel.org/tip/bb8e370bdc141ddff526e5e5ee74210c91fee0b8 Author: Mathieu Poirier <[email protected]> AuthorDate: Thu, 31 Jan 2019 11:47:09 -0700 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 6 Feb 2019 10:00:39 -0300
coresight: perf: Add "sinks" group to PMU directory
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.
Committer tests:
Test built on a ubuntu 18.04 container with a cross build environment to arm64, the new field is there, need to find a machine with this feature to do further testing in the future.
root@d15263e5734a:/git/perf# grep CORESIGHT /tmp/build/v5.0-rc2+/.config CONFIG_CORESIGHT=y CONFIG_CORESIGHT_LINKS_AND_SINKS=y CONFIG_CORESIGHT_LINK_AND_SINK_TMC=y CONFIG_CORESIGHT_CATU=y CONFIG_CORESIGHT_SINK_TPIU=y CONFIG_CORESIGHT_SINK_ETBV10=y CONFIG_CORESIGHT_SOURCE_ETM4X=y CONFIG_CORESIGHT_DYNAMIC_REPLICATOR=y CONFIG_CORESIGHT_STM=y CONFIG_CORESIGHT_CPU_DEBUG=m root@d15263e5734a:/git/perf# root@d15263e5734a:/git/perf# file /tmp/build/v5.0-rc2+/drivers/hwtracing/coresight/*.o .../coresight/coresight-catu.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-cpu-debug.mod.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-cpu-debug.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-dynamic-replicator.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-etb10.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-etm-perf.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-etm4x-sysfs.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-etm4x.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-funnel.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-replicator.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-stm.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-tmc-etf.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-tmc-etr.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-tmc.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-tpiu.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/of_coresight.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped root@d15263e5734a:/git/perf#
root@d15263e5734a:/git/perf# pahole -C coresight_device /tmp/build/v5.0-rc2+/drivers/hwtracing/coresight/coresight.o
struct coresight_device {
struct coresight_connection * conns; /* 0 8 */
int nr_inport; /* 8 4 */
int nr_outport; /* 12 4 */
enum coresight_dev_type type; /* 16 4 */
union coresight_dev_subtype subtype; /* 20 8 *//* XXX 4 bytes hole, try to pack */
const struct coresight_ops * ops; /* 32 8 */
struct device dev; /* 40 1408 */
/* XXX last struct has 7 bytes of padding */
/* --- cacheline 22 boundary (1408 bytes) was 40 bytes ago --- */
atomic_t * refcnt; /* 1448 8 */
bool orphan; /* 1456 1 */
bool enable; /* 1457 1 */
bool activated; /* 1458 1 */
/* XXX 5 bytes hole, try to pack */
struct dev_ext_attribute * ea; /* 1464 8 */
/* size: 1472, cachelines: 23, members: 12 */ /* sum members: 1463, holes: 2, sum holes: 9 */ /* paddings: 1, sum paddings: 7 */
};
root@d15263e5734a:/git/perf#
--- drivers/hwtracing/coresight/coresight-etm-perf.c | 82 ++++++++++++++++++++++++ drivers/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(-)
drivers/hwtracing/coresight/coresight-etm-perf.c +82 -0
@@ -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;
drivers/hwtracing/coresight/coresight-etm-perf.h +5 -1
@@ -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 ;
drivers/hwtracing/coresight/coresight.c +18 -0
@@ -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);
include/linux/coresight.h +5 -2
@@ -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)
PATCH v3 3/7 coresight: Use event attributes for sink selection
In reply to Mathieu PoirierThis 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.
--- .../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(-)
drivers/hwtracing/coresight/coresight-etm-perf.c +12 -12
@@ -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;
drivers/hwtracing/coresight/coresight-priv.h +1 -0
@@ -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);
drivers/hwtracing/coresight/coresight.c +42 -0
54 lines not on this page · raw message
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 3/7] coresight: Use event attributes for sink selection
Quoted 8 lines · Mathieu Poirier
This patch uses the information conveyed by
perf_event::attr::config2to 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 <[email protected]>---
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
tip-bot for Mathieu Poirier
merge bot[tip:perf/core] coresight: Use event attributes for sink selection
In reply to Mathieu Poiriercoresight: Use event attributes for sink selection
Commit-ID: 2264439258870ed258e190491c54cfb8fc7fa955 Gitweb: https://git.kernel.org/tip/2264439258870ed258e190491c54cfb8fc7fa955 Author: Mathieu Poirier <[email protected]> AuthorDate: Thu, 31 Jan 2019 11:47:10 -0700 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 6 Feb 2019 10:00:39 -0300
coresight: Use event attributes for sink selection
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.
--- drivers/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(-)
drivers/hwtracing/coresight/coresight-etm-perf.c +12 -12
@@ -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;
drivers/hwtracing/coresight/coresight-priv.h +1 -0
@@ -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);
drivers/hwtracing/coresight/coresight.c +42 -0
54 lines not on this page · raw message
PATCH v3 4/7 perf pmu: Moving EVENT_SOURCE_DEVICE_PATH to PMU header file
In reply to Mathieu PoirierMoving definition of EVENT_SOURCE_DEVICE_PATH to pmu.h so that it can be used by other files than pmu.c
--- tools/perf/util/pmu.c | 2 -- tools/perf/util/pmu.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/pmu.c +0 -2
@@ -29,8 +29,6 @@ struct perf_pmu_format {struct list_head list; }; -#define EVENT_SOURCE_DEVICE_PATH "/bus/event_source/devices/" -int perf_pmu_parse (struct list_head *list,char *name);extern FILE *perf_pmu_in;
tools/perf/util/pmu.h +1 -0
@@ -16,6 +16,7 @@ enum { };#define PERF_PMU_FORMAT_BITS 64 +#define EVENT_SOURCE_DEVICE_PATH "/bus/event_source/devices/"struct perf_event_attr ;
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
tip-bot for Mathieu Poirier
merge bot[tip:perf/core] perf pmu: Move EVENT_SOURCE_DEVICE_PATH to PMU header file
perf pmu: Move EVENT_SOURCE_DEVICE_PATH to PMU header file
Commit-ID: ffe8881eb20b0452e47efe151e870b4fae8bd5d2 Gitweb: https://git.kernel.org/tip/ffe8881eb20b0452e47efe151e870b4fae8bd5d2 Author: Mathieu Poirier <[email protected]> AuthorDate: Thu, 31 Jan 2019 11:47:11 -0700 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 6 Feb 2019 10:00:39 -0300
perf pmu: Move EVENT_SOURCE_DEVICE_PATH to PMU header file
Move definition of EVENT_SOURCE_DEVICE_PATH to pmu.h so that it can be used by other files than pmu.c
--- tools/perf/util/pmu.c | 2 -- tools/perf/util/pmu.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/pmu.c +0 -2
@@ -29,8 +29,6 @@ struct perf_pmu_format {struct list_head list; }; -#define EVENT_SOURCE_DEVICE_PATH "/bus/event_source/devices/" -int perf_pmu_parse (struct list_head *list,char *name);extern FILE *perf_pmu_in;
tools/perf/util/pmu.h +1 -0
@@ -17,6 +17,7 @@ enum { };#define PERF_PMU_FORMAT_BITS 64 +#define EVENT_SOURCE_DEVICE_PATH "/bus/event_source/devices/"struct perf_event_attr ;
PATCH v3 5/7 perf tools: Use event attributes to send sink information to kernel
In reply to Mathieu PoirierThe communication of sink information for a trace session doesn't work when more than on CPU is involved in the scenario due to the static nature of sysfs. As such communicate the sink information to each event by using the perf_event::attr:config2 attribute. The information sent to the kernel is an hash of the sink's name, which is unique in a system.
--- tools/perf/arch/arm/util/cs-etm.c | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
tools/perf/arch/arm/util/cs-etm.c +44 -0
@@ -5,6 +5,7 @@*/ #include <api/fs/fs.h> +#include <linux/bits.h> #include <linux/bitops.h> #include <linux/compiler.h> #include <linux/coresight-pmu.h>
@@ -22,6 +23,7 @@#include "../../util/thread_map.h" #include "../../util/cs-etm.h" +#include <errno.h> #include <stdlib.h> #include <sys/stat.h>
@@ -60,10 +62,48 @@ static int cs_etm_parse_snapshot_options(struct auxtrace_record *itr,return 0 ; } +static int cs_etm_set_sink_attr (struct perf_pmu *pmu, +struct perf_evsel *evsel) +{ +char msg[BUFSIZ ], path[PATH_MAX ], *sink; +struct perf_evsel_config_term *term; +int ret = -EINVAL ; +u32 hash; + +if (evsel->attr.config2 &GENMASK (31 ,0 )) +return 0 ; + +list_for_each_entry (term, &evsel->config_terms, list) { +if (term->type !=PERF_EVSEL__CONFIG_TERM_DRV_CFG ) +continue ; + + sink = term->val.drv_cfg; +snprintf (path,PATH_MAX ,"sinks/%s" , sink); + + ret =perf_pmu__scan_file (pmu, path,"%x" , &hash); +if (ret !=1 ) { +pr_err ("failed to set sink \"%s\" on event %s with %d (%s)\n" , + sink,perf_evsel__name (evsel), errno, +str_error_r (errno, msg,sizeof (msg))); +return ret; + } + + evsel->attr.config2 |= hash; +return 0 ; + } + +/* +* No sink was provided on the command line - for _now_ treat +* this as an error. +*/ +return ret; +} +static int cs_etm_recording_options (struct auxtrace_record *itr,struct perf_evlist *evlist,struct record_opts *opts) { +int ret;struct cs_etm_recording *ptr = container_of(itr, struct cs_etm_recording, itr);struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu;
@@ -92,6 +132,10 @@ static int cs_etm_recording_options(struct auxtrace_record *itr,if (!cs_etm_evsel)return 0 ; + ret =cs_etm_set_sink_attr (cs_etm_pmu, cs_etm_evsel); +if (ret) +return ret; +if (opts->use_clockid) {pr_err ("Cannot use clockid (-k option) with %s\n" ,CORESIGHT_ETM_PMU_NAME );
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
tip-bot for Mathieu Poirier
merge bot[tip:perf/core] perf arm cs-etm: Use event attributes to send sink information to kernel
perf arm cs-etm: Use event attributes to send sink information to kernel
Commit-ID: fa4e819bbca9939c54e87ba994a6a9bffd0247df Gitweb: https://git.kernel.org/tip/fa4e819bbca9939c54e87ba994a6a9bffd0247df Author: Mathieu Poirier <[email protected]> AuthorDate: Thu, 31 Jan 2019 11:47:12 -0700 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 6 Feb 2019 10:00:39 -0300
perf arm cs-etm: Use event attributes to send sink information to kernel
The communication of sink information for a trace session doesn't work when more than on CPU is involved in the scenario due to the static nature of sysfs. As such communicate the sink information to each event by using the perf_event::attr:config2 attribute. The information sent to the kernel is an hash of the sink's name, which is unique in a system.
--- tools/perf/arch/arm/util/cs-etm.c | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
tools/perf/arch/arm/util/cs-etm.c +44 -0
@@ -5,6 +5,7 @@*/ #include <api/fs/fs.h> +#include <linux/bits.h> #include <linux/bitops.h> #include <linux/compiler.h> #include <linux/coresight-pmu.h>
@@ -22,6 +23,7 @@#include "../../util/thread_map.h" #include "../../util/cs-etm.h" +#include <errno.h> #include <stdlib.h> #include <sys/stat.h>
@@ -60,10 +62,48 @@ static int cs_etm_parse_snapshot_options(struct auxtrace_record *itr,return 0 ; } +static int cs_etm_set_sink_attr (struct perf_pmu *pmu, +struct perf_evsel *evsel) +{ +char msg[BUFSIZ ], path[PATH_MAX ], *sink; +struct perf_evsel_config_term *term; +int ret = -EINVAL ; +u32 hash; + +if (evsel->attr.config2 &GENMASK (31 ,0 )) +return 0 ; + +list_for_each_entry (term, &evsel->config_terms, list) { +if (term->type !=PERF_EVSEL__CONFIG_TERM_DRV_CFG ) +continue ; + + sink = term->val.drv_cfg; +snprintf (path,PATH_MAX ,"sinks/%s" , sink); + + ret =perf_pmu__scan_file (pmu, path,"%x" , &hash); +if (ret !=1 ) { +pr_err ("failed to set sink \"%s\" on event %s with %d (%s)\n" , + sink,perf_evsel__name (evsel), errno, +str_error_r (errno, msg,sizeof (msg))); +return ret; + } + + evsel->attr.config2 |= hash; +return 0 ; + } + +/* +* No sink was provided on the command line - for _now_ treat +* this as an error. +*/ +return ret; +} +static int cs_etm_recording_options (struct auxtrace_record *itr,struct perf_evlist *evlist,struct record_opts *opts) { +int ret;struct cs_etm_recording *ptr = container_of(itr, struct cs_etm_recording, itr);struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu;
@@ -92,6 +132,10 @@ static int cs_etm_recording_options(struct auxtrace_record *itr,if (!cs_etm_evsel)return 0 ; + ret =cs_etm_set_sink_attr (cs_etm_pmu, cs_etm_evsel); +if (ret) +return ret; +if (opts->use_clockid) {pr_err ("Cannot use clockid (-k option) with %s\n" ,CORESIGHT_ETM_PMU_NAME );
PATCH v3 6/7 perf tools: Removing CoreSight set_drv_config() API
In reply to Mathieu PoirierNow that event's config2 attribute is used to communicate sink selection to the kernel, remove the old set_drv_config() implementation since it is no longer needed.
--- tools/perf/arch/arm/util/cs-etm.c | 54 ------------------------------- tools/perf/arch/arm/util/cs-etm.h | 3 -- tools/perf/arch/arm/util/pmu.c | 2 -- 3 files changed, 59 deletions(-)
tools/perf/arch/arm/util/cs-etm.c +0 -54
@@ -27,9 +27,6 @@#include <stdlib.h> #include <sys/stat.h> -#define ENABLE_SINK_MAX 128 -#define CS_BUS_DEVICE_PATH "/bus/coresight/devices/" -struct cs_etm_recording {struct auxtrace_record itr;struct perf_pmu *cs_etm_pmu;
@@ -642,54 +639,3 @@ struct auxtrace_record *cs_etm_record_init(int *err) out:return NULL ; } - -static FILE *cs_device__open_file (const char *name) -{ -struct stat st; -char path[PATH_MAX ]; -const char *sysfs; - - sysfs =sysfs__mountpoint (); -if (!sysfs) -return NULL ; - -snprintf (path,PATH_MAX , -"%s" CS_BUS_DEVICE_PATH "%s" , sysfs, name); - -if (stat (path, &st) <0 ) -return NULL ; - -return fopen (path,"w" ); - -} - -static int __printf(2, 3) cs_device__print_file(const char *name, const char *fmt, ...) -{ - va_list args; -FILE *file; -int ret = -EINVAL ; - - va_start(args, fmt); - file =cs_device__open_file (name); - if (file) { - ret =vfprintf (file, fmt, args); -fclose (file); - } -va_end (args); -return ret; -} - -int cs_etm_set_drv_config (struct perf_evsel_config_term *term) -{ -int ret; -char enable_sink[ENABLE_SINK_MAX ]; - -snprintf (enable_sink,ENABLE_SINK_MAX ,"%s/%s" , - term->val.drv_cfg,"enable_sink" ); - - ret =cs_device__print_file (enable_sink,"%d" ,1 ); -if (ret <0 ) -return ret; - -return 0 ; -}
tools/perf/arch/arm/util/cs-etm.h +0 -3
@@ -7,9 +7,6 @@#ifndef INCLUDE__PERF_CS_ETM_H__ #define INCLUDE__PERF_CS_ETM_H__ -#include "../../util/evsel.h" -struct auxtrace_record *cs_etm_record_init (int *err); -int cs_etm_set_drv_config (struct perf_evsel_config_term *term);#endif
tools/perf/arch/arm/util/pmu.c +0 -2
@@ -8,7 +8,6 @@#include <linux/coresight-pmu.h> #include <linux/perf_event.h> -#include "cs-etm.h" #include "arm-spe.h" #include "../../util/pmu.h"
@@ -19,7 +18,6 @@ struct perf_event_attrif (!strcmp (pmu->name,CORESIGHT_ETM_PMU_NAME )) {/* add ETM default config here */ pmu->selectable = true; - pmu->set_drv_config = cs_etm_set_drv_config;#if defined(__aarch64__) } else if (strstarts(pmu->name, ARM_SPE_PMU_NAME)) {return arm_spe_pmu_default_config (pmu);
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
tip-bot for Mathieu Poirier
merge bot[tip:perf/core] perf coresight: Remove set_drv_config() API
perf coresight: Remove set_drv_config() API
Commit-ID: 1a89f1e2bec2e6537483b4d22cad62e1d8433686 Gitweb: https://git.kernel.org/tip/1a89f1e2bec2e6537483b4d22cad62e1d8433686 Author: Mathieu Poirier <[email protected]> AuthorDate: Thu, 31 Jan 2019 11:47:13 -0700 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 6 Feb 2019 10:00:39 -0300
perf coresight: Remove set_drv_config() API
Now that the event's config2 attribute is used to communicate sink selection to the kernel, remove the old set_drv_config() implementation since it is no longer needed.
--- tools/perf/arch/arm/util/cs-etm.c | 54 --------------------------------------- tools/perf/arch/arm/util/cs-etm.h | 3 --- tools/perf/arch/arm/util/pmu.c | 2 -- 3 files changed, 59 deletions(-)
tools/perf/arch/arm/util/cs-etm.c +0 -54
@@ -27,9 +27,6 @@#include <stdlib.h> #include <sys/stat.h> -#define ENABLE_SINK_MAX 128 -#define CS_BUS_DEVICE_PATH "/bus/coresight/devices/" -struct cs_etm_recording {struct auxtrace_record itr;struct perf_pmu *cs_etm_pmu;
@@ -642,54 +639,3 @@ struct auxtrace_record *cs_etm_record_init(int *err) out:return NULL ; } - -static FILE *cs_device__open_file (const char *name) -{ -struct stat st; -char path[PATH_MAX ]; -const char *sysfs; - - sysfs =sysfs__mountpoint (); -if (!sysfs) -return NULL ; - -snprintf (path,PATH_MAX , -"%s" CS_BUS_DEVICE_PATH "%s" , sysfs, name); - -if (stat (path, &st) <0 ) -return NULL ; - -return fopen (path,"w" ); - -} - -static int __printf(2, 3) cs_device__print_file(const char *name, const char *fmt, ...) -{ - va_list args; -FILE *file; -int ret = -EINVAL ; - - va_start(args, fmt); - file =cs_device__open_file (name); - if (file) { - ret =vfprintf (file, fmt, args); -fclose (file); - } -va_end (args); -return ret; -} - -int cs_etm_set_drv_config (struct perf_evsel_config_term *term) -{ -int ret; -char enable_sink[ENABLE_SINK_MAX ]; - -snprintf (enable_sink,ENABLE_SINK_MAX ,"%s/%s" , - term->val.drv_cfg,"enable_sink" ); - - ret =cs_device__print_file (enable_sink,"%d" ,1 ); -if (ret <0 ) -return ret; - -return 0 ; -}
tools/perf/arch/arm/util/cs-etm.h +0 -3
@@ -7,9 +7,6 @@#ifndef INCLUDE__PERF_CS_ETM_H__ #define INCLUDE__PERF_CS_ETM_H__ -#include "../../util/evsel.h" -struct auxtrace_record *cs_etm_record_init (int *err); -int cs_etm_set_drv_config (struct perf_evsel_config_term *term);#endif
tools/perf/arch/arm/util/pmu.c +0 -2
@@ -9,7 +9,6 @@#include <linux/perf_event.h> #include <linux/string.h> -#include "cs-etm.h" #include "arm-spe.h" #include "../../util/pmu.h"
@@ -20,7 +19,6 @@ struct perf_event_attrif (!strcmp (pmu->name,CORESIGHT_ETM_PMU_NAME )) {/* add ETM default config here */ pmu->selectable = true; - pmu->set_drv_config = cs_etm_set_drv_config;#if defined(__aarch64__) } else if (strstarts(pmu->name, ARM_SPE_PMU_NAME)) {return arm_spe_pmu_default_config (pmu);
PATCH v3 7/7 perf tools: Remove PMU::set_drv_config API
In reply to Mathieu PoirierCoreSight was the only client of the PMU's set_drv_config() API. Now that it is no longer needed by CoreSight remove it from the code base.
--- tools/perf/builtin-record.c | 10 ----- tools/perf/builtin-stat.c | 9 ---- tools/perf/builtin-top.c | 13 ------ tools/perf/util/Build | 1 - tools/perf/util/drv_configs.c | 78 ----------------------------------- tools/perf/util/drv_configs.h | 26 ------------ tools/perf/util/pmu.h | 1 - 7 files changed, 138 deletions(-) delete mode 100644 tools/perf/util/drv_configs.c delete mode 100644 tools/perf/util/drv_configs.h
tools/perf/builtin-record.c +0 -10
@@ -23,7 +23,6 @@#include "util/evlist.h" #include "util/evsel.h" #include "util/debug.h" -#include "util/drv_configs.h" #include "util/session.h" #include "util/tool.h" #include "util/symbol.h"
@@ -566,7 +565,6 @@ 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 ;/*
@@ -619,14 +617,6 @@ static int record__open(struct record *rec) goto out; } -if (perf_evlist__apply_drv_configs (evlist, &pos, &err_term)) { -pr_err ("failed to set config \"%s\" on event %s with %d (%s)\n" , - err_term->val.drv_cfg,perf_evsel__name (pos), errno, -str_error_r (errno, msg,sizeof (msg))); - rc =-1 ; - goto out; - } - rc =record__mmap (rec);if (rc) goto out;
tools/perf/builtin-stat.c +0 -9
@@ -52,7 +52,6 @@#include "util/evlist.h" #include "util/evsel.h" #include "util/debug.h" -#include "util/drv_configs.h" #include "util/color.h" #include "util/stat.h" #include "util/header.h"
@@ -418,7 +417,6 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)int status =0 ;const bool forks = (argc >0 );bool is_pipe =STAT_RECORD ? perf_stat.data.is_pipe : false; -struct perf_evsel_config_term *err_term;if (interval) { ts.tv_sec = interval /USEC_PER_MSEC ;
@@ -515,13 +513,6 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)return -1 ; } -if (perf_evlist__apply_drv_configs (evsel_list, &counter, &err_term)) { -pr_err ("failed to set config \"%s\" on event %s with %d (%s)\n" , - err_term->val.drv_cfg,perf_evsel__name (counter), errno, -str_error_r (errno, msg,sizeof (msg))); -return -1 ; - } -if (STAT_RECORD ) {int err, fd =perf_data__fd (&perf_stat.data);
tools/perf/builtin-top.c +0 -13
@@ -24,7 +24,6 @@#include "util/annotate.h" #include "util/config.h" #include "util/color.h" -#include "util/drv_configs.h" #include "util/evlist.h" #include "util/evsel.h" #include "util/event.h"
@@ -1184,10 +1183,6 @@ static void init_process_thread(struct perf_top *top)static int __cmd_top (struct perf_top *top) { -char msg[512 ]; -struct perf_evsel *pos; -struct perf_evsel_config_term *err_term; -struct perf_evlist *evlist = top->evlist;struct record_opts *opts = &top->record_opts;pthread_t thread, thread_process;int ret;
@@ -1232,14 +1227,6 @@ static int __cmd_top(struct perf_top *top)if (ret) goto out_delete; - ret =perf_evlist__apply_drv_configs (evlist, &pos, &err_term); -if (ret) { -pr_err ("failed to set config \"%s\" on event %s with %d (%s)\n" , - err_term->val.drv_cfg,perf_evsel__name (pos), errno, -str_error_r (errno, msg,sizeof (msg))); - goto out_delete; - } - top->session->evlist = top->evlist;perf_session__set_id_hdr_size (top->session);
tools/perf/util/Build +0 -1
@@ -104,7 +104,6 @@ libperf-y += term.o libperf-y += help-unknown-cmd.o libperf-y += mem-events.o libperf-y += vsprintf.o -libperf-y += drv_configs.o libperf-y += units.o libperf-y += time-utils.o libperf-y += expr-bison.o
tools/perf/util/drv_configs.c deleted +0 -78
78 lines not on this page · raw message
tools/perf/util/drv_configs.h deleted +0 -26
@@ -1,26 +0,0 @@ -/* -* drv_configs.h: Interface to apply PMU specific configuration -* Copyright (c) 2016-2018, Linaro Ltd. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, -* version 2, as published by the Free Software Foundation. -* -* This program is distributed in the hope it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -*/ - -#ifndef __PERF_DRV_CONFIGS_H -#define __PERF_DRV_CONFIGS_H - -#include "drv_configs.h" -#include "evlist.h" -#include "evsel.h" - -int perf_evlist__apply_drv_configs (struct perf_evlist *evlist, -struct perf_evsel **err_evsel, -struct perf_evsel_config_term **term); -#endif
tools/perf/util/pmu.h +0 -1
@@ -30,7 +30,6 @@ struct perf_pmu {struct list_head format;/* HEAD struct perf_pmu_format -> list */ struct list_head aliases;/* HEAD struct perf_pmu_alias -> list */ struct list_head list;/* ELEM */ -int (*set_drv_config) (struct perf_evsel_config_term *term); };struct perf_pmu_info {
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 7/7] perf tools: Remove PMU::set_drv_config API
Quoted 13 lines · Mathieu Poirier
CoreSight was the only client of the PMU's
set_drv_config()API. Now that it is no longer needed by CoreSight remove it from the code base.Signed-off-by Mathieu Poirier <[email protected]>--- tools/perf/builtin-record.c | 10 ----- tools/perf/builtin-stat.c | 9 ---- tools/perf/builtin-top.c | 13 ------ tools/perf/util/Build | 1 - tools/perf/util/drv_configs.c | 78 ----------------------------------- tools/perf/util/drv_configs.h | 26 ------------ tools/perf/util/pmu.h | 1 - 7 files changed, 138 deletions(-)
Quoted 2 lines
delete mode 100644
tools/perf/util/drv_configs.cdelete mode 100644tools/perf/util/drv_configs.h
Nice !
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Arnaldo Carvalho de Melo
maintainerRe: [PATCH v3 7/7] perf tools: Remove PMU::set_drv_config API
Em Thu, Jan 31, 2019 at 07:03:48PM +0000, Suzuki K Poulose escreveu:
Quoted 5 lines · Mathieu Poirier
Quoted 4 lines
CoreSight was the only client of the PMU's
set_drv_config()API. Now that it is no longer needed by CoreSight remove it from the code base.Signed-off-by Mathieu Poirier <[email protected]>
I'm processing the patchkit, test building it on a cross arch64 build.
- Arnaldo
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
tip-bot for Mathieu Poirier
merge bot[tip:perf/core] perf pmu: Remove set_drv_config API
In reply to Mathieu Poirierperf pmu: Remove set_drv_config API
Commit-ID: 159b0da50adb021fe452d849fb73b408f21de3f8 Gitweb: https://git.kernel.org/tip/159b0da50adb021fe452d849fb73b408f21de3f8 Author: Mathieu Poirier <[email protected]> AuthorDate: Thu, 31 Jan 2019 11:47:14 -0700 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 6 Feb 2019 10:00:39 -0300
perf pmu: Remove set_drv_config API
CoreSight was the only client of the PMU's set_drv_config() API. Now that it is no longer needed by CoreSight remove it from the code base.
--- tools/perf/builtin-record.c | 10 ------ tools/perf/builtin-stat.c | 9 ----- tools/perf/builtin-top.c | 13 -------- tools/perf/util/Build | 1 - tools/perf/util/drv_configs.c | 78 ------------------------------------------- tools/perf/util/drv_configs.h | 26 --------------- tools/perf/util/pmu.h | 1 - 7 files changed, 138 deletions(-)
tools/perf/builtin-record.c +0 -10
@@ -23,7 +23,6 @@#include "util/evlist.h" #include "util/evsel.h" #include "util/debug.h" -#include "util/drv_configs.h" #include "util/session.h" #include "util/tool.h" #include "util/symbol.h"
@@ -567,7 +566,6 @@ 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 ;/*
@@ -620,14 +618,6 @@ try_again: goto out; } -if (perf_evlist__apply_drv_configs (evlist, &pos, &err_term)) { -pr_err ("failed to set config \"%s\" on event %s with %d (%s)\n" , - err_term->val.drv_cfg,perf_evsel__name (pos), errno, -str_error_r (errno, msg,sizeof (msg))); - rc =-1 ; - goto out; - } - rc =record__mmap (rec);if (rc) goto out;
tools/perf/builtin-stat.c +0 -9
@@ -52,7 +52,6 @@#include "util/evlist.h" #include "util/evsel.h" #include "util/debug.h" -#include "util/drv_configs.h" #include "util/color.h" #include "util/stat.h" #include "util/header.h"
@@ -417,7 +416,6 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)int status =0 ;const bool forks = (argc >0 );bool is_pipe =STAT_RECORD ? perf_stat.data.is_pipe : false; -struct perf_evsel_config_term *err_term;if (interval) { ts.tv_sec = interval /USEC_PER_MSEC ;
@@ -514,13 +512,6 @@ try_again:return -1 ; } -if (perf_evlist__apply_drv_configs (evsel_list, &counter, &err_term)) { -pr_err ("failed to set config \"%s\" on event %s with %d (%s)\n" , - err_term->val.drv_cfg,perf_evsel__name (counter), errno, -str_error_r (errno, msg,sizeof (msg))); -return -1 ; - } -if (STAT_RECORD ) {int err, fd =perf_data__fd (&perf_stat.data);
tools/perf/builtin-top.c +0 -13
@@ -25,7 +25,6 @@#include "util/bpf-event.h" #include "util/config.h" #include "util/color.h" -#include "util/drv_configs.h" #include "util/evlist.h" #include "util/evsel.h" #include "util/event.h"
@@ -1186,10 +1185,6 @@ static void init_process_thread(struct perf_top *top)static int __cmd_top (struct perf_top *top) { -char msg[512 ]; -struct perf_evsel *pos; -struct perf_evsel_config_term *err_term; -struct perf_evlist *evlist = top->evlist;struct record_opts *opts = &top->record_opts;pthread_t thread, thread_process;int ret;
@@ -1240,14 +1235,6 @@ static int __cmd_top(struct perf_top *top)if (ret) goto out_delete; - ret =perf_evlist__apply_drv_configs (evlist, &pos, &err_term); -if (ret) { -pr_err ("failed to set config \"%s\" on event %s with %d (%s)\n" , - err_term->val.drv_cfg,perf_evsel__name (pos), errno, -str_error_r (errno, msg,sizeof (msg))); - goto out_delete; - } - top->session->evlist = top->evlist;perf_session__set_id_hdr_size (top->session);
tools/perf/util/Build +0 -1
@@ -107,7 +107,6 @@ libperf-y += term.o libperf-y += help-unknown-cmd.o libperf-y += mem-events.o libperf-y += vsprintf.o -libperf-y += drv_configs.o libperf-y += units.o libperf-y += time-utils.o libperf-y += expr-bison.o
tools/perf/util/drv_configs.c deleted +0 -78
78 lines not on this page · raw message
tools/perf/util/drv_configs.h deleted +0 -26
@@ -1,26 +0,0 @@ -/* -* drv_configs.h: Interface to apply PMU specific configuration -* Copyright (c) 2016-2018, Linaro Ltd. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, -* version 2, as published by the Free Software Foundation. -* -* This program is distributed in the hope it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -*/ - -#ifndef __PERF_DRV_CONFIGS_H -#define __PERF_DRV_CONFIGS_H - -#include "drv_configs.h" -#include "evlist.h" -#include "evsel.h" - -int perf_evlist__apply_drv_configs (struct perf_evlist *evlist, -struct perf_evsel **err_evsel, -struct perf_evsel_config_term **term); -#endif
tools/perf/util/pmu.h +0 -1
@@ -31,7 +31,6 @@ struct perf_pmu {struct list_head format;/* HEAD struct perf_pmu_format -> list */ struct list_head aliases;/* HEAD struct perf_pmu_alias -> list */ struct list_head list;/* ELEM */ -int (*set_drv_config) (struct perf_evsel_config_term *term); };struct perf_pmu_info {