aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-script.c
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2016-10-23 22:02:45 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-10-28 09:29:40 -0400
commit99620a5d0cc8e2dd9aedb629a6e81825f0db020e (patch)
tree4aaa056d98c2114a3af9c7b206c2b28268564d80 /tools/perf/builtin-script.c
parente107f129e2e0e75ddf1cd7995a9f5ffff2307766 (diff)
perf tools: Introduce timestamp__scnprintf_usec()
Joonwoo reported that there's a mismatch between timestamps in script and sched commands. This was because of difference in printing the timestamp. Factor out the code and share it so that they can be in sync. Also I found that sched map has similar problem, fix it too. Committer notes: Fixed the max_lat_at bug introduced by Namhyung's original patch, as pointed out by Joonwoo, and made it a function following the scnprintf() model, i.e. returning the number of bytes formatted, and receiving as the first parameter the object from where the data to the formatting is obtained, renaming it from: char *timestamp_in_usec(char *bf, size_t size, u64 timestamp) to int timestamp__scnprintf_usec(u64 timestamp, char *bf, size_t size) Reported-by: Joonwoo Park <joonwoop@codeaurora.org> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/20161024020246.14928-3-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r--tools/perf/builtin-script.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 412fb6e65ac0..e1daff36d070 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -441,7 +441,6 @@ static void print_sample_start(struct perf_sample *sample,
441{ 441{
442 struct perf_event_attr *attr = &evsel->attr; 442 struct perf_event_attr *attr = &evsel->attr;
443 unsigned long secs; 443 unsigned long secs;
444 unsigned long usecs;
445 unsigned long long nsecs; 444 unsigned long long nsecs;
446 445
447 if (PRINT_FIELD(COMM)) { 446 if (PRINT_FIELD(COMM)) {
@@ -471,11 +470,14 @@ static void print_sample_start(struct perf_sample *sample,
471 nsecs = sample->time; 470 nsecs = sample->time;
472 secs = nsecs / NSEC_PER_SEC; 471 secs = nsecs / NSEC_PER_SEC;
473 nsecs -= secs * NSEC_PER_SEC; 472 nsecs -= secs * NSEC_PER_SEC;
474 usecs = nsecs / NSEC_PER_USEC; 473
475 if (nanosecs) 474 if (nanosecs)
476 printf("%5lu.%09llu: ", secs, nsecs); 475 printf("%5lu.%09llu: ", secs, nsecs);
477 else 476 else {
478 printf("%5lu.%06lu: ", secs, usecs); 477 char sample_time[32];
478 timestamp__scnprintf_usec(sample->time, sample_time, sizeof(sample_time));
479 printf("%12s: ", sample_time);
480 }
479 } 481 }
480} 482}
481 483