Re: [PATCH 1/3] perf, tool: Add parser generator for events parsing

From: Peter Zijlstra
Date: Fri Dec 16 2011 - 09:03:50 EST


On Thu, 2011-12-15 at 16:30 +0100, Jiri Olsa wrote:
> events: events ',' event | event
>
> event: event_tracepoint |
> event_raw |
> event_numeric |
> event_symbolic |
> event_generic_hw |
> event_breakpoint
>
> event_tracepoint: PE_NAME_TP ':' PE_NAME_TP modifier
> event_raw: PE_SEP_RAW PE_VALUE modifier
> event_numeric: PE_VALUE ':' PE_VALUE modifier
> event_symbolic: PE_NAME_SYM modifier
> event_generic_hw: PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT modifier |
> PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT modifier |
> PE_NAME_CACHE_TYPE modifier
> event_breakpoint: PE_SEP_BP ':' PE_VALUE event_breakpoint_type modifier
> event_breakpoint_type: PE_MODIFIER_BPTYPE | empty
> modifier: PE_MODIFIER_EVENT | empty

This isn't complete, we need means of specifying
perf_event_attr::config[12] when specifying a raw event.


> 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

It might make sense to allow means of custom symbol -> raw mappings.

> 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_SEP_RAW: 'r'
> PE_SEP_BP: 'mem'
> PE_MODIFIER_EVENT: :[ukhp]{1,2}

You can actually have more than 2 modifiers, eg. "upp".

[u] | [k] | [h] | [p]{,3} would be more correct I think.

> PE_MODIFIER_BPTYPE: :[rwx]{1,3}
> PE_NAME_TP: [a-zA-Z_*?]+
> PE_VALUE: number
>
> Added flex/bison files for event grammar parsing. Added
> flex/bison Makefile rules plus few special dependencies.

It might be good to include the .c output of flex/bison so that we can
build perf without a hard dependency on them -- only people changing the
parser will need them.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/