Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933346AbbLVRIo (ORCPT ); Tue, 22 Dec 2015 12:08:44 -0500 Received: from mail-pa0-f49.google.com ([209.85.220.49]:34986 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933311AbbLVRIk (ORCPT ); Tue, 22 Dec 2015 12:08:40 -0500 From: Namhyung Kim To: Arnaldo Carvalho de Melo Cc: Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , David Ahern , Steven Rostedt , Frederic Weisbecker , Andi Kleen , Wang Nan Subject: [PATCH 13/13] perf tools: Make 'trace' or 'trace_fields' sort key default for tracepoint events Date: Wed, 23 Dec 2015 02:07:10 +0900 Message-Id: <1450804030-29193-14-git-send-email-namhyung@kernel.org> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1450804030-29193-1-git-send-email-namhyung@kernel.org> References: <1450804030-29193-1-git-send-email-namhyung@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3430 Lines: 112 When an evlist contains tracepoint events only, use 'trace' sort key as default. If --raw-trace option was given, use 'trace_fields' instead. This will make users more convenient to see trace result. Suggested-by: Jiri Olsa Cc: Steven Rostedt Signed-off-by: Namhyung Kim --- tools/perf/util/sort.c | 27 ++++++++++++++++++++++----- tools/perf/util/sort.h | 1 + 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index ae995f37e135..18927984fe8e 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -15,6 +15,7 @@ const char default_branch_sort_order[] = "comm,dso_from,symbol_from,symbol_to,cy const char default_mem_sort_order[] = "local_weight,mem,sym,dso,symbol_daddr,dso_daddr,snoop,tlb,locked"; const char default_top_sort_order[] = "dso,symbol"; const char default_diff_sort_order[] = "dso,symbol"; +const char default_tracepoint_sort_order[] = "trace"; const char *sort_order; const char *field_order; regex_t ignore_callees_regex; @@ -2167,7 +2168,7 @@ static int sort_dimension__add(const char *tok, return -ESRCH; } -static const char *get_default_sort_order(void) +static const char *get_default_sort_order(struct perf_evlist *evlist) { const char *default_sort_orders[] = { default_sort_order, @@ -2175,14 +2176,30 @@ static const char *get_default_sort_order(void) default_mem_sort_order, default_top_sort_order, default_diff_sort_order, + default_tracepoint_sort_order, }; + bool use_trace = true; + struct perf_evsel *evsel; BUG_ON(sort__mode >= ARRAY_SIZE(default_sort_orders)); + evlist__for_each(evlist, evsel) { + if (evsel->attr.type != PERF_TYPE_TRACEPOINT) { + use_trace = false; + break; + } + } + + if (use_trace) { + sort__mode = SORT_MODE__TRACEPOINT; + if (symbol_conf.raw_trace) + return "trace_fields"; + } + return default_sort_orders[sort__mode]; } -static int setup_sort_order(void) +static int setup_sort_order(struct perf_evlist *evlist) { char *new_sort_order; @@ -2203,7 +2220,7 @@ static int setup_sort_order(void) * because it's checked over the rest of the code. */ if (asprintf(&new_sort_order, "%s,%s", - get_default_sort_order(), sort_order + 1) < 0) { + get_default_sort_order(evlist), sort_order + 1) < 0) { error("Not enough memory to set up --sort"); return -ENOMEM; } @@ -2218,7 +2235,7 @@ static int __setup_sorting(struct perf_evlist *evlist) const char *sort_keys; int ret = 0; - ret = setup_sort_order(); + ret = setup_sort_order(evlist); if (ret) return ret; @@ -2232,7 +2249,7 @@ static int __setup_sorting(struct perf_evlist *evlist) return 0; } - sort_keys = get_default_sort_order(); + sort_keys = get_default_sort_order(evlist); } str = strdup(sort_keys); diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 6b7590ade229..dec536b6ab3d 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -167,6 +167,7 @@ enum sort_mode { SORT_MODE__MEMORY, SORT_MODE__TOP, SORT_MODE__DIFF, + SORT_MODE__TRACEPOINT, }; enum sort_type { -- 2.6.4 -- 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/