All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] perf sched map: Apply cpu color when there's an activity
@ 2016-10-24  2:02 Namhyung Kim
  2016-10-24  2:02 ` [PATCH 2/3] perf sched map: Always show task comm with -v Namhyung Kim
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Namhyung Kim @ 2016-10-24  2:02 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern

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.

Cc: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/builtin-sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index f5503ca22e1c..78006e991d91 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -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, "*");
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/3] perf sched map: Always show task comm with -v
  2016-10-24  2:02 [PATCH 1/3] perf sched map: Apply cpu color when there's an activity Namhyung Kim
@ 2016-10-24  2:02 ` Namhyung Kim
  2016-10-24 16:46   ` Jiri Olsa
  2016-10-28 17:46   ` [tip:perf/core] " tip-bot for Namhyung Kim
  2016-10-24  2:02 ` [PATCH 3/3] perf tools: Introduce timestamp_in_usec() Namhyung Kim
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 12+ messages in thread
From: Namhyung Kim @ 2016-10-24  2:02 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern

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 <namhyung@kernel.org>
---
 tools/perf/builtin-sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 78006e991d91..97d6cbf486bb 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -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))
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/3] perf tools: Introduce timestamp_in_usec()
  2016-10-24  2:02 [PATCH 1/3] perf sched map: Apply cpu color when there's an activity Namhyung Kim
  2016-10-24  2:02 ` [PATCH 2/3] perf sched map: Always show task comm with -v Namhyung Kim
@ 2016-10-24  2:02 ` Namhyung Kim
  2016-10-24 16:46   ` Jiri Olsa
                     ` (2 more replies)
  2016-10-24 16:46 ` [PATCH 1/3] perf sched map: Apply cpu color when there's an activity Jiri Olsa
                   ` (2 subsequent siblings)
  4 siblings, 3 replies; 12+ messages in thread
From: Namhyung Kim @ 2016-10-24  2:02 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern, Joonwoo Park

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 <joonwoop@codeaurora.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 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(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 97d6cbf486bb..c88d64ae997e 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -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;
 
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 7228d141a789..c848c74bdc90 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -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));
 	}
 }
 
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 85c56800f17a..aa3e778989ce 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -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;
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 71b6992f1d98..ece974f1c538 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -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 */
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/3] perf tools: Introduce timestamp_in_usec()
  2016-10-24  2:02 ` [PATCH 3/3] perf tools: Introduce timestamp_in_usec() Namhyung Kim
@ 2016-10-24 16:46   ` Jiri Olsa
  2016-10-24 20:56   ` Joonwoo Park
  2016-10-28 17:46   ` [tip:perf/core] perf tools: Introduce timestamp__scnprintf_usec() tip-bot for Namhyung Kim
  2 siblings, 0 replies; 12+ messages in thread
From: Jiri Olsa @ 2016-10-24 16:46 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra, Jiri Olsa,
	LKML, David Ahern, Joonwoo Park

On Mon, Oct 24, 2016 at 11:02:45AM +0900, Namhyung Kim wrote:

SNIP

> +
>  		if (nanosecs)
>  			printf("%5lu.%09llu: ", secs, nsecs);
>  		else
> -			printf("%5lu.%06lu: ", secs, usecs);
> +			printf("%12s: ", timestamp_in_usec(buf, sz,
> +							   sample->time));
>  	}
>  }
>  
> diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
> index 85c56800f17a..aa3e778989ce 100644
> --- a/tools/perf/util/util.c
> +++ b/tools/perf/util/util.c
> @@ -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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/3] perf sched map: Always show task comm with -v
  2016-10-24  2:02 ` [PATCH 2/3] perf sched map: Always show task comm with -v Namhyung Kim
@ 2016-10-24 16:46   ` Jiri Olsa
  2016-10-28 17:46   ` [tip:perf/core] " tip-bot for Namhyung Kim
  1 sibling, 0 replies; 12+ messages in thread
From: Jiri Olsa @ 2016-10-24 16:46 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra, Jiri Olsa,
	LKML, David Ahern

On Mon, Oct 24, 2016 at 11:02:44AM +0900, Namhyung Kim wrote:
> 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 <namhyung@kernel.org>

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

> ---
>  tools/perf/builtin-sched.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> index 78006e991d91..97d6cbf486bb 100644
> --- a/tools/perf/builtin-sched.c
> +++ b/tools/perf/builtin-sched.c
> @@ -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))
> -- 
> 2.10.0
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/3] perf sched map: Apply cpu color when there's an activity
  2016-10-24  2:02 [PATCH 1/3] perf sched map: Apply cpu color when there's an activity Namhyung Kim
  2016-10-24  2:02 ` [PATCH 2/3] perf sched map: Always show task comm with -v Namhyung Kim
  2016-10-24  2:02 ` [PATCH 3/3] perf tools: Introduce timestamp_in_usec() Namhyung Kim
@ 2016-10-24 16:46 ` Jiri Olsa
  2016-10-25 18:07 ` Arnaldo Carvalho de Melo
  2016-10-28 17:45 ` [tip:perf/core] " tip-bot for Namhyung Kim
  4 siblings, 0 replies; 12+ messages in thread
From: Jiri Olsa @ 2016-10-24 16:46 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra, Jiri Olsa,
	LKML, David Ahern

On Mon, Oct 24, 2016 at 11:02:43AM +0900, Namhyung Kim wrote:
> 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 ;-)

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

> 
> Cc: Jiri Olsa <jolsa@kernel.org>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/builtin-sched.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> index f5503ca22e1c..78006e991d91 100644
> --- a/tools/perf/builtin-sched.c
> +++ b/tools/perf/builtin-sched.c
> @@ -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, "*");
>  
> -- 
> 2.10.0
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/3] perf tools: Introduce timestamp_in_usec()
  2016-10-24  2:02 ` [PATCH 3/3] perf tools: Introduce timestamp_in_usec() Namhyung Kim
  2016-10-24 16:46   ` Jiri Olsa
@ 2016-10-24 20:56   ` Joonwoo Park
  2016-10-28 17:46   ` [tip:perf/core] perf tools: Introduce timestamp__scnprintf_usec() tip-bot for Namhyung Kim
  2 siblings, 0 replies; 12+ messages in thread
From: Joonwoo Park @ 2016-10-24 20:56 UTC (permalink / raw)
  To: Namhyung Kim, Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern



On 10/23/2016 07:02 PM, Namhyung Kim wrote:
> 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 <joonwoop@codeaurora.org>

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.

> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  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(-)
>
> diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> index 97d6cbf486bb..c88d64ae997e 100644
> --- a/tools/perf/builtin-sched.c
> +++ b/tools/perf/builtin-sched.c
> @@ -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));

This should be :
s/work_list->max_lat/work_list->max_lat_at/

>  }
>
>  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;
>
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index 7228d141a789..c848c74bdc90 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -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));
>  	}
>  }
>
> diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
> index 85c56800f17a..aa3e778989ce 100644
> --- a/tools/perf/util/util.c
> +++ b/tools/perf/util/util.c
> @@ -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

> +{
> +	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;
> diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
> index 71b6992f1d98..ece974f1c538 100644
> --- a/tools/perf/util/util.h
> +++ b/tools/perf/util/util.h
> @@ -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 */
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/3] perf sched map: Apply cpu color when there's an activity
  2016-10-24  2:02 [PATCH 1/3] perf sched map: Apply cpu color when there's an activity Namhyung Kim
                   ` (2 preceding siblings ...)
  2016-10-24 16:46 ` [PATCH 1/3] perf sched map: Apply cpu color when there's an activity Jiri Olsa
@ 2016-10-25 18:07 ` Arnaldo Carvalho de Melo
  2016-10-25 21:24   ` Namhyung Kim
  2016-10-28 17:45 ` [tip:perf/core] " tip-bot for Namhyung Kim
  4 siblings, 1 reply; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-10-25 18:07 UTC (permalink / raw)
  To: Namhyung Kim; +Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern

Em Mon, Oct 24, 2016 at 11:02:43AM +0900, Namhyung Kim escreveu:
> 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
 
> Cc: Jiri Olsa <jolsa@kernel.org>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/builtin-sched.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> index f5503ca22e1c..78006e991d91 100644
> --- a/tools/perf/builtin-sched.c
> +++ b/tools/perf/builtin-sched.c
> @@ -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, "*");
>  
> -- 
> 2.10.0

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/3] perf sched map: Apply cpu color when there's an activity
  2016-10-25 18:07 ` Arnaldo Carvalho de Melo
@ 2016-10-25 21:24   ` Namhyung Kim
  0 siblings, 0 replies; 12+ messages in thread
From: Namhyung Kim @ 2016-10-25 21:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern

Hi Arnaldo,

On Tue, Oct 25, 2016 at 03:07:46PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, Oct 24, 2016 at 11:02:43AM +0900, Namhyung Kim escreveu:
> > 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


diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index f0ab715b4923..a8e58d495a66 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -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)

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [tip:perf/core] perf sched map: Apply cpu color when there's an activity
  2016-10-24  2:02 [PATCH 1/3] perf sched map: Apply cpu color when there's an activity Namhyung Kim
                   ` (3 preceding siblings ...)
  2016-10-25 18:07 ` Arnaldo Carvalho de Melo
@ 2016-10-28 17:45 ` tip-bot for Namhyung Kim
  4 siblings, 0 replies; 12+ messages in thread
From: tip-bot for Namhyung Kim @ 2016-10-28 17:45 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, tglx, a.p.zijlstra, dsahern, mingo, namhyung, jolsa,
	linux-kernel, acme

Commit-ID:  1208bb274ba547012579d5b68c693e0b36682b74
Gitweb:     http://git.kernel.org/tip/1208bb274ba547012579d5b68c693e0b36682b74
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Mon, 24 Oct 2016 11:02:43 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20161024020246.14928-1-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 8ca1b540..a8ad859 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -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, "*");
 

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [tip:perf/core] perf sched map: Always show task comm with -v
  2016-10-24  2:02 ` [PATCH 2/3] perf sched map: Always show task comm with -v Namhyung Kim
  2016-10-24 16:46   ` Jiri Olsa
@ 2016-10-28 17:46   ` tip-bot for Namhyung Kim
  1 sibling, 0 replies; 12+ messages in thread
From: tip-bot for Namhyung Kim @ 2016-10-28 17:46 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, jolsa, acme, mingo, tglx, namhyung, a.p.zijlstra,
	dsahern, hpa

Commit-ID:  e107f129e2e0e75ddf1cd7995a9f5ffff2307766
Gitweb:     http://git.kernel.org/tip/e107f129e2e0e75ddf1cd7995a9f5ffff2307766
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Mon, 24 Oct 2016 11:02:44 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20161024020246.14928-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index a8ad859..1f33d15 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -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))

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [tip:perf/core] perf tools: Introduce timestamp__scnprintf_usec()
  2016-10-24  2:02 ` [PATCH 3/3] perf tools: Introduce timestamp_in_usec() Namhyung Kim
  2016-10-24 16:46   ` Jiri Olsa
  2016-10-24 20:56   ` Joonwoo Park
@ 2016-10-28 17:46   ` tip-bot for Namhyung Kim
  2 siblings, 0 replies; 12+ messages in thread
From: tip-bot for Namhyung Kim @ 2016-10-28 17:46 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, namhyung, a.p.zijlstra, hpa, mingo, linux-kernel, tglx,
	jolsa, joonwoop, dsahern

Commit-ID:  99620a5d0cc8e2dd9aedb629a6e81825f0db020e
Gitweb:     http://git.kernel.org/tip/99620a5d0cc8e2dd9aedb629a6e81825f0db020e
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Mon, 24 Oct 2016 11:02:45 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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)

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>
---
 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(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 1f33d15..fb34412 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -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;
 
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 412fb6e..e1daff3 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,
 {
 	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);
+		}
 	}
 }
 
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 85c5680..5bbd1f6 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -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;
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 71b6992..79662d6 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -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 */

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-10-28 17:46 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-24  2:02 [PATCH 1/3] perf sched map: Apply cpu color when there's an activity Namhyung Kim
2016-10-24  2:02 ` [PATCH 2/3] perf sched map: Always show task comm with -v Namhyung Kim
2016-10-24 16:46   ` Jiri Olsa
2016-10-28 17:46   ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-10-24  2:02 ` [PATCH 3/3] perf tools: Introduce timestamp_in_usec() Namhyung Kim
2016-10-24 16:46   ` Jiri Olsa
2016-10-24 20:56   ` Joonwoo Park
2016-10-28 17:46   ` [tip:perf/core] perf tools: Introduce timestamp__scnprintf_usec() tip-bot for Namhyung Kim
2016-10-24 16:46 ` [PATCH 1/3] perf sched map: Apply cpu color when there's an activity Jiri Olsa
2016-10-25 18:07 ` Arnaldo Carvalho de Melo
2016-10-25 21:24   ` Namhyung Kim
2016-10-28 17:45 ` [tip:perf/core] " tip-bot for Namhyung Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.