From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756688AbcAIQjW (ORCPT ); Sat, 9 Jan 2016 11:39:22 -0500 Received: from terminus.zytor.com ([198.137.202.10]:42275 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755717AbcAIQjS (ORCPT ); Sat, 9 Jan 2016 11:39:18 -0500 Date: Sat, 9 Jan 2016 08:39:03 -0800 From: tip-bot for Jiri Olsa Message-ID: Cc: tglx@linutronix.de, mingo@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org, a.p.zijlstra@chello.nl, adrian.hunter@intel.com, acme@redhat.com, dsahern@gmail.com, jolsa@kernel.org, namhyung@kernel.org, noelgrandin@gmail.com Reply-To: jolsa@kernel.org, namhyung@kernel.org, noelgrandin@gmail.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org, hpa@zytor.com, dsahern@gmail.com, a.p.zijlstra@chello.nl, adrian.hunter@intel.com, acme@redhat.com In-Reply-To: <1452158050-28061-12-git-send-email-jolsa@kernel.org> References: <1452158050-28061-12-git-send-email-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Add overhead/ overhead_children keys defaults via string Git-Commit-ID: b97511c5bc94ef12613f485ab82f989df04088da X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: b97511c5bc94ef12613f485ab82f989df04088da Gitweb: http://git.kernel.org/tip/b97511c5bc94ef12613f485ab82f989df04088da Author: Jiri Olsa AuthorDate: Thu, 7 Jan 2016 10:14:08 +0100 Committer: Arnaldo Carvalho de Melo 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 Acked-by: Namhyung Kim Cc: Adrian Hunter Cc: David Ahern Cc: Noel Grandin Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1452158050-28061-12-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- 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);