perf tool: parser generator for events parsing
Subsystems (2)
v5 cover perf tool: parser generator for events parsing
hi,
here's new version of event parsing patchset.
I saw Arnaldo already sent patches 1-3 to Ingo, but they did not make it to the tree yet, so I'm still attaching them here.
v5 changes:
4/8 - patch updated by Peter with actual format definitions
for x86 processors
6/8 - added hardcoded terms for config[12] and sample_period
the code is ready to include branch_sample_type once this field is available in perf_event_attr, just uncommenting one line.. ;)
- allow config option to be used without value in which case 1 is assigned as value
Overall summarize:
- adding event parser bison/flex generator
- the event syntax stays as it was
- adding event format sysfs group attribute
for pmu device
- adding new syntax to specify raw events based
on the sysfs pmu's format attribute
eg. "cpu/config=1,config1=2,config2=3/u"
Attached patches:
1/8 perf, tool: Remove unused functions from debugfs object 2/8 perf, tool: Add sysfs mountpoint interface
3/8 perf, tool: Add bitmap_or function into bitmap object 4/8 perf: Adding sysfs group format attribute for pmu device 5/8 perf, tool: Add parser generator for events parsing 6/8 perf, tool: Add config options support for event parsing 7/8 perf, tool: Add perf pmu object to access pmu format definition 8/8 perf, tool: Add support to specify pmu style event
thanks,
jirka
--- .../testing/sysfs-bus-event_source-devices-format | 14 + arch/x86/kernel/cpu/perf_event.c | 7 + arch/x86/kernel/cpu/perf_event.h | 1 + arch/x86/kernel/cpu/perf_event_amd.c | 19 + arch/x86/kernel/cpu/perf_event_intel.c | 36 + arch/x86/kernel/cpu/perf_event_p6.c | 19 + include/linux/perf_event.h | 14 + tools/perf/Makefile | 31 + tools/perf/builtin-test.c | 58 +- tools/perf/util/bitmap.c | 10 + tools/perf/util/debugfs.c | 141 -- tools/perf/util/debugfs.h | 6 - tools/perf/util/include/linux/bitmap.h | 11 + tools/perf/util/parse-events-bison.c | 1852 ++++++++++++++++ tools/perf/util/parse-events-bison.h | 82 + tools/perf/util/parse-events-flex.c | 2272 ++++++++++++++++++++ tools/perf/util/parse-events-flex.h | 316 +++ tools/perf/util/parse-events.c | 590 +++--- tools/perf/util/parse-events.h | 46 + tools/perf/util/parse-events.l | 126 ++ tools/perf/util/parse-events.y | 217 ++ tools/perf/util/pmu-bison.c | 1663 ++++++++++++++ tools/perf/util/pmu-bison.h | 73 + tools/perf/util/pmu-flex.c | 1821 ++++++++++++++++ tools/perf/util/pmu-flex.h | 316 +++ tools/perf/util/pmu.c | 469 ++++ tools/perf/util/pmu.h | 41 + tools/perf/util/pmu.l | 43 + tools/perf/util/pmu.y | 93 + tools/perf/util/sysfs.c | 60 + tools/perf/util/sysfs.h | 6 + 31 files changed, 9974 insertions(+), 479 deletions(-)
PATCH v5 1/8 perf, tool: Remove unused functions from debugfs object
Following debugfs object functions are not referenced within the code:
int debugfs_valid_entry(const char *path); int debugfs_umount(void); int debugfs_write(const char *entry, const char *value); int debugfs_read(const char *entry, char *buffer, size_t size); void debugfs_force_cleanup(void); int debugfs_make_path(const char *element, char *buffer, int size);
Removing them.
--- tools/perf/util/debugfs.c | 141 --------------------------------------------- tools/perf/util/debugfs.h | 6 -- 2 files changed, 0 insertions(+), 147 deletions(-)
tools/perf/util/debugfs.c +0 -141
@@ -15,32 +15,6 @@ static const char *debugfs_known_mountpoints[] = { 0, }; -/* use this to force a umount */ -void debugfs_force_cleanup (void ) -{ -debugfs_find_mountpoint (); - debugfs_premounted =0 ; -debugfs_umount (); -} - -/* construct a full path to a debugfs element */ -int debugfs_make_path (const char *element,char *buffer,int size) -{ -int len; - -if (strlen (debugfs_mountpoint) ==0 ) { - buffer[0 ] ='\0' ; -return -1 ; - } - - len =strlen (debugfs_mountpoint) +strlen (element) +1 ; -if (len >= size) -return len+1 ; - -snprintf (buffer, size-1 ,"%s/%s" , debugfs_mountpoint, element); -return 0 ; -} -static int debugfs_found;/* find the path to the mounted debugfs */
@@ -97,17 +71,6 @@ int debugfs_valid_mountpoint(const char *debugfs)return 0 ; } - -int debugfs_valid_entry (const char *path) -{ -struct stat st; - -if (stat (path, &st)) -return -errno; - -return 0 ; -} -static void debugfs_set_tracing_events_path (const char *mountpoint) { snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s",
@@ -149,107 +112,3 @@ void debugfs_set_path(const char *mountpoint)snprintf (debugfs_mountpoint,sizeof (debugfs_mountpoint),"%s" , mountpoint);debugfs_set_tracing_events_path (mountpoint); } - -/* umount the debugfs */ - -int debugfs_umount (void ) -{ -char umountcmd[128 ]; -int ret; - -/* if it was already mounted, leave it */ -if (debugfs_premounted) -return 0 ; - -/* make sure it's a valid mount point */ - ret =debugfs_valid_mountpoint (debugfs_mountpoint); -if (ret) -return ret; - -snprintf (umountcmd,sizeof (umountcmd), -"/bin/umount %s" , debugfs_mountpoint); -return system (umountcmd); -} - -int debugfs_write (const char *entry,const char *value) -{ -char path[PATH_MAX +1 ]; -int ret, count; -int fd; - -/* construct the path */ -snprintf (path,sizeof (path),"%s/%s" , debugfs_mountpoint, entry); - -/* verify that it exists */ - ret =debugfs_valid_entry (path); -if (ret) -return ret; - -/* get how many chars we're going to write */ - count =strlen (value); - -/* open the debugfs entry */ - fd =open (path,O_RDWR ); -if (fd <0 ) -return -errno; - -while (count >0 ) { -/* write it */ - ret =write (fd, value, count); -if (ret <=0 ) { -if (ret ==EAGAIN ) -continue ; -close (fd); -return -errno; - } - count -= ret; - } - -/* close it */ -close (fd); - -/* return success */ -return 0 ; -} - -/* -* read a debugfs entry -* returns the number of chars read or a negative errno -*/ -int debugfs_read (const char *entry,char *buffer,size_t size) -{ -char path[PATH_MAX +1 ]; -int ret; -int fd; - -/* construct the path */ -snprintf (path,sizeof (path),"%s/%s" , debugfs_mountpoint, entry); - -/* verify that it exists */ - ret =debugfs_valid_entry (path); -if (ret) -return ret; - -/* open the debugfs entry */ - fd =open (path,O_RDONLY ); -if (fd <0 ) -return -errno; - -do { -/* read it */ - ret =read (fd, buffer, size); -if (ret ==0 ) { -close (fd); -return EOF ; - } - }while (ret <0 && errno ==EAGAIN ); - -/* close it */ -close (fd); - -/* make *sure* there's a null character at the end */ - buffer[ret] ='\0' ; - -/* return the number of chars read */ -return ret; -}
tools/perf/util/debugfs.h +0 -6
@@ -3,14 +3,8 @@const char *debugfs_find_mountpoint (void );int debugfs_valid_mountpoint (const char *debugfs); -int debugfs_valid_entry (const char *path);char *debugfs_mount (const char *mountpoint); -int debugfs_umount (void );void debugfs_set_path (const char *mountpoint); -int debugfs_write (const char *entry,const char *value); -int debugfs_read (const char *entry,char *buffer,size_t size); -void debugfs_force_cleanup (void ); -int debugfs_make_path (const char *element,char *buffer,int size);extern char debugfs_mountpoint[];extern char tracing_events_path[];
Signature · 1 line
1.7.4.4
PATCH v5 2/8 perf, tool: Add sysfs mountpoint interface
In reply to Jiri OlsaAdding sysfs object to provide sysfs mount information in the same way as debugfs object does.
The object provides following function:
sysfs_find_mountpoint
which returns the sysfs mount mount.
--- tools/perf/Makefile | 2 + tools/perf/util/sysfs.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/sysfs.h | 6 ++++ 3 files changed, 68 insertions(+), 0 deletions(-) create mode 100644 tools/perf/util/sysfs.c create mode 100644 tools/perf/util/sysfs.h
tools/perf/Makefile +2 -0
@@ -256,6 +256,7 @@ LIB_H += util/callchain.h LIB_H += util/build-id.h LIB_H += util/debug.h LIB_H += util/debugfs.h +LIB_H += util/sysfs.h LIB_H += util/event.h LIB_H += util/evsel.h LIB_H += util/evlist.h
@@ -302,6 +303,7 @@ LIB_OBJS += $(OUTPUT)util/build-id.o LIB_OBJS += $(OUTPUT)util/config.o LIB_OBJS += $(OUTPUT)util/ctype.o LIB_OBJS += $(OUTPUT)util/debugfs.o +LIB_OBJS += $(OUTPUT)util/sysfs.o LIB_OBJS += $(OUTPUT)util/environment.o LIB_OBJS += $(OUTPUT)util/event.o LIB_OBJS += $(OUTPUT)util/evlist.o
tools/perf/util/sysfs.c new file +60 -0
60 lines not on this page · raw message
tools/perf/util/sysfs.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef __SYSFS_H__ +#define __SYSFS_H__ + +const char *sysfs_find_mountpoint (void ); + +#endif /* __DEBUGFS_H__ */
Signature · 1 line
1.7.4.4
PATCH v5 3/8 perf, tool: Add bitmap_or function into bitmap object
In reply to Jiri OlsaAdding implementation os bitmap_or function to the bitmap object. It is stolen from the kernel lib/bitmap.o object.
It is used in upcomming patches.
--- tools/perf/util/bitmap.c | 10 ++++++++++ tools/perf/util/include/linux/bitmap.h | 11 +++++++++++ 2 files changed, 21 insertions(+), 0 deletions(-)
tools/perf/util/bitmap.c +10 -0
@@ -19,3 +19,13 @@ int __bitmap_weight(const unsigned long *bitmap, int bits)return w; } + +void __bitmap_or (unsigned long *dst,const unsigned long *bitmap1, +const unsigned long *bitmap2,int bits) +{ +int k; +int nr =BITS_TO_LONGS (bits); + +for (k =0 ; k < nr; k++) + dst[k] = bitmap1[k] | bitmap2[k]; +}
tools/perf/util/include/linux/bitmap.h +11 -0
@@ -5,6 +5,8 @@#include <linux/bitops.h> int __bitmap_weight (const unsigned long *bitmap,int bits); +void __bitmap_or (unsigned long *dst,const unsigned long *bitmap1, +const unsigned long *bitmap2,int bits);#define BITMAP_LAST_WORD_MASK (nbits) \ ( \
@@ -32,4 +34,13 @@ static inline int bitmap_weight(const unsigned long *src, int nbits) return __bitmap_weight(src, nbits); } +static inline void bitmap_or (unsigned long *dst,const unsigned long *src1, +const unsigned long *src2,int nbits) +{ +if (small_const_nbits (nbits)) + *dst = *src1 | *src2; +else +__bitmap_or (dst, src1, src2, nbits); +} +#endif /* _PERF_BITOPS_H */
Signature · 1 line
1.7.4.4
PATCH v5 4/8 perf: Adding sysfs group format attribute for pmu device
In reply to Jiri OlsaAdding sysfs group 'format' attribute for pmu device that contains a syntax description on how to construct raw events.
The event configuration is described in following
struct pefr_event_attr attributes:
config
config1
config2
Each sysfs attribute within the format attribute group, describes mapping of name and bitfield definition within one of above attributes.
eg:
"/sys/...<dev>/format/event" contains "config:0-7" "/sys/...<dev>/format/umask" contains "config:8-15"
"/sys/...<dev>/format/usr" contains "config:16"
the attribute value syntax is:
line: config ':' bits config: 'config' | 'config1' | 'config2" bits: bits ',' bit_term | bit_term bit_term: VALUE '-' VALUE | VALUE
Adding format attribute definitions for x86 cpu pmus.
--- .../testing/sysfs-bus-event_source-devices-format | 14 ++++++++ arch/x86/kernel/cpu/perf_event.c | 7 ++++ arch/x86/kernel/cpu/perf_event.h | 1 + arch/x86/kernel/cpu/perf_event_amd.c | 19 ++++++++++ arch/x86/kernel/cpu/perf_event_intel.c | 36 ++++++++++++++++++++ arch/x86/kernel/cpu/perf_event_p6.c | 19 ++++++++++ include/linux/perf_event.h | 14 ++++++++ 7 files changed, 110 insertions(+), 0 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-event_source-devices-format
Documentation/ABI/testing/sysfs-bus-event_source-devices-format new file +14 -0
@@ -0,0 +1,14 @@ +Where: /sys/bus/event_source/devices/<dev>/format +Date: January 2012 +Kernel Version: 3.3 +Contact: Jiri Olsa <[email protected]> +Description: + Attribute group to describe the magic bits that go into + perf_event_attr::config[012] for a particular pmu. + Each attribute of this group defines the 'hardware' bitmask + we want to export, so that userspace can deal with sane + name/value pairs. + + Example: 'config1:1,6-10,44' + Defines contents of attribute that occupies bits 1,6-10,44 of + perf_event_attr::config1.
arch/x86/kernel/cpu/perf_event.c +7 -0
@@ -1250,6 +1250,11 @@ static void __init pmu_check_apic(void)pr_info ("no hardware sampling interrupt available.\n" ); } +static struct attribute_group x86_pmu_format_group = { + .name ="format" , + .attrs =NULL , +}; +static int __init init_hw_perf_events (void ) {struct x86_pmu_quirk *quirk;
@@ -1324,6 +1329,7 @@ static int __init init_hw_perf_events(void) } x86_pmu.attr_rdpmc =1 ;/* enable userspace RDPMC usage by default */ + x86_pmu_format_group.attrs = x86_pmu.format_attrs;pr_info ("... version: %d\n" , x86_pmu.version);pr_info ("... bit width: %d\n" , x86_pmu.cntval_bits);
@@ -1604,6 +1610,7 @@ static struct attribute_group x86_pmu_attr_group = {static const struct attribute_group *x86_pmu_attr_groups[] = { &x86_pmu_attr_group, + &x86_pmu_format_group,NULL , };
arch/x86/kernel/cpu/perf_event.h +1 -0
@@ -311,6 +311,7 @@ struct x86_pmu {* sysfs attrs */ int attr_rdpmc; +struct attribute **format_attrs;/* * CPU Hotplug hooks
arch/x86/kernel/cpu/perf_event_amd.c +19 -0
@@ -398,6 +398,21 @@ static void amd_pmu_cpu_dead(int cpu) } } +PMU_FORMAT_ATTR (event,"config:0-7,32-35" ); +PMU_FORMAT_ATTR (umask,"config:8-15" ); +PMU_FORMAT_ATTR (edge,"config:18" ); +PMU_FORMAT_ATTR (inv,"config:23" ); +PMU_FORMAT_ATTR (cmask,"config:24-31" ); + +static struct attribute *amd_format_attr[] = { + &format_attr_event.attr, + &format_attr_umask.attr, + &format_attr_edge.attr, + &format_attr_inv.attr, + &format_attr_cmask.attr, +NULL , +}; +static __initconst const struct x86_pmu amd_pmu = { .name ="AMD" , .handle_irq = x86_pmu_handle_irq,
@@ -420,6 +435,8 @@ static __initconst const struct x86_pmu amd_pmu = { .get_event_constraints = amd_get_event_constraints, .put_event_constraints = amd_put_event_constraints, + .format_attrs = amd_format_attr, + .cpu_prepare = amd_pmu_cpu_prepare, .cpu_starting = amd_pmu_cpu_starting, .cpu_dead = amd_pmu_cpu_dead,
@@ -590,6 +607,8 @@ static __initconst const struct x86_pmu amd_pmu_f15h = { .cpu_starting = amd_pmu_cpu_starting, .cpu_dead = amd_pmu_cpu_dead, #endif + + .format_attrs = amd_format_attr, };__init int amd_pmu_init (void )
arch/x86/kernel/cpu/perf_event_intel.c +36 -0
@@ -1382,6 +1382,24 @@ static void core_pmu_enable_all(int added) } } +PMU_FORMAT_ATTR (event,"config:0-7" ); +PMU_FORMAT_ATTR (umask,"config:8-15" ); +PMU_FORMAT_ATTR (edge,"config:18" ); +PMU_FORMAT_ATTR (pc,"config:19" ); +PMU_FORMAT_ATTR (any,"config:21" );/* v3 + */ +PMU_FORMAT_ATTR (inv,"config:23" ); +PMU_FORMAT_ATTR (cmask,"config:24-31" ); + +static struct attribute *intel_arch_formats_attr[] = { + &format_attr_event.attr, + &format_attr_umask.attr, + &format_attr_edge.attr, + &format_attr_pc.attr, + &format_attr_inv.attr, + &format_attr_cmask.attr, +NULL , +}; +static __initconst const struct x86_pmu core_pmu = { .name ="core" , .handle_irq = x86_pmu_handle_irq,
@@ -1406,6 +1424,7 @@ static __initconst const struct x86_pmu core_pmu = { .put_event_constraints = intel_put_event_constraints, .event_constraints = intel_core_event_constraints, .guest_get_msrs = core_guest_get_msrs, + .format_attrs = intel_arch_formats_attr, };struct intel_shared_regs *allocate_shared_regs (int cpu)
@@ -1486,6 +1505,21 @@ static void intel_pmu_cpu_dying(int cpu)fini_debug_store_on_cpu (cpu); } +PMU_FORMAT_ATTR (offcore_rsp,"config1:0-63" ); + +static struct attribute *intel_arch3_formats_attr[] = { + &format_attr_event.attr, + &format_attr_umask.attr, + &format_attr_edge.attr, + &format_attr_pc.attr, + &format_attr_any.attr, + &format_attr_inv.attr, + &format_attr_cmask.attr, + + &format_attr_offcore_rsp.attr,/* XXX do NHM/WSM + SNB breakout */ +NULL , +}; +static __initconst const struct x86_pmu intel_pmu = { .name ="Intel" , .handle_irq = intel_pmu_handle_irq,
@@ -1509,6 +1543,8 @@ static __initconst const struct x86_pmu intel_pmu = { .get_event_constraints = intel_get_event_constraints, .put_event_constraints = intel_put_event_constraints, + .format_attrs = intel_arch3_formats_attr, + .cpu_prepare = intel_pmu_cpu_prepare, .cpu_starting = intel_pmu_cpu_starting, .cpu_dying = intel_pmu_cpu_dying,
arch/x86/kernel/cpu/perf_event_p6.c +19 -0
@@ -87,6 +87,23 @@ static void p6_pmu_enable_event(struct perf_event *event) (void )checking_wrmsrl (hwc->config_base, val); } +PMU_FORMAT_ATTR (event,"config:0-7" ); +PMU_FORMAT_ATTR (umask,"config:8-15" ); +PMU_FORMAT_ATTR (edge,"config:18" ); +PMU_FORMAT_ATTR (pc,"config:19" ); +PMU_FORMAT_ATTR (inv,"config:23" ); +PMU_FORMAT_ATTR (cmask,"config:24-31" ); + +static struct attribute *intel_p6_formats_attr[] = { + &format_attr_event.attr, + &format_attr_umask.attr, + &format_attr_edge.attr, + &format_attr_pc.attr, + &format_attr_inv.attr, + &format_attr_cmask.attr, +NULL , +}; +static __initconst const struct x86_pmu p6_pmu = { .name ="p6" , .handle_irq = x86_pmu_handle_irq,
@@ -115,6 +132,8 @@ static __initconst const struct x86_pmu p6_pmu = { .cntval_mask = (1ULL << 32) - 1, .get_event_constraints = x86_get_event_constraints, .event_constraints = p6_event_constraints, + + .format_attrs = intel_p6_formats_attr, };__init int p6_pmu_init (void )
include/linux/perf_event.h +14 -0
@@ -516,6 +516,7 @@ struct perf_guest_info_callbacks {#include <linux/irq_work.h> #include <linux/jump_label.h> #include <linux/atomic.h> +#include <linux/sysfs.h> #include <asm/local.h> #define PERF_MAX_STACK_DEPTH 255
@@ -1216,5 +1217,18 @@ do { \ register_cpu_notifier(&fn##_nb); \ } while (0) + +#define PMU_FORMAT_ATTR (_name, _format) \ +static ssize_t \ +_name##_show(struct device *dev, \ + struct device_attribute *attr, \ + char *page) \ +{ \ + BUILD_BUG_ON(sizeof(_format) >= PAGE_SIZE); \ + return sprintf(page, _format "\n"); \ +} \ + \ +static struct device_attribute format_attr_##_name = __ATTR_RO(_name) +#endif /* __KERNEL__ */ #endif /* _LINUX_PERF_EVENT_H */
Signature · 1 line
1.7.4.4
PATCH v5 5/8 perf, tool: Add parser generator for events parsing
In reply to Jiri OlsaChanging event parsing to use flex/bison parse generator. The event syntax stays as it was.
grammar description:
events: events ',' event | event
event: event_def PE_MODIFIER_EVENT | event_def
event_def: event_legacy_symbol sep_dc |
event_legacy_cache sep_dc |
event_legacy_breakpoint sep_dc |
event_legacy_tracepoint sep_dc |
event_legacy_numeric sep_dc | event_legacy_raw sep_dc
event_legacy_symbol: PE_NAME_SYM
event_legacy_cache: PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT |
PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT | PE_NAME_CACHE_TYPE
event_legacy_raw: PE_SEP_RAW PE_VALUE
event_legacy_numeric: PE_VALUE ':' PE_VALUE
event_legacy_breakpoint: PE_SEP_BP ':' PE_VALUE ':' PE_MODIFIER_BP
event_breakpoint_type: PE_MODIFIER_BPTYPE | empty
PE_NAME_SYM: cpu-cycles|cycles |
stalled-cycles-frontend|idle-cycles-frontend |
stalled-cycles-backend|idle-cycles-backend |
instructions |
cache-references |
cache-misses |
branch-instructions|branches |
branch-misses |
bus-cycles |
cpu-clock |
task-clock |
page-faults|faults |
minor-faults |
major-faults |
context-switches|cs |
cpu-migrations|migrations |
alignment-faults |emulation-faults
PE_NAME_CACHE_TYPE: L1-dcache|l1-d|l1d|L1-data |
L1-icache|l1-i|l1i|L1-instruction |
LLC|L2 |
dTLB|d-tlb|Data-TLB |
iTLB|i-tlb|Instruction-TLB |
branch|branches|bpu|btb|bpc |node
PE_NAME_CACHE_OP_RESULT: load|loads|read |
store|stores|write |
prefetch|prefetches |
speculative-read|speculative-load |
refs|Reference|ops|access |misses|miss
PE_MODIFIER_EVENT: [ukhp]{0,5}
PE_MODIFIER_BP: [rwx]
PE_SEP_BP: 'mem'
PE_SEP_RAW: 'r'
sep_dc: ':' |
Added flex/bison files for event grammar parsing. The generated parser is part of the patch. Added makefile rule 'event-parser' to generate the parser code out of the bison/flex sources.
--- tools/perf/Makefile | 17 + tools/perf/builtin-test.c | 6 +- tools/perf/util/parse-events-bison.c | 1715 ++++++++++++++++++++++++++ tools/perf/util/parse-events-bison.h | 79 ++ tools/perf/util/parse-events-flex.c | 2225 ++++++++++++++++++++++++++++++++++ tools/perf/util/parse-events-flex.h | 316 +++++ tools/perf/util/parse-events.c | 486 +++------ tools/perf/util/parse-events.h | 15 + tools/perf/util/parse-events.l | 107 ++ tools/perf/util/parse-events.y | 127 ++ 10 files changed, 4752 insertions(+), 341 deletions(-) create mode 100644 tools/perf/util/parse-events-bison.c create mode 100644 tools/perf/util/parse-events-bison.h create mode 100644 tools/perf/util/parse-events-flex.c create mode 100644 tools/perf/util/parse-events-flex.h create mode 100644 tools/perf/util/parse-events.l create mode 100644 tools/perf/util/parse-events.y
tools/perf/Makefile +17 -0
@@ -47,6 +47,8 @@ ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ CC = $(CROSS_COMPILE)gcc AR = $(CROSS_COMPILE)ar +FLEX = $(CROSS_COMPILE)flex +BISON= $(CROSS_COMPILE)bison # Additional ARCH settings for x86 ifeq ($(ARCH),i386)
@@ -340,6 +342,8 @@ LIB_OBJS += $(OUTPUT)util/session.o LIB_OBJS += $(OUTPUT)util/thread.o LIB_OBJS += $(OUTPUT)util/thread_map.o LIB_OBJS += $(OUTPUT)util/trace-event-parse.o +LIB_OBJS += $(OUTPUT)util/parse-events-flex.o +LIB_OBJS += $(OUTPUT)util/parse-events-bison.o LIB_OBJS += $(OUTPUT)util/trace-event-read.o LIB_OBJS += $(OUTPUT)util/trace-event-info.o LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o
@@ -628,6 +632,8 @@ ifndef V QUIET_LINK = @echo ' ' LINK $@; QUIET_MKDIR = @echo ' ' MKDIR $@; QUIET_GEN = @echo ' ' GEN $@; + QUIET_FLEX = @echo ' ' FLEX $@; + QUIET_BISON = @echo ' ' BISON $@; endif endif
@@ -708,6 +714,9 @@ $(OUTPUT)perf.o perf.spec \ $(SCRIPTS) \ : $(OUTPUT)PERF-VERSION-FILE +.SUFFIXES: +.SUFFIXES: .o .c .S .s + $(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $< $(OUTPUT)%.s: %.c $(OUTPUT)PERF-CFLAGS
@@ -740,6 +749,9 @@ $(OUTPUT)util/ui/browsers/map.o: util/ui/browsers/map.c $(OUTPUT)PERF-CFLAGS $(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< +$(OUTPUT)util/parse-events-flex.o: util/parse-events-flex.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -Wno-redundant-decls -Wno-switch-default -Wno-unused-function $< + $(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
@@ -776,6 +788,7 @@ help: @echo ' html - make html documentation' @echo ' info - make GNU info documentation (access with info <foo>)' @echo ' pdf - make pdf documentation' + @echo ' event-parser - make event parser code' @echo ' TAGS - use etags to make tag information for source browsing' @echo ' tags - use ctags to make tag information for source browsing' @echo ' cscope - use cscope to make interactive browsing database'
@@ -825,6 +838,10 @@ cscope: $(RM) cscope* $(FIND) . -name '*.[hcS]' -print | xargs cscope -b +event-parser: + $(QUIET_BISON)$(BISON) -v util/parse-events.y -d -o util/parse-events-bison.c + $(QUIET_FLEX)$(FLEX) --header-file=util/parse-events-flex.h -t util/parse-events.l > util/parse-events-flex.c + ### Detect prefix changes TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\ $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
tools/perf/builtin-test.c +3 -3
@@ -650,7 +650,7 @@ static int test__checkevent_raw(struct perf_evlist *evlist)TEST_ASSERT_VAL ("wrong number of entries" ,1 == evlist->nr_entries);TEST_ASSERT_VAL ("wrong type" ,PERF_TYPE_RAW == evsel->attr.type); -TEST_ASSERT_VAL ("wrong config" ,1 == evsel->attr.config); +TEST_ASSERT_VAL ("wrong config" ,0x1a == evsel->attr.config);return 0 ; }
@@ -872,7 +872,7 @@ static struct test__event_st { .check = test__checkevent_tracepoint_multi, }, { - .name = "r1", + .name = "r1a", .check = test__checkevent_raw, }, {
@@ -916,7 +916,7 @@ static struct test__event_st { .check = test__checkevent_tracepoint_multi_modifier, }, { - .name = "r1:kp", + .name = "r1a:kp", .check = test__checkevent_raw_modifier, }, {
tools/perf/util/parse-events-bison.c new file +1715 -0
1,715 lines not on this page · raw message
tools/perf/util/parse-events-bison.h new file +79 -0
79 lines not on this page · raw message
tools/perf/util/parse-events-flex.c new file +2225 -0
1,123 lines not on this page · raw message
tools/perf/util/parse-events-flex.h new file +316 -0
316 lines not on this page · raw message
tools/perf/util/parse-events.c +148 -338
486 lines not on this page · raw message
tools/perf/util/parse-events.l new file +107 -0
107 lines not on this page · raw message
tools/perf/util/parse-events.y new file +127 -0
127 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.4.4
Part of the diff is not shown here. View the raw message.
PATCH v5 6/8 perf, tool: Add config options support for event parsing
In reply to Jiri OlsaAdding a new rule to the event grammar to be able to specify values of additional attributes of symbolic event.
The new syntax for event symbolic definition is:
event_legacy_symbol: PE_NAME_SYM '/' event_config '/' |
PE_NAME_SYM sep_slash_dc
event_config: event_config ',' event_term | event_term
event_term: PE_NAME '=' PE_NAME |
PE_NAME '=' PE_VALUE
PE_NAME
sep_slash_dc: '/' | ':' |
At the moment the config options are hardcoded to be used for legacy symbol events to define several perf_event_attr fields. It is:
'config' to define perf_event_attr::config 'config1' to define perf_event_attr::config1 'config2' to define perf_event_attr::config2 'period' to define perf_event_attr::sample_period
Legacy events could be now specified as:
cycles/period=100000/
If term is specified without the value assignment, then 1 is assigned by default.
--- tools/perf/builtin-test.c | 22 + tools/perf/util/parse-events-bison.c | 310 +++++++++++----- tools/perf/util/parse-events-bison.h | 23 +- tools/perf/util/parse-events-flex.c | 713 ++++++++++++++++++---------------- tools/perf/util/parse-events-flex.h | 2 +- tools/perf/util/parse-events.c | 99 +++++- tools/perf/util/parse-events.h | 31 ++- tools/perf/util/parse-events.l | 19 + tools/perf/util/parse-events.y | 94 +++++- 9 files changed, 866 insertions(+), 447 deletions(-)
tools/perf/builtin-test.c +22 -0
@@ -677,6 +677,24 @@ static int test__checkevent_symbolic_name(struct perf_evlist *evlist)return 0 ; } +static int test__checkevent_symbolic_name_config (struct perf_evlist *evlist) +{ +struct perf_evsel *evsel =list_entry (evlist->entries.next, + struct perf_evsel, node); + +TEST_ASSERT_VAL ("wrong number of entries" ,1 == evlist->nr_entries); +TEST_ASSERT_VAL ("wrong type" ,PERF_TYPE_HARDWARE == evsel->attr.type); +TEST_ASSERT_VAL ("wrong config" , +PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); +TEST_ASSERT_VAL ("wrong period" , +100000 == evsel->attr.sample_period); +TEST_ASSERT_VAL ("wrong config1" , +0 == evsel->attr.config1); +TEST_ASSERT_VAL ("wrong config2" , +1 == evsel->attr.config2); +return 0 ; +} +static int test__checkevent_symbolic_alias (struct perf_evlist *evlist) { struct perf_evsel *evsel = list_entry(evlist->entries.next,
@@ -884,6 +902,10 @@ static struct test__event_st { .check = test__checkevent_symbolic_name, }, { + .name = "cycles/period=100000,config2/", + .check = test__checkevent_symbolic_name_config, + }, + { .name = "faults", .check = test__checkevent_symbolic_alias, },
tools/perf/util/parse-events-bison.c +217 -93
522 lines not on this page · raw message
tools/perf/util/parse-events-bison.h +13 -10
@@ -41,14 +41,15 @@PE_VALUE =258 ,PE_VALUE_SYM =259 ,PE_RAW =260 , -PE_NAME =261 , -PE_MODIFIER_EVENT =262 , -PE_MODIFIER_BP =263 , -PE_NAME_CACHE_TYPE =264 , -PE_NAME_CACHE_OP_RESULT =265 , -PE_PREFIX_MEM =266 , -PE_PREFIX_RAW =267 , -PE_ERROR =268 +PE_TERM =261 , +PE_NAME =262 , +PE_MODIFIER_EVENT =263 , +PE_MODIFIER_BP =264 , +PE_NAME_CACHE_TYPE =265 , +PE_NAME_CACHE_OP_RESULT =266 , +PE_PREFIX_MEM =267 , +PE_PREFIX_RAW =268 , +PE_ERROR =269 };#endif
@@ -59,15 +60,17 @@ typedef union YYSTYPE {/* Line 1685 of yacc.c */ -#line 42 "util/parse-events.y" +#line 45 "util/parse-events.y"char *str;unsigned long num; +struct list_head *head; +struct parse_events__term *term;/* Line 1685 of yacc.c */ -#line 71 "util/parse-events-bison.h" +#line 74 "util/parse-events-bison.h" }YYSTYPE ;# define YYSTYPE_IS_TRIVIAL 1# define yystype YYSTYPE/* obsolescent; will be withdrawn */
tools/perf/util/parse-events-flex.c +380 -333
947 lines not on this page · raw message
tools/perf/util/parse-events-flex.h +1 -1
@@ -308,7 +308,7 @@ extern int parse_events_lex (void);#undef YY_DECL#endif -#line 102 "util/parse-events.l" +#line 121 "util/parse-events.l"#line 315 "util/parse-events-flex.h"
tools/perf/util/parse-events.c +96 -3
114 lines not on this page · raw message
tools/perf/util/parse-events.h +30 -1
@@ -33,6 +33,34 @@ extern int parse_filter(const struct option *opt, const char *str, int unset);#define EVENTS_HELP_MAX (128*1024) +enum { +PARSE_EVENTS__TERM_TYPE_CONFIG , +PARSE_EVENTS__TERM_TYPE_CONFIG1 , +PARSE_EVENTS__TERM_TYPE_CONFIG2 , +PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD , +PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE , +PARSE_EVENTS__TERM_TYPE_NUM , +PARSE_EVENTS__TERM_TYPE_STR , + +PARSE_EVENTS__TERM_TYPE_HARDCODED_MAX = +PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE , +}; + +struct parse_events__term { +char *config; +union { +char *str; +long num; + } val; +int type; + +struct list_head list; +}; + +int parse_events__is_hardcoded_term (struct parse_events__term *term); +int parse_events__new_term (struct parse_events__term **term,int type, +char *config,char *str,long num); +void parse_events__free_terms (struct list_head *terms);int parse_events_modifier (struct list_head *list__used ,char *str__used );int parse_events_add_tracepoint (struct list_head *list,int *idx,char *sys,char *event);
@@ -40,7 +68,8 @@ int parse_events_add_raw(struct perf_evlist *evlist, unsigned long config, unsigned long config1, unsigned long config2, char *mod);int parse_events_add_numeric (struct list_head *list,int *idx, -unsigned long type,unsigned long config); +unsigned long type,unsigned long config, +struct list_head *head_config);int parse_events_add_cache (struct list_head *list,int *idx,char *type,char *op_result1,char *op_result2); int parse_events_add_breakpoint(struct list_head *list, int *idx,
tools/perf/util/parse-events.l +19 -0
@@ -5,6 +5,7 @@ #include <errno.h> #include "../perf.h" #include "parse-events-bison.h" +#include "parse-events.h" static int __value(char *str, int base, int token) {
@@ -41,6 +42,12 @@ static int sym(int type, int config) return PE_VALUE_SYM; } +static int term(int type) +{ + parse_events_lval.num = type; + return PE_TERM; +} + %} num_dec [0-9]+
@@ -85,6 +92,18 @@ speculative-read|speculative-load | refs|Reference|ops|access | misses|miss { return str(PE_NAME_CACHE_OP_RESULT); } + /* + * These are event config hardcoded term names to be specified + * within xxx/.../ syntax. So far we dont clash with other names, + * so we can put them here directly. In case the we have a conflict + * in future, this needs to go into '//' condition block. + */ +config { return term(PARSE_EVENTS__TERM_TYPE_CONFIG); } +config1 { return term(PARSE_EVENTS__TERM_TYPE_CONFIG1); } +config2 { return term(PARSE_EVENTS__TERM_TYPE_CONFIG2); } +period { return term(PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); } +branch_type { return term(PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); } + mem: { return PE_PREFIX_MEM; } r{num_raw_hex} { return raw(); } {num_dec} { return value(10); }
tools/perf/util/parse-events.y +88 -6
147 lines not on this page · raw message
Signature · 1 line
1.7.4.4
PATCH v5 7/8 perf, tool: Add perf pmu object to access pmu format definition
In reply to Jiri OlsaAdding pmu object which provides interface to pmu's sysfs event format definition located at:
${sysfs_mount}/bus/event_source/devices/${pmu}/format
Following interface is exported:
struct perf_pmu* perf_pmu__find(char *name);
- this function returns pmu object, which is then passed as a handle to other interface functions
int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr,
struct list_head *head_terms);
- this function configures perf_event_attr struct based on pmu's format definitions and config terms data, containined in head_terms list.
Parser generator is used to retrive the pmu's format definition. The generated parser is part of the patch. Added makefile rule 'pmu-parser' to generate the parser code out of the bison/flex sources.
Added builtin test 'Test perf pmu format parsing', which could be run like:
perf test pmu
--- tools/perf/Makefile | 12 + tools/perf/builtin-test.c | 10 + tools/perf/util/pmu-bison.c | 1663 +++++++++++++++++++++++++++++++++++++++ tools/perf/util/pmu-bison.h | 73 ++ tools/perf/util/pmu-flex.c | 1821 +++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/pmu-flex.h | 316 ++++++++ tools/perf/util/pmu.c | 469 +++++++++++ tools/perf/util/pmu.h | 41 + tools/perf/util/pmu.l | 43 + tools/perf/util/pmu.y | 93 +++ 10 files changed, 4541 insertions(+), 0 deletions(-) create mode 100644 tools/perf/util/pmu-bison.c create mode 100644 tools/perf/util/pmu-bison.h create mode 100644 tools/perf/util/pmu-flex.c create mode 100644 tools/perf/util/pmu-flex.h create mode 100644 tools/perf/util/pmu.c create mode 100644 tools/perf/util/pmu.h create mode 100644 tools/perf/util/pmu.l create mode 100644 tools/perf/util/pmu.y
tools/perf/Makefile +12 -0
@@ -259,6 +259,7 @@ LIB_H += util/build-id.h LIB_H += util/debug.h LIB_H += util/debugfs.h LIB_H += util/sysfs.h +LIB_H += util/pmu.h LIB_H += util/event.h LIB_H += util/evsel.h LIB_H += util/evlist.h
@@ -306,6 +307,7 @@ LIB_OBJS += $(OUTPUT)util/config.o LIB_OBJS += $(OUTPUT)util/ctype.o LIB_OBJS += $(OUTPUT)util/debugfs.o LIB_OBJS += $(OUTPUT)util/sysfs.o +LIB_OBJS += $(OUTPUT)util/pmu.o LIB_OBJS += $(OUTPUT)util/environment.o LIB_OBJS += $(OUTPUT)util/event.o LIB_OBJS += $(OUTPUT)util/evlist.o
@@ -344,6 +346,8 @@ LIB_OBJS += $(OUTPUT)util/thread_map.o LIB_OBJS += $(OUTPUT)util/trace-event-parse.o LIB_OBJS += $(OUTPUT)util/parse-events-flex.o LIB_OBJS += $(OUTPUT)util/parse-events-bison.o +LIB_OBJS += $(OUTPUT)util/pmu-flex.o +LIB_OBJS += $(OUTPUT)util/pmu-bison.o LIB_OBJS += $(OUTPUT)util/trace-event-read.o LIB_OBJS += $(OUTPUT)util/trace-event-info.o LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o
@@ -752,6 +756,9 @@ $(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS $(OUTPUT)util/parse-events-flex.o: util/parse-events-flex.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -Wno-redundant-decls -Wno-switch-default -Wno-unused-function $< +$(OUTPUT)util/pmu-flex.o: util/pmu-flex.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -Wno-redundant-decls -Wno-switch-default -Wno-unused-function $< + $(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
@@ -789,6 +796,7 @@ help: @echo ' info - make GNU info documentation (access with info <foo>)' @echo ' pdf - make pdf documentation' @echo ' event-parser - make event parser code' + @echo ' pmu-parser - make pmu format parser code' @echo ' TAGS - use etags to make tag information for source browsing' @echo ' tags - use ctags to make tag information for source browsing' @echo ' cscope - use cscope to make interactive browsing database'
@@ -842,6 +850,10 @@ event-parser: $(QUIET_BISON)$(BISON) -v util/parse-events.y -d -o util/parse-events-bison.c $(QUIET_FLEX)$(FLEX) --header-file=util/parse-events-flex.h -t util/parse-events.l > util/parse-events-flex.c +pmu-parser: + $(QUIET_BISON)$(BISON) -v util/pmu.y -d -o util/pmu-bison.c + $(QUIET_FLEX)$(FLEX) --header-file=util/pmu-flex.h -t util/pmu.l > util/pmu-flex.c + ### Detect prefix changes TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\ $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
tools/perf/builtin-test.c +10 -0
@@ -13,6 +13,7 @@#include "util/parse-events.h" #include "util/symbol.h" #include "util/thread_map.h" +#include "util/pmu.h" #include "../../include/linux/hw_breakpoint.h" #include <sys/mman.h>
@@ -1487,6 +1488,11 @@ static int test__rdpmc(void)#endif +static int test__perf_pmu (void ) +{ +return perf_pmu__test (); +} + static struct test { const char *desc; int (*func)(void);
@@ -1522,6 +1528,10 @@ static struct test { .func = test__PERF_RECORD, }, { + .desc = "Test perf pmu format parsing", + .func = test__perf_pmu, + }, + { .func = NULL, }, };
tools/perf/util/pmu-bison.c new file +1663 -0
1,663 lines not on this page · raw message
tools/perf/util/pmu-bison.h new file +73 -0
73 lines not on this page · raw message
tools/perf/util/pmu-flex.c new file +1821 -0
1,188 lines not on this page · raw message
tools/perf/util/pmu-flex.h new file +316 -0
316 lines not on this page · raw message
tools/perf/util/pmu.c new file +469 -0
469 lines not on this page · raw message
tools/perf/util/pmu.h new file +41 -0
41 lines not on this page · raw message
tools/perf/util/pmu.l new file +43 -0
43 lines not on this page · raw message
tools/perf/util/pmu.y new file +93 -0
93 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.4.4
Part of the diff is not shown here. View the raw message.
PATCH v5 8/8 perf, tool: Add support to specify pmu style event
In reply to Jiri OlsaAdded new event rule to the event definition grammar:
event_def: event_pmu |
...
event_pmu: PE_NAME '/' event_config '/'
Using this rule, event could be now specified like:
cpu/config=1,config1=2,config2=3/u
where pmu name 'cpu' is looked up via following path:
${sysfs_mount}/bus/event_source/devices/${pmu}
and config options are bound to the pmu's format definiton:
${sysfs_mount}/bus/event_source/devices/${pmu}/format
The hardcoded config options still stays and have precedence over any format field defined with same name.
--- tools/perf/builtin-test.c | 20 ++++ tools/perf/util/parse-events-bison.c | 209 ++++++++++++++++++---------------- tools/perf/util/parse-events.c | 31 +++++- tools/perf/util/parse-events.h | 2 + tools/perf/util/parse-events.y | 10 ++- 5 files changed, 172 insertions(+), 100 deletions(-)
tools/perf/builtin-test.c +20 -0
@@ -877,6 +877,22 @@ static int test__checkevent_genhw_modifier(struct perf_evlist *evlist)return test__checkevent_genhw (evlist); } +static int test__checkevent_pmu (struct perf_evlist *evlist) +{ + +struct perf_evsel *evsel =list_entry (evlist->entries.next, + struct perf_evsel, node); + +TEST_ASSERT_VAL ("wrong number of entries" ,1 == evlist->nr_entries); +TEST_ASSERT_VAL ("wrong type" ,PERF_TYPE_RAW == evsel->attr.type); +TEST_ASSERT_VAL ("wrong config" ,10 == evsel->attr.config); +TEST_ASSERT_VAL ("wrong config1" ,1 == evsel->attr.config1); +TEST_ASSERT_VAL ("wrong config2" ,3 == evsel->attr.config2); +TEST_ASSERT_VAL ("wrong period" ,1000 == evsel->attr.sample_period); + +return 0 ; +} + static struct test__event_st { const char *name; __u32 type;
@@ -958,6 +974,10 @@ static struct test__event_st { .name = "L1-dcache-load-miss:kp", .check = test__checkevent_genhw_modifier, }, + { + .name = "cpu/config=10,config1,config2=3,period=1000/u", + .check = test__checkevent_pmu, + }, };#define TEST__EVENTS_CNT (sizeof(test__events) / sizeof(struct test__event_st))
tools/perf/util/parse-events-bison.c +111 -98
435 lines not on this page · raw message
tools/perf/util/parse-events.c +30 -1
@@ -12,6 +12,7 @@#include "header.h" #include "debugfs.h" #include "parse-events-flex.h" +#include "pmu.h" #define MAX_NAME_LEN 100
@@ -646,6 +647,30 @@ int parse_events_add_numeric(struct list_head *list, int *idx, (char *) __event_name(type, config)); } +int parse_events_add_pmu (struct list_head *list,int *idx, +char *name,struct list_head *head_config) +{ +struct perf_event_attr attr; +struct perf_pmu *pmu; + + pmu =perf_pmu__find (name); +if (!pmu) +return -EINVAL ; + +memset (&attr,0 ,sizeof (attr)); + +/* +* Configure hardcoded terms first, no need to check +* return value when called with fail == 0 ;) +*/ +config_attr (&attr, head_config,0 ); + +if (perf_pmu__config (pmu, &attr, head_config)) +return -EINVAL ; + +return add_event (list, idx, &attr, (char *)"pmu" ); +} +int parse_events_modifier (struct list_head *list,char *str) {struct perf_evsel *evsel;
@@ -957,8 +982,12 @@ void print_events(const char *event_glob)printf ("\n" );printf (" %-50s [%s]\n" , -"rNNN (see 'perf list --help' on how to encode it)" , +"rNNN" , + event_type_descriptors[PERF_TYPE_RAW ]); +printf (" %-50s [%s]\n" , +"cpu/t1=v1[,t2=v2,t3 ...]/modifier" , event_type_descriptors[PERF_TYPE_RAW ]); +printf (" (see 'perf list --help' on how to encode it)\n" );printf ("\n" ); printf(" %-50s [%s]\n",
tools/perf/util/parse-events.h +2 -0
@@ -74,6 +74,8 @@ int parse_events_add_cache(struct list_head *list, int *idx, char *type, char *op_result1, char *op_result2);int parse_events_add_breakpoint (struct list_head *list,int *idx,void *ptr,char *type); +int parse_events_add_pmu (struct list_head *list,int *idx, +char *pmu ,struct list_head *head_config);void parse_events_error (struct list_head *list,int *idx,char const *msg);
tools/perf/util/parse-events.y +9 -1
@@ -61,13 +61,21 @@ event_def PE_MODIFIER_EVENT | event_def -event_def: event_legacy_symbol | +event_def: event_pmu | + event_legacy_symbol | event_legacy_cache sep_dc | event_legacy_mem | event_legacy_tracepoint sep_dc | event_legacy_numeric sep_dc | event_legacy_raw sep_dc +event_pmu: +PE_NAME '/' event_config '/' +{ + ABORT_ON(parse_events_add_pmu(list, idx, $1, $3)); + parse_events__free_terms($3); +} + event_legacy_symbol: PE_VALUE_SYM '/' event_config '/' {
Signature · 1 line
1.7.4.4
Quoted 25 lines · Jiri Olsa
hi,
here's new version of event parsing patchset.I saw Arnaldo already sent patches 1-3 to Ingo, but they did not make it to the tree yet, so I'm still attaching them here.
v5 changes:
4/8 - patch updated by Peter with actual format definitions
for x86 processors
6/8 - added hardcoded terms for config[12] andsample_period
the code is ready to includebranch_sample_typeonce this field is available inperf_event_attr, just uncommenting one line.. ;)
- allow config option to be used without value in which case 1 is assigned as valueOverall summarize:
- adding event parser bison/flex generator
- the event syntax stays as it was
- adding event format sysfs group attribute
for pmu device
- adding new syntax to specify raw events based
on the sysfs pmu's format attribute
eg. "cpu/config=1,config1=2,config2=3/u"
Quoted 9 lines
Attached patches:
1/8 perf, tool: Remove unused functions from debugfs object 2/8 perf, tool: Add sysfs mountpoint interface
3/8 perf, tool: Addbitmap_orfunction into bitmap object 4/8 perf: Adding sysfs group format attribute for pmu device 5/8 perf, tool: Add parser generator for events parsing 6/8 perf, tool: Add config options support for event parsing 7/8 perf, tool: Add perf pmu object to access pmu format definition 8/8 perf, tool: Add support to specify pmu style event
I'm fine with this going fwd, and since this is mostly tools/perf I suggest acme take it, so:
Also, it might make sense to CC everybody who has/maintains a hardware pmu implementation on patch 4.
Thanks Jiri!
Em Thu, Feb 16, 2012 at 06:03:03PM +0100, Peter Zijlstra escreveu:
Quoted 6 lines · Jiri Olsa
Quoted 5 lines
hi,
here's new version of event parsing patchset.I saw Arnaldo already sent patches 1-3 to Ingo, but they did not make it to the tree yet, so I'm still attaching them here.
Right, I'll take the rest (read this just now, keeping the dup comments below :-) ).
Quoted 29 lines
Quoted 19 lines
v5 changes:
4/8 - patch updated by Peter with actual format definitions
for x86 processors
6/8 - added hardcoded terms for config[12] andsample_period
the code is ready to includebranch_sample_typeonce this field is available inperf_event_attr, just uncommenting one line.. ;)
- allow config option to be used without value in which case 1 is assigned as valueOverall summarize:
- adding event parser bison/flex generator
- the event syntax stays as it was
- adding event format sysfs group attribute
for pmu device
- adding new syntax to specify raw events based
on the sysfs pmu's format attribute
eg. "cpu/config=1,config1=2,config2=3/u"Quoted 9 lines
Attached patches:
1/8 perf, tool: Remove unused functions from debugfs object 2/8 perf, tool: Add sysfs mountpoint interface
3/8 perf, tool: Addbitmap_orfunction into bitmap object 4/8 perf: Adding sysfs group format attribute for pmu device 5/8 perf, tool: Add parser generator for events parsing 6/8 perf, tool: Add config options support for event parsing 7/8 perf, tool: Add perf pmu object to access pmu format definition 8/8 perf, tool: Add support to specify pmu style event
Quoted 7 lines
I'm fine with this going fwd, and since this is mostly
tools/perfI suggest acme take it, so:Acked-by Peter Zijlstra <[email protected]>Also, it might make sense to CC everybody who has/maintains a hardware pmu implementation on patch 4.
I'll do it, I already merged patch 1, 2, 3 in my perf/core branch, will look and merge the rest, adding your a-b.
- Arnaldo