perf sched map: Apply cpu color when there's an activity
Namhyung Kim
maintainerPATCH 1/3 perf sched map: Apply cpu color when there's an activity
Applying cpu color always doesn't help readability IMHO. Instead it might be better to applying the color when there's an activity on those CPUs.
--- tools/perf/builtin-sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-sched.c +1 -1
@@ -1479,7 +1479,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel, cpu_color =COLOR_CPUS ;if (cpu != this_cpu) -color_fprintf (stdout, cpu_color," " ); +color_fprintf (stdout, color," " );else color_fprintf (stdout, cpu_color,"*" );
Signature · 1 line
2.10.0
Namhyung Kim
maintainerPATCH 2/3 perf sched map: Always show task comm with -v
I'd like to see the name of tasks with perf sched map, but it only shows name of new tasks and then use short names after all. This is not good for long running tasks since it's hard for users to track the short names. This patch makes it show the names (except the idle task) when -v option is used. Probably we may make it as default behavior.
--- tools/perf/builtin-sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-sched.c +1 -1
@@ -1493,7 +1493,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel, goto out;color_fprintf (stdout, color," %12.6f secs " , (double )timestamp /NSEC_PER_SEC ); -if (new_shortname) { +if (new_shortname || (verbose && sched_in->tid)) {const char *pid_color = color;if (thread__has_color (sched_in))
Signature · 1 line
2.10.0
Re: [PATCH 2/3] perf sched map: Always show task comm with -v
Quoted 7 lines · Namhyung Kim
I'd like to see the name of tasks with perf sched map, but it only shows name of new tasks and then use short names after all. This is not good for long running tasks since it's hard for users to track the short names. This patch makes it show the names (except the idle task) when -v option is used. Probably we may make it as default behavior.
Signed-off-by Namhyung Kim <[email protected]>
thanks,
jirka
Quoted 20 lines
--- tools/perf/builtin-sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/builtin-sched.c +1
-1@@ -1493,7 +1493,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel, goto out;color_fprintf (stdout, color," %12.6f secs " , (double )timestamp /NSEC_PER_SEC ); -if (new_shortname) { +if (new_shortname || (verbose && sched_in->tid)) {const char *pid_color = color;if (thread__has_color (sched_in))Signature · 1 line
2.10.0
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf sched map: Always show task comm with -v
In reply to Namhyung Kimperf sched map: Always show task comm with -v
Commit-ID: e107f129e2e0e75ddf1cd7995a9f5ffff2307766 Gitweb: http://git.kernel.org/tip/e107f129e2e0e75ddf1cd7995a9f5ffff2307766 Author: Namhyung Kim <[email protected]> AuthorDate: Mon, 24 Oct 2016 11:02:44 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 25 Oct 2016 15:05:09 -0300
perf sched map: Always show task comm with -v
I'd like to see the name of tasks with perf sched map, but it only shows name of new tasks and then use short names after all. This is not good for long running tasks since it's hard for users to track the short names. This patch makes it show the names (except the idle task) when -v option is used. Probably we may make it as default behavior.
--- tools/perf/builtin-sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-sched.c +1 -1
@@ -1493,7 +1493,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel, goto out;color_fprintf (stdout, color," %12.6f secs " , (double )timestamp /NSEC_PER_SEC ); -if (new_shortname) { +if (new_shortname || (verbose && sched_in->tid)) {const char *pid_color = color;if (thread__has_color (sched_in))
Namhyung Kim
maintainerPATCH 3/3 perf tools: Introduce timestamp_in_usec()
In reply to Namhyung KimJoonwoo 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.
--- tools/perf/builtin-sched.c | 9 ++++++--- tools/perf/builtin-script.c | 9 ++++++--- tools/perf/util/util.c | 9 +++++++++ tools/perf/util/util.h | 3 +++ 4 files changed, 24 insertions(+), 6 deletions(-)
tools/perf/builtin-sched.c +6 -3
@@ -1191,6 +1191,7 @@ static void output_lat_thread(struct perf_sched *sched, struct work_atoms *work_int i;int ret;u64 avg; +char buf[32 ];if (!work_list->nb_atoms)return ;
@@ -1213,11 +1214,11 @@ static void output_lat_thread(struct perf_sched *sched, struct work_atoms *work_ avg = work_list->total_lat / work_list->nb_atoms; -printf ("|%11.3f ms |%9" PRIu64" | avg:%9.3f ms | max:%9.3f ms | max at: %13.6f s\n" , +printf ("|%11.3f ms |%9" PRIu64" | avg:%9.3f ms | max:%9.3f ms | max at: %13s s\n" , (double )work_list->total_runtime /NSEC_PER_MSEC , work_list->nb_atoms, (double )avg /NSEC_PER_MSEC , (double )work_list->max_lat /NSEC_PER_MSEC , - (double )work_list->max_lat_at /NSEC_PER_SEC ); +timestamp_in_usec (buf,sizeof (buf), work_list->max_lat)); }static int pid_cmp (struct work_atoms *l,struct work_atoms *r)
@@ -1402,6 +1403,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,int cpus_nr;bool new_cpu = false;const char *color =PERF_COLOR_NORMAL ; +char buf[32 ];BUG_ON (this_cpu >=MAX_CPUS || this_cpu <0 );
@@ -1492,7 +1494,8 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,if (sched->map.cpus && !cpu_map__has (sched->map.cpus, this_cpu)) goto out; -color_fprintf (stdout, color," %12.6f secs " , (double )timestamp /NSEC_PER_SEC ); +color_fprintf (stdout, color," %12s secs " , +timestamp_in_usec (buf,sizeof (buf), timestamp));if (new_shortname || (verbose && sched_in->tid)) {const char *pid_color = color;
tools/perf/builtin-script.c +6 -3
@@ -437,7 +437,6 @@ static void print_sample_start(struct perf_sample *sample, {struct perf_event_attr *attr = &evsel->attr;unsigned long secs; -unsigned long usecs;unsigned long long nsecs;if (PRINT_FIELD (COMM )) {
@@ -464,14 +463,18 @@ static void print_sample_start(struct perf_sample *sample, }if (PRINT_FIELD (TIME )) { +char buf[32 ]; +size_t sz =sizeof (buf); + nsecs = sample->time; secs = nsecs /NSEC_PER_SEC ; nsecs -= secs *NSEC_PER_SEC ; - usecs = nsecs /NSEC_PER_USEC ; +if (nanosecs)printf ("%5lu.%09llu: " , secs, nsecs);else -printf ("%5lu.%06lu: " , secs, usecs); +printf ("%12s: " ,timestamp_in_usec (buf, sz, + sample->time)); } }
tools/perf/util/util.c +9 -0
@@ -433,6 +433,15 @@ int parse_nsec_time(const char *str, u64 *ptime)return 0 ; } +char *timestamp_in_usec (char *buf,size_t sz,u64 timestamp) +{ +u64 sec = timestamp /NSEC_PER_SEC ; +u64 usec = (timestamp %NSEC_PER_SEC ) /NSEC_PER_USEC ; + +scnprintf (buf, sz,"%" PRIu64".%06" PRIu64, sec, usec); +return buf; +} +unsigned long parse_tag_value (const char *str,struct parse_tag *tags) {struct parse_tag *i = tags;
tools/perf/util/util.h +3 -0
@@ -362,4 +362,7 @@ extern int sched_getcpu(void);#endif int is_printable_array (char *p,unsigned int len); + +char *timestamp_in_usec (char *buf,size_t sz,u64 timestamp); +#endif /* GIT_COMPAT_UTIL_H */
Signature · 1 line
2.10.0
Re: [PATCH 3/3] perf tools: Introduce timestamp_in_usec()
On Mon, Oct 24, 2016 at 11:02:45AM +0900, Namhyung Kim wrote:
SNIP
Quoted 15 lines
tools/perf/builtin-script.c +3
-1+if (nanosecs)printf ("%5lu.%09llu: " , secs, nsecs);else -printf ("%5lu.%06lu: " , secs, usecs); +printf ("%12s: " ,timestamp_in_usec (buf, sz, + sample->time)); } }tools/perf/util/util.c +0
-0
tools/perf/util/util.c int parse_nsec_time(const char *str, u64 *ptime) · line 437
Quoted 5 lines
tools/perf/util/util.c +2
-0@@ -433,6 +433,15 @@ int parse_nsec_time(const char *str, u64 *ptime)return 0 ; } +char *timestamp_in_usec (char *buf,size_t sz,u64 timestamp) +{
good idea.. 2 things:
- I've spot several other places by looking for NSEC_PER_USEC but haven't checked deeply they could be also users for this function
- timestamp_usec__scnprint might fir better
thanks,
jirka
Re: [PATCH 3/3] perf tools: Introduce timestamp_in_usec()
In reply to Namhyung KimQuoted 6 lines · Namhyung Kim
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.
Reported-by Joonwoo Park <[email protected]>
Sorry I was busy with something else so didn't have chance to follow up on my initial proposal and thanks for take caring of this.
Quoted 21 lines
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/builtin-sched.c | 9 ++++++--- tools/perf/builtin-script.c | 9 ++++++--- tools/perf/util/util.c | 9 +++++++++ tools/perf/util/util.h | 3 +++ 4 files changed, 24 insertions(+), 6 deletions(-)tools/perf/builtin-sched.c +1
-0@@ -1191,6 +1191,7 @@ static void output_lat_thread(struct perf_sched *sched, struct work_atoms *work_int i;int ret;u64 avg; +char buf[32 ];if (!work_list->nb_atoms)return ;
tools/perf/builtin-sched.c static void output_lat_thread(struct perf_sched *sched, struct work_atoms *work_ · line 1221
Quoted 10 lines
tools/perf/builtin-sched.c +2
-2@@ -1213,11 +1214,11 @@ static void output_lat_thread(struct perf_sched *sched, struct work_atoms *work_ avg = work_list->total_lat / work_list->nb_atoms; -printf ("|%11.3f ms |%9" PRIu64" | avg:%9.3f ms | max:%9.3f ms | max at: %13.6f s\n" , +printf ("|%11.3f ms |%9" PRIu64" | avg:%9.3f ms | max:%9.3f ms | max at: %13s s\n" , (double )work_list->total_runtime /NSEC_PER_MSEC , work_list->nb_atoms, (double )avg /NSEC_PER_MSEC , (double )work_list->max_lat /NSEC_PER_MSEC , - (double )work_list->max_lat_at /NSEC_PER_SEC ); +timestamp_in_usec (buf,sizeof (buf), work_list->max_lat));
This should be :
s/work_list->max_lat/work_list->max_lat_at/
Quoted 59 lines
tools/perf/builtin-sched.c +3
-1}static int pid_cmp (struct work_atoms *l,struct work_atoms *r)@@ -1402,6 +1403,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,int cpus_nr;bool new_cpu = false;const char *color =PERF_COLOR_NORMAL ; +char buf[32 ];BUG_ON (this_cpu >=MAX_CPUS || this_cpu <0 );@@ -1492,7 +1494,8 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,if (sched->map.cpus && !cpu_map__has (sched->map.cpus, this_cpu)) goto out; -color_fprintf (stdout, color," %12.6f secs " , (double )timestamp /NSEC_PER_SEC ); +color_fprintf (stdout, color," %12s secs " , +timestamp_in_usec (buf,sizeof (buf), timestamp));if (new_shortname || (verbose && sched_in->tid)) {const char *pid_color = color;tools/perf/builtin-script.c +6
-3@@ -437,7 +437,6 @@ static void print_sample_start(struct perf_sample *sample, {struct perf_event_attr *attr = &evsel->attr;unsigned long secs; -unsigned long usecs;unsigned long long nsecs;if (PRINT_FIELD (COMM )) {@@ -464,14 +463,18 @@ static void print_sample_start(struct perf_sample *sample, }if (PRINT_FIELD (TIME )) { +char buf[32 ]; +size_t sz =sizeof (buf); + nsecs = sample->time; secs = nsecs /NSEC_PER_SEC ; nsecs -= secs *NSEC_PER_SEC ; - usecs = nsecs /NSEC_PER_USEC ; +if (nanosecs)printf ("%5lu.%09llu: " , secs, nsecs);else -printf ("%5lu.%06lu: " , secs, usecs); +printf ("%12s: " ,timestamp_in_usec (buf, sz, + sample->time)); } }tools/perf/util/util.c +0
-0
tools/perf/util/util.c int parse_nsec_time(const char *str, u64 *ptime) · line 436
Quoted 4 lines
tools/perf/util/util.c +1
-0@@ -433,6 +433,15 @@ int parse_nsec_time(const char *str, u64 *ptime)return 0 ; } +char *timestamp_in_usec (char *buf,size_t sz,u64 timestamp)
I agree with Jirka. timestamp_usec__scnprintf looks better.
Thanks,
Joonwoo
Quoted 24 lines
tools/perf/util/util.c +8
-0+{ +u64 sec = timestamp /NSEC_PER_SEC ; +u64 usec = (timestamp %NSEC_PER_SEC ) /NSEC_PER_USEC ; + +scnprintf (buf, sz,"%" PRIu64".%06" PRIu64, sec, usec); +return buf; +} +unsigned long parse_tag_value (const char *str,struct parse_tag *tags) {struct parse_tag *i = tags;tools/perf/util/util.h +3
-0@@ -362,4 +362,7 @@ extern int sched_getcpu(void);#endif int is_printable_array (char *p,unsigned int len); + +char *timestamp_in_usec (char *buf,size_t sz,u64 timestamp); +#endif /* GIT_COMPAT_UTIL_H */
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf tools: Introduce timestamp__scnprintf_usec()
In reply to Namhyung Kimperf tools: Introduce timestamp__scnprintf_usec()
Commit-ID: 99620a5d0cc8e2dd9aedb629a6e81825f0db020e Gitweb: http://git.kernel.org/tip/99620a5d0cc8e2dd9aedb629a6e81825f0db020e Author: Namhyung Kim <[email protected]> AuthorDate: Mon, 24 Oct 2016 11:02:45 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 28 Oct 2016 11:29:40 -0200
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)
--- tools/perf/builtin-sched.c | 10 +++++++--- tools/perf/builtin-script.c | 10 ++++++---- tools/perf/util/util.c | 8 ++++++++ tools/perf/util/util.h | 3 +++ 4 files changed, 24 insertions(+), 7 deletions(-)
tools/perf/builtin-sched.c +7 -3
@@ -1191,6 +1191,7 @@ static void output_lat_thread(struct perf_sched *sched, struct work_atoms *work_int i;int ret;u64 avg; +char max_lat_at[32 ];if (!work_list->nb_atoms)return ;
@@ -1212,12 +1213,13 @@ static void output_lat_thread(struct perf_sched *sched, struct work_atoms *work_printf (" " ); avg = work_list->total_lat / work_list->nb_atoms; +timestamp__scnprintf_usec (work_list->max_lat_at, max_lat_at,sizeof (max_lat_at)); -printf ("|%11.3f ms |%9" PRIu64" | avg:%9.3f ms | max:%9.3f ms | max at: %13.6f s\n" , +printf ("|%11.3f ms |%9" PRIu64" | avg:%9.3f ms | max:%9.3f ms | max at: %13s s\n" , (double )work_list->total_runtime /NSEC_PER_MSEC , work_list->nb_atoms, (double )avg /NSEC_PER_MSEC , (double )work_list->max_lat /NSEC_PER_MSEC , - (double )work_list->max_lat_at /NSEC_PER_SEC ); + max_lat_at); }static int pid_cmp (struct work_atoms *l,struct work_atoms *r)
@@ -1402,6 +1404,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,int cpus_nr;bool new_cpu = false;const char *color =PERF_COLOR_NORMAL ; +char stimestamp[32 ];BUG_ON (this_cpu >=MAX_CPUS || this_cpu <0 );
@@ -1492,7 +1495,8 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,if (sched->map.cpus && !cpu_map__has (sched->map.cpus, this_cpu)) goto out; -color_fprintf (stdout, color," %12.6f secs " , (double )timestamp /NSEC_PER_SEC ); +timestamp__scnprintf_usec (timestamp, stimestamp,sizeof (stimestamp)); +color_fprintf (stdout, color," %12s secs " , stimestamp);if (new_shortname || (verbose && sched_in->tid)) {const char *pid_color = color;
tools/perf/builtin-script.c +6 -4
@@ -441,7 +441,6 @@ static void print_sample_start(struct perf_sample *sample, {struct perf_event_attr *attr = &evsel->attr;unsigned long secs; -unsigned long usecs;unsigned long long nsecs;if (PRINT_FIELD (COMM )) {
@@ -471,11 +470,14 @@ static void print_sample_start(struct perf_sample *sample, nsecs = sample->time; secs = nsecs /NSEC_PER_SEC ; nsecs -= secs *NSEC_PER_SEC ; - usecs = nsecs /NSEC_PER_USEC ; +if (nanosecs)printf ("%5lu.%09llu: " , secs, nsecs); -else -printf ("%5lu.%06lu: " , secs, usecs); +else { +char sample_time[32 ]; +timestamp__scnprintf_usec (sample->time, sample_time,sizeof (sample_time)); +printf ("%12s: " , sample_time); + } } }
tools/perf/util/util.c +8 -0
@@ -433,6 +433,14 @@ int parse_nsec_time(const char *str, u64 *ptime)return 0 ; } +int timestamp__scnprintf_usec (u64 timestamp,char *buf,size_t sz) +{ +u64 sec = timestamp /NSEC_PER_SEC ; +u64 usec = (timestamp %NSEC_PER_SEC ) /NSEC_PER_USEC ; + +return scnprintf (buf, sz,"%" PRIu64".%06" PRIu64, sec, usec); +} +unsigned long parse_tag_value (const char *str,struct parse_tag *tags) {struct parse_tag *i = tags;
tools/perf/util/util.h +3 -0
@@ -362,4 +362,7 @@ extern int sched_getcpu(void);#endif int is_printable_array (char *p,unsigned int len); + +int timestamp__scnprintf_usec (u64 timestamp,char *buf,size_t sz); +#endif /* GIT_COMPAT_UTIL_H */
Quoted 3 lines · Namhyung Kim
Applying cpu color always doesn't help readability IMHO. Instead it might be better to applying the color when there's an activity on those CPUs.
ok, I added it to easily spot cpu columns I was interested in, but I think I can live with dotted line ;-)
thanks,
jirka
Quoted 23 lines
Cc Jiri Olsa <[email protected]>Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/builtin-sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/builtin-sched.c +1
-1@@ -1479,7 +1479,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel, cpu_color =COLOR_CPUS ;if (cpu != this_cpu) -color_fprintf (stdout, cpu_color," " ); +color_fprintf (stdout, color," " );else color_fprintf (stdout, cpu_color,"*" );Signature · 1 line
2.10.0
Em Mon, Oct 24, 2016 at 11:02:43AM +0900, Namhyung Kim escreveu:
Quoted 3 lines
Applying cpu color always doesn't help readability IMHO. Instead it might be better to applying the color when there's an activity on those CPUs.
thanks, applied the three patches.
- Arnaldo
Quoted 21 lines
Cc Jiri Olsa <[email protected]>Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/builtin-sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/builtin-sched.c +1
-1@@ -1479,7 +1479,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel, cpu_color =COLOR_CPUS ;if (cpu != this_cpu) -color_fprintf (stdout, cpu_color," " ); +color_fprintf (stdout, color," " );else color_fprintf (stdout, cpu_color,"*" );Signature · 1 line
2.10.0
Namhyung Kim
maintainerHi Arnaldo,
Quoted 6 lines · Arnaldo Carvalho de Melo
Em Mon, Oct 24, 2016 at 11:02:43AM +0900, Namhyung Kim escreveu:
Quoted 3 lines
Applying cpu color always doesn't help readability IMHO. Instead it might be better to applying the color when there's an activity on those CPUs.
thanks, applied the three patches.
Thanks, but unfortunately the patch 3/3 has a bug. Could you please fold the fix below into the patch?
Thanks,
Namhyung
tools/perf/builtin-sched.c +1 -1
@@ -1218,7 +1218,7 @@ static void output_lat_thread(struct perf_sched *sched, struct work_atoms *work_ (double )work_list->total_runtime /NSEC_PER_MSEC , work_list->nb_atoms, (double )avg /NSEC_PER_MSEC , (double )work_list->max_lat /NSEC_PER_MSEC , - timestamp_in_usec(buf, sizeof(buf), work_list->max_lat)); + timestamp_in_usec(buf, sizeof(buf), work_list->max_lat_at)); }static int pid_cmp (struct work_atoms *l,struct work_atoms *r)
tip-bot for Namhyung Kim
merge botperf sched map: Apply cpu color when there's an activity
Commit-ID: 1208bb274ba547012579d5b68c693e0b36682b74 Gitweb: http://git.kernel.org/tip/1208bb274ba547012579d5b68c693e0b36682b74 Author: Namhyung Kim <[email protected]> AuthorDate: Mon, 24 Oct 2016 11:02:43 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 25 Oct 2016 15:04:48 -0300
perf sched map: Apply cpu color when there's an activity
Applying cpu color always doesn't help readability IMHO. Instead it might be better to applying the color when there's an activity on those CPUs.
--- tools/perf/builtin-sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-sched.c +1 -1
@@ -1479,7 +1479,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel, cpu_color =COLOR_CPUS ;if (cpu != this_cpu) -color_fprintf (stdout, cpu_color," " ); +color_fprintf (stdout, color," " );else color_fprintf (stdout, cpu_color,"*" );