diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2010-02-01 21:25:05 -0500 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2010-02-01 22:32:44 -0500 |
| commit | 24a173b9abeb79e1dc8c84dd9bcfd965dfca6eca (patch) | |
| tree | 39a0c9615d907377b4de6a447292e85f03590242 | |
| parent | 6843871167d7472c5cb705db9c7650143da9866e (diff) | |
trace-cmd: Do not enable tracing until exec
Wait till the last moment to enable tracing. Otherwise we trace
the trace-cmd utility setting up the program and waste a lot of
the data file.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
| -rw-r--r-- | trace-cmd.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/trace-cmd.c b/trace-cmd.c index 75bc325..182c8d6 100644 --- a/trace-cmd.c +++ b/trace-cmd.c | |||
| @@ -249,6 +249,21 @@ static void clear_trace(void) | |||
| 249 | fclose(fp); | 249 | fclose(fp); |
| 250 | } | 250 | } |
| 251 | 251 | ||
| 252 | static void reset_max_latency(void) | ||
| 253 | { | ||
| 254 | FILE *fp; | ||
| 255 | char *path; | ||
| 256 | |||
| 257 | /* reset the trace */ | ||
| 258 | path = get_tracing_file("tracing_max_latency"); | ||
| 259 | fp = fopen(path, "w"); | ||
| 260 | if (!fp) | ||
| 261 | die("writing to '%s'", path); | ||
| 262 | put_tracing_file(path); | ||
| 263 | fwrite("0", 1, 1, fp); | ||
| 264 | fclose(fp); | ||
| 265 | } | ||
| 266 | |||
| 252 | static void update_ftrace_pid(const char *pid) | 267 | static void update_ftrace_pid(const char *pid) |
| 253 | { | 268 | { |
| 254 | char *path; | 269 | char *path; |
| @@ -269,6 +284,7 @@ static void update_ftrace_pid(const char *pid) | |||
| 269 | } | 284 | } |
| 270 | 285 | ||
| 271 | static void update_pid_event_filters(char *pid); | 286 | static void update_pid_event_filters(char *pid); |
| 287 | static void enable_tracing(void); | ||
| 272 | 288 | ||
| 273 | static void update_task_filter(void) | 289 | static void update_task_filter(void) |
| 274 | { | 290 | { |
| @@ -277,6 +293,7 @@ static void update_task_filter(void) | |||
| 277 | 293 | ||
| 278 | if (!filter_task) { | 294 | if (!filter_task) { |
| 279 | update_ftrace_pid(""); | 295 | update_ftrace_pid(""); |
| 296 | enable_tracing(); | ||
| 280 | return; | 297 | return; |
| 281 | } | 298 | } |
| 282 | 299 | ||
| @@ -286,8 +303,7 @@ static void update_task_filter(void) | |||
| 286 | 303 | ||
| 287 | update_pid_event_filters(spid); | 304 | update_pid_event_filters(spid); |
| 288 | 305 | ||
| 289 | /* clear the trace */ | 306 | enable_tracing(); |
| 290 | |||
| 291 | } | 307 | } |
| 292 | 308 | ||
| 293 | void run_cmd(int argc, char **argv) | 309 | void run_cmd(int argc, char **argv) |
| @@ -717,6 +733,9 @@ static void write_tracing_on(int on) | |||
| 717 | static void enable_tracing(void) | 733 | static void enable_tracing(void) |
| 718 | { | 734 | { |
| 719 | write_tracing_on(1); | 735 | write_tracing_on(1); |
| 736 | |||
| 737 | if (latency) | ||
| 738 | reset_max_latency(); | ||
| 720 | } | 739 | } |
| 721 | 740 | ||
| 722 | static void disable_tracing(void) | 741 | static void disable_tracing(void) |
| @@ -734,21 +753,6 @@ static void disable_all(void) | |||
| 734 | clear_trace(); | 753 | clear_trace(); |
| 735 | } | 754 | } |
| 736 | 755 | ||
| 737 | static void reset_max_latency(void) | ||
| 738 | { | ||
| 739 | FILE *fp; | ||
| 740 | char *path; | ||
| 741 | |||
| 742 | /* reset the trace */ | ||
| 743 | path = get_tracing_file("tracing_max_latency"); | ||
| 744 | fp = fopen(path, "w"); | ||
| 745 | if (!fp) | ||
| 746 | die("writing to '%s'", path); | ||
| 747 | put_tracing_file(path); | ||
| 748 | fwrite("0", 1, 1, fp); | ||
| 749 | fclose(fp); | ||
| 750 | } | ||
| 751 | |||
| 752 | static void update_pid_event_filters(char *pid) | 756 | static void update_pid_event_filters(char *pid) |
| 753 | { | 757 | { |
| 754 | struct event_list *event; | 758 | struct event_list *event; |
| @@ -1246,10 +1250,6 @@ int main (int argc, char **argv) | |||
| 1246 | sleep(1); | 1250 | sleep(1); |
| 1247 | } | 1251 | } |
| 1248 | } else { | 1252 | } else { |
| 1249 | enable_tracing(); | ||
| 1250 | if (latency) | ||
| 1251 | reset_max_latency(); | ||
| 1252 | |||
| 1253 | if (!record) | 1253 | if (!record) |
| 1254 | exit(0); | 1254 | exit(0); |
| 1255 | 1255 | ||
