Skip to contentSkip to conversation

perf, tools: Make alias matching case-insensitive

PATCH In review Andi Kleen 2 participants 2 messages Aug 28, 2015 – Aug 31, 2015 perf events

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 perf, tools: Make alias matching case-insensitive

From: Andi Kleen <[email protected]>

Make alias matching the events parser case-insensitive. This is useful with the JSON events. perf uses lower case events, but the CPU manuals generally use upper case event names. The JSON files use lower case by default too. But if we search case insensitively then users can cut-n-paste the upper case event names.

So the following works:

% perf stat -e BR_INST_EXEC.TAKEN_INDIRECT_NEAR_CALL true

Performance counter stats for 'true':

               305      BR_INST_EXEC.TAKEN_INDIRECT_NEAR_CALL

       0.000492799 seconds time elapsed
---
 tools/perf/util/parse-events.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/parse-events.c +1 -1
index e14ceb6..2347840 100644
@@ -981,7 +981,7 @@ comp_pmu(const void *p1, const void *p2)
 	struct perf_pmu_event_symbol *pmu1 = (struct perf_pmu_event_symbol *) p1;
 	struct perf_pmu_event_symbol *pmu2 = (struct perf_pmu_event_symbol *) p2;
 
-	return strcmp(pmu1->symbol, pmu2->symbol);
+	return strcasecmp(pmu1->symbol, pmu2->symbol);
 }
 
 static void perf_pmu__parse_cleanup(void)
Signature · 1 line
2.4.3
Tested-by on v1 1/1
#1 lore raw

Andi Kleen [[email protected]] wrote:

| From: Andi Kleen <[email protected]>
| 
| Make alias matching the events parser case-insensitive. This is useful
| with the JSON events. perf uses lower case events, but the CPU manuals
| generally use upper case event names. The JSON files use lower
| case by default too. But if we search case insensitively then
| users can cut-n-paste the upper case event names.
| 
| So the following works:
| 
| % perf stat -e BR_INST_EXEC.TAKEN_INDIRECT_NEAR_CALL true
| 
|  Performance counter stats for 'true':
| 
|                305      BR_INST_EXEC.TAKEN_INDIRECT_NEAR_CALL
| 
|        0.000492799 seconds time elapsed
| 
| Signed-off-by: Andi Kleen <[email protected]>

I have also pushed this to 'json-v16' branch of my github tree:

https://github.com/sukadev/linux

Sukadev