diff options
author | Jaswinder Singh Rajput <jaswinder@kernel.org> | 2009-06-25 07:46:07 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-06-25 08:08:49 -0400 |
commit | 06813f6c743420c16f9248ab59bd2e68a2de57ba (patch) | |
tree | 86ebf73e025c1fbe0ecd8b3d0c9a673ae8c88995 /tools/perf | |
parent | 76c64c5e4c47b6d28deb3cae8dfa07a93c2229dc (diff) |
perf_counter tools: Check for valid cache operations
Made new table for cache operartion stat 'hw_cache_stat' as:
L1I : Read and prefetch only
ITLB and BPU : Read-only
introduce is_cache_op_valid() for cache operation validity
And checks for valid cache operations.
Reported-by : Ingo Molnar <mingo@elte.hu>
Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <1245930367.5308.33.camel@localhost.localdomain>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/parse-events.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 06af2fadcd87..7939a21130d2 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -90,6 +90,34 @@ static char *hw_cache_result[][MAX_ALIASES] = { | |||
90 | { "Miss" }, | 90 | { "Miss" }, |
91 | }; | 91 | }; |
92 | 92 | ||
93 | #define C(x) PERF_COUNT_HW_CACHE_##x | ||
94 | #define CACHE_READ (1 << C(OP_READ)) | ||
95 | #define CACHE_WRITE (1 << C(OP_WRITE)) | ||
96 | #define CACHE_PREFETCH (1 << C(OP_PREFETCH)) | ||
97 | #define COP(x) (1 << x) | ||
98 | |||
99 | /* | ||
100 | * cache operartion stat | ||
101 | * L1I : Read and prefetch only | ||
102 | * ITLB and BPU : Read-only | ||
103 | */ | ||
104 | static unsigned long hw_cache_stat[C(MAX)] = { | ||
105 | [C(L1D)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH), | ||
106 | [C(L1I)] = (CACHE_READ | CACHE_PREFETCH), | ||
107 | [C(LL)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH), | ||
108 | [C(DTLB)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH), | ||
109 | [C(ITLB)] = (CACHE_READ), | ||
110 | [C(BPU)] = (CACHE_READ), | ||
111 | }; | ||
112 | |||
113 | static int is_cache_op_valid(u8 cache_type, u8 cache_op) | ||
114 | { | ||
115 | if (hw_cache_stat[cache_type] & COP(cache_op)) | ||
116 | return 1; /* valid */ | ||
117 | else | ||
118 | return 0; /* invalid */ | ||
119 | } | ||
120 | |||
93 | char *event_name(int counter) | 121 | char *event_name(int counter) |
94 | { | 122 | { |
95 | u64 config = attrs[counter].config; | 123 | u64 config = attrs[counter].config; |
@@ -123,6 +151,8 @@ char *event_name(int counter) | |||
123 | if (cache_result > PERF_COUNT_HW_CACHE_RESULT_MAX) | 151 | if (cache_result > PERF_COUNT_HW_CACHE_RESULT_MAX) |
124 | return "unknown-ext-hardware-cache-result"; | 152 | return "unknown-ext-hardware-cache-result"; |
125 | 153 | ||
154 | if (!is_cache_op_valid(cache_type, cache_op)) | ||
155 | return "invalid-cache"; | ||
126 | sprintf(name, "%s-Cache-%s-%ses", | 156 | sprintf(name, "%s-Cache-%s-%ses", |
127 | hw_cache[cache_type][0], | 157 | hw_cache[cache_type][0], |
128 | hw_cache_op[cache_op][0], | 158 | hw_cache_op[cache_op][0], |
@@ -179,6 +209,9 @@ parse_generic_hw_symbols(const char *str, struct perf_counter_attr *attr) | |||
179 | if (cache_op == -1) | 209 | if (cache_op == -1) |
180 | cache_op = PERF_COUNT_HW_CACHE_OP_READ; | 210 | cache_op = PERF_COUNT_HW_CACHE_OP_READ; |
181 | 211 | ||
212 | if (!is_cache_op_valid(cache_type, cache_op)) | ||
213 | return -EINVAL; | ||
214 | |||
182 | cache_result = parse_aliases(str, hw_cache_result, | 215 | cache_result = parse_aliases(str, hw_cache_result, |
183 | PERF_COUNT_HW_CACHE_RESULT_MAX); | 216 | PERF_COUNT_HW_CACHE_RESULT_MAX); |
184 | /* | 217 | /* |