aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/parse-events.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-08-27 21:09:58 -0400
committerIngo Molnar <mingo@elte.hu>2009-08-28 01:58:11 -0400
commit1ef2ed1066ae9f8080cd96cba11c2d41118b8792 (patch)
tree44c9e7216610bdca195f21d4934ece4d339df456 /tools/perf/util/parse-events.c
parent1909629fb1ec9800cf2cb0091870d6a1c1ca665f (diff)
perf tools: Only save the event formats we need
While opening a trace event counter, every events are saved in the trace.info file. But we only want to save the specifications of the events we are using. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Steven Rostedt <rostedt@goodmis.org> LKML-Reference: <1251421798-9101-1-git-send-email-fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/parse-events.c')
-rw-r--r--tools/perf/util/parse-events.c47
1 files changed, 39 insertions, 8 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 1cda97b39118..89d46c99bc9c 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -158,9 +158,9 @@ int valid_debugfs_mount(const char *debugfs)
158 return 0; 158 return 0;
159} 159}
160 160
161static const char *tracepoint_id_to_name(u64 config) 161struct tracepoint_path *tracepoint_id_to_path(u64 config)
162{ 162{
163 static char tracepoint_name[2 * MAX_EVENT_LENGTH]; 163 struct tracepoint_path *path = NULL;
164 DIR *sys_dir, *evt_dir; 164 DIR *sys_dir, *evt_dir;
165 struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; 165 struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent;
166 struct stat st; 166 struct stat st;
@@ -170,7 +170,7 @@ static const char *tracepoint_id_to_name(u64 config)
170 char evt_path[MAXPATHLEN]; 170 char evt_path[MAXPATHLEN];
171 171
172 if (valid_debugfs_mount(debugfs_path)) 172 if (valid_debugfs_mount(debugfs_path))
173 return "unkown"; 173 return NULL;
174 174
175 sys_dir = opendir(debugfs_path); 175 sys_dir = opendir(debugfs_path);
176 if (!sys_dir) 176 if (!sys_dir)
@@ -197,10 +197,23 @@ static const char *tracepoint_id_to_name(u64 config)
197 if (id == config) { 197 if (id == config) {
198 closedir(evt_dir); 198 closedir(evt_dir);
199 closedir(sys_dir); 199 closedir(sys_dir);
200 snprintf(tracepoint_name, 2 * MAX_EVENT_LENGTH, 200 path = calloc(1, sizeof(path));
201 "%s:%s", sys_dirent.d_name, 201 path->system = malloc(MAX_EVENT_LENGTH);
202 evt_dirent.d_name); 202 if (!path->system) {
203 return tracepoint_name; 203 free(path);
204 return NULL;
205 }
206 path->name = malloc(MAX_EVENT_LENGTH);
207 if (!path->name) {
208 free(path->system);
209 free(path);
210 return NULL;
211 }
212 strncpy(path->system, sys_dirent.d_name,
213 MAX_EVENT_LENGTH);
214 strncpy(path->name, evt_dirent.d_name,
215 MAX_EVENT_LENGTH);
216 return path;
204 } 217 }
205 } 218 }
206 closedir(evt_dir); 219 closedir(evt_dir);
@@ -208,7 +221,25 @@ static const char *tracepoint_id_to_name(u64 config)
208 221
209cleanup: 222cleanup:
210 closedir(sys_dir); 223 closedir(sys_dir);
211 return "unkown"; 224 return NULL;
225}
226
227#define TP_PATH_LEN (MAX_EVENT_LENGTH * 2 + 1)
228static const char *tracepoint_id_to_name(u64 config)
229{
230 static char buf[TP_PATH_LEN];
231 struct tracepoint_path *path;
232
233 path = tracepoint_id_to_path(config);
234 if (path) {
235 snprintf(buf, TP_PATH_LEN, "%s:%s", path->system, path->name);
236 free(path->name);
237 free(path->system);
238 free(path);
239 } else
240 snprintf(buf, TP_PATH_LEN, "%s:%s", "unknown", "unknown");
241
242 return buf;
212} 243}
213 244
214static int is_cache_op_valid(u8 cache_type, u8 cache_op) 245static int is_cache_op_valid(u8 cache_type, u8 cache_op)