Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1303403 > unrolled thread

[PATCH 11/13] perf tools: Add overhead/overhead_children keys defaults via string

Started byJiri Olsa <jolsa@kernel.org>
First post2016-01-07 10:20 +0100
Last post2016-01-09 17:40 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 11/13] perf tools: Add overhead/overhead_children keys defaults via string Jiri Olsa <jolsa@kernel.org> - 2016-01-07 10:20 +0100
    Re: [PATCH 11/13] perf tools: Add overhead/overhead_children keys  defaults via string Namhyung Kim <namhyung@kernel.org> - 2016-01-07 12:20 +0100
    [tip:perf/core] perf tools: Add overhead/  overhead_children keys defaults via string tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-01-09 17:40 +0100

#1303403 — [PATCH 11/13] perf tools: Add overhead/overhead_children keys defaults via string

FromJiri Olsa <jolsa@kernel.org>
Date2016-01-07 10:20 +0100
Subject[PATCH 11/13] perf tools: Add overhead/overhead_children keys defaults via string
Message-ID<qOeTF-65o-31@gated-at.bofh.it>
We currently set 'overhead' and 'overhead_children'
as default sort keys within perf_hpp__init function
by directly adding into the sort list.

This patch adds 'overhead' and 'overhead_children'
in text form into sort_keys and let them be added
by standard sort dimension interface.

We need to eliminate dirrect sort_list additions to
b able to add support for hists specific sort keys.

Link: http://lkml.kernel.org/n/tip-thk6jds1pi6j2jy82ywnxniy@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/ui/hist.c   | 12 ------------
 tools/perf/util/sort.c | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 8263c0eb9fb5..bf2a66e254ea 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -443,7 +443,6 @@ LIST_HEAD(perf_hpp__sort_list);
 
 void perf_hpp__init(void)
 {
-	struct list_head *list;
 	int i;
 
 	for (i = 0; i < PERF_HPP__MAX_INDEX; i++) {
@@ -484,17 +483,6 @@ void perf_hpp__init(void)
 
 	if (symbol_conf.show_total_period)
 		hpp_dimension__add_output(PERF_HPP__PERIOD);
-
-	/* prepend overhead field for backward compatiblity.  */
-	list = &perf_hpp__format[PERF_HPP__OVERHEAD].sort_list;
-	if (list_empty(list))
-		list_add(list, &perf_hpp__sort_list);
-
-	if (symbol_conf.cumulate_callchain) {
-		list = &perf_hpp__format[PERF_HPP__OVERHEAD_ACC].sort_list;
-		if (list_empty(list))
-			list_add(list, &perf_hpp__sort_list);
-	}
 }
 
 void perf_hpp__column_register(struct perf_hpp_fmt *format)
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 04e2a5cb19e3..ec722346e6ff 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2252,6 +2252,34 @@ static int setup_sort_order(struct perf_evlist *evlist)
 	return 0;
 }
 
+/*
+ * Adds 'pre,' prefix into 'str' is 'pre' is
+ * not already part of 'str'.
+ */
+static char *prefix_if_not_in(const char *pre, char *str)
+{
+	char *n;
+
+	if (!str || strstr(str, pre))
+		return str;
+
+	if (asprintf(&n, "%s,%s", pre, str) < 0)
+		return NULL;
+
+	free(str);
+	return n;
+}
+
+static char *setup_overhead(char *keys)
+{
+	keys = prefix_if_not_in("overhead", keys);
+
+	if (symbol_conf.cumulate_callchain)
+		keys = prefix_if_not_in("overhead_children", keys);
+
+	return keys;
+}
+
 static int __setup_sorting(struct perf_evlist *evlist)
 {
 	char *tmp, *tok, *str;
@@ -2281,6 +2309,17 @@ static int __setup_sorting(struct perf_evlist *evlist)
 		return -ENOMEM;
 	}
 
+	/*
+	 * Prepend overhead fields for backward compatibility.
+	 */
+	if (!is_strict_order(field_order)) {
+		str = setup_overhead(str);
+		if (str == NULL) {
+			error("Not enough memory to setup overhead keys");
+			return -ENOMEM;
+		}
+	}
+
 	for (tok = strtok_r(str, ", ", &tmp);
 			tok; tok = strtok_r(NULL, ", ", &tmp)) {
 		ret = sort_dimension__add(tok, evlist);
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1303485 — Re: [PATCH 11/13] perf tools: Add overhead/overhead_children keys defaults via string

FromNamhyung Kim <namhyung@kernel.org>
Date2016-01-07 12:20 +0100
SubjectRe: [PATCH 11/13] perf tools: Add overhead/overhead_children keys defaults via string
Message-ID<qOgLM-7kJ-3@gated-at.bofh.it>
In reply to#1303403
On Thu, Jan 07, 2016 at 10:14:08AM +0100, Jiri Olsa wrote:
> We currently set 'overhead' and 'overhead_children'
> as default sort keys within perf_hpp__init function
> by directly adding into the sort list.
> 
> This patch adds 'overhead' and 'overhead_children'
> in text form into sort_keys and let them be added
> by standard sort dimension interface.
> 
> We need to eliminate dirrect sort_list additions to
> b able to add support for hists specific sort keys.
> 
> Link: http://lkml.kernel.org/n/tip-thk6jds1pi6j2jy82ywnxniy@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung


> ---
>  tools/perf/ui/hist.c   | 12 ------------
>  tools/perf/util/sort.c | 39 +++++++++++++++++++++++++++++++++++++++
>  2 files changed, 39 insertions(+), 12 deletions(-)
> 
> diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
> index 8263c0eb9fb5..bf2a66e254ea 100644
> --- a/tools/perf/ui/hist.c
> +++ b/tools/perf/ui/hist.c
> @@ -443,7 +443,6 @@ LIST_HEAD(perf_hpp__sort_list);
>  
>  void perf_hpp__init(void)
>  {
> -	struct list_head *list;
>  	int i;
>  
>  	for (i = 0; i < PERF_HPP__MAX_INDEX; i++) {
> @@ -484,17 +483,6 @@ void perf_hpp__init(void)
>  
>  	if (symbol_conf.show_total_period)
>  		hpp_dimension__add_output(PERF_HPP__PERIOD);
> -
> -	/* prepend overhead field for backward compatiblity.  */
> -	list = &perf_hpp__format[PERF_HPP__OVERHEAD].sort_list;
> -	if (list_empty(list))
> -		list_add(list, &perf_hpp__sort_list);
> -
> -	if (symbol_conf.cumulate_callchain) {
> -		list = &perf_hpp__format[PERF_HPP__OVERHEAD_ACC].sort_list;
> -		if (list_empty(list))
> -			list_add(list, &perf_hpp__sort_list);
> -	}
>  }
>  
>  void perf_hpp__column_register(struct perf_hpp_fmt *format)
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index 04e2a5cb19e3..ec722346e6ff 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -2252,6 +2252,34 @@ static int setup_sort_order(struct perf_evlist *evlist)
>  	return 0;
>  }
>  
> +/*
> + * Adds 'pre,' prefix into 'str' is 'pre' is
> + * not already part of 'str'.
> + */
> +static char *prefix_if_not_in(const char *pre, char *str)
> +{
> +	char *n;
> +
> +	if (!str || strstr(str, pre))
> +		return str;
> +
> +	if (asprintf(&n, "%s,%s", pre, str) < 0)
> +		return NULL;
> +
> +	free(str);
> +	return n;
> +}
> +
> +static char *setup_overhead(char *keys)
> +{
> +	keys = prefix_if_not_in("overhead", keys);
> +
> +	if (symbol_conf.cumulate_callchain)
> +		keys = prefix_if_not_in("overhead_children", keys);
> +
> +	return keys;
> +}
> +
>  static int __setup_sorting(struct perf_evlist *evlist)
>  {
>  	char *tmp, *tok, *str;
> @@ -2281,6 +2309,17 @@ static int __setup_sorting(struct perf_evlist *evlist)
>  		return -ENOMEM;
>  	}
>  
> +	/*
> +	 * Prepend overhead fields for backward compatibility.
> +	 */
> +	if (!is_strict_order(field_order)) {
> +		str = setup_overhead(str);
> +		if (str == NULL) {
> +			error("Not enough memory to setup overhead keys");
> +			return -ENOMEM;
> +		}
> +	}
> +
>  	for (tok = strtok_r(str, ", ", &tmp);
>  			tok; tok = strtok_r(NULL, ", ", &tmp)) {
>  		ret = sort_dimension__add(tok, evlist);
> -- 
> 2.4.3
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1305285 — [tip:perf/core] perf tools: Add overhead/ overhead_children keys defaults via string

Fromtip-bot for Jiri Olsa <tipbot@zytor.com>
Date2016-01-09 17:40 +0100
Subject[tip:perf/core] perf tools: Add overhead/ overhead_children keys defaults via string
Message-ID<qP4Iy-87R-5@gated-at.bofh.it>
In reply to#1303403
Commit-ID:  b97511c5bc94ef12613f485ab82f989df04088da
Gitweb:     http://git.kernel.org/tip/b97511c5bc94ef12613f485ab82f989df04088da
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Thu, 7 Jan 2016 10:14:08 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 8 Jan 2016 12:58:58 -0300

perf tools: Add overhead/overhead_children keys defaults via string

We currently set 'overhead' and 'overhead_children' as default sort keys
within perf_hpp__init function by directly adding into the sort list.

This patch adds 'overhead' and 'overhead_children' in text form into
sort_keys and let them be added by standard sort dimension interface.

We need to eliminate dirrect sort_list additions to be able to add
support for hists specific sort keys.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Noel Grandin <noelgrandin@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1452158050-28061-12-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/hist.c   | 12 ------------
 tools/perf/util/sort.c | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 8263c0e..bf2a66e 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -443,7 +443,6 @@ LIST_HEAD(perf_hpp__sort_list);
 
 void perf_hpp__init(void)
 {
-	struct list_head *list;
 	int i;
 
 	for (i = 0; i < PERF_HPP__MAX_INDEX; i++) {
@@ -484,17 +483,6 @@ void perf_hpp__init(void)
 
 	if (symbol_conf.show_total_period)
 		hpp_dimension__add_output(PERF_HPP__PERIOD);
-
-	/* prepend overhead field for backward compatiblity.  */
-	list = &perf_hpp__format[PERF_HPP__OVERHEAD].sort_list;
-	if (list_empty(list))
-		list_add(list, &perf_hpp__sort_list);
-
-	if (symbol_conf.cumulate_callchain) {
-		list = &perf_hpp__format[PERF_HPP__OVERHEAD_ACC].sort_list;
-		if (list_empty(list))
-			list_add(list, &perf_hpp__sort_list);
-	}
 }
 
 void perf_hpp__column_register(struct perf_hpp_fmt *format)
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 04e2a5c..ec72234 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2252,6 +2252,34 @@ static int setup_sort_order(struct perf_evlist *evlist)
 	return 0;
 }
 
+/*
+ * Adds 'pre,' prefix into 'str' is 'pre' is
+ * not already part of 'str'.
+ */
+static char *prefix_if_not_in(const char *pre, char *str)
+{
+	char *n;
+
+	if (!str || strstr(str, pre))
+		return str;
+
+	if (asprintf(&n, "%s,%s", pre, str) < 0)
+		return NULL;
+
+	free(str);
+	return n;
+}
+
+static char *setup_overhead(char *keys)
+{
+	keys = prefix_if_not_in("overhead", keys);
+
+	if (symbol_conf.cumulate_callchain)
+		keys = prefix_if_not_in("overhead_children", keys);
+
+	return keys;
+}
+
 static int __setup_sorting(struct perf_evlist *evlist)
 {
 	char *tmp, *tok, *str;
@@ -2281,6 +2309,17 @@ static int __setup_sorting(struct perf_evlist *evlist)
 		return -ENOMEM;
 	}
 
+	/*
+	 * Prepend overhead fields for backward compatibility.
+	 */
+	if (!is_strict_order(field_order)) {
+		str = setup_overhead(str);
+		if (str == NULL) {
+			error("Not enough memory to setup overhead keys");
+			return -ENOMEM;
+		}
+	}
+
 	for (tok = strtok_r(str, ", ", &tmp);
 			tok; tok = strtok_r(NULL, ", ", &tmp)) {
 		ret = sort_dimension__add(tok, evlist);

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web