Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755587AbbLVRJc (ORCPT ); Tue, 22 Dec 2015 12:09:32 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:33850 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933301AbbLVRIa (ORCPT ); Tue, 22 Dec 2015 12:08:30 -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 10/13] perf tools: Support '.*' dynamic sort key Date: Wed, 23 Dec 2015 02:07:07 +0900 Message-Id: <1450804030-29193-11-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: 3500 Lines: 106 Support '*' character for field name to add all (non-common) fields as sort keys easily. $ perf report -s 'switch.*' --stdio ... # Overhead prev_comm prev_pid prev_prio prev_state next_comm next_pid next_prio # ........ ........... ......... ......... .......... ............ ........ ......... # 3.82% swapper/0 0 120 0 netctl-auto 18711 120 3.75% netctl-auto 18711 120 1 swapper/0 0 120 2.24% swapper/1 0 120 0 netctl-auto 18709 120 2.24% netctl-auto 18709 120 1 swapper/1 0 120 1.80% swapper/2 0 120 0 rcu_preempt 7 120 1.80% swapper/2 0 120 0 netctl-auto 18711 120 1.80% rcu_preempt 7 120 1 swapper/2 0 120 1.80% netctl-auto 18711 120 1 swapper/2 0 120 ... Suggested-by: Jiri Olsa Signed-off-by: Namhyung Kim --- tools/perf/util/sort.c | 49 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 78496f0555ec..297383e0abc5 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -1907,12 +1907,27 @@ static struct perf_evsel *find_evsel(struct perf_evlist *evlist, char *event_nam return evsel; } +static int __dynamic_dimension__add(struct perf_evsel *evsel, + struct format_field *field, + bool raw_trace) +{ + struct hpp_dynamic_entry *hde; + + hde = __alloc_dynamic_entry(evsel, field); + if (hde == NULL) + return -ENOMEM; + + hde->raw_trace = raw_trace; + + perf_hpp__register_sort_field(&hde->hpp); + return 0; +} + static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok) { char *str, *event_name, *field_name, *opt_name; struct perf_evsel *evsel; struct format_field *field; - struct hpp_dynamic_entry *hde; bool raw_trace = symbol_conf.raw_trace; int ret = 0; @@ -1950,22 +1965,26 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok) goto out; } - field = pevent_find_any_field(evsel->tp_format, field_name); - if (field == NULL) { - pr_debug("Cannot find event field for %s.%s\n", - event_name, field_name); - ret = -ENOENT; - goto out; - } + if (!strcmp(field_name, "*")) { + field = evsel->tp_format->format.fields; - hde = __alloc_dynamic_entry(evsel, field); - if (hde == NULL) { - ret = -ENOMEM; - goto out; - } - hde->raw_trace = raw_trace; + while (field) { + ret = __dynamic_dimension__add(evsel, field, raw_trace); + if (ret < 0) + goto out; - perf_hpp__register_sort_field(&hde->hpp); + field = field->next; + } + } else { + field = pevent_find_any_field(evsel->tp_format, field_name); + if (field == NULL) { + pr_debug("Cannot find event field for %s.%s\n", + event_name, field_name); + return -ENOENT; + } + + ret = __dynamic_dimension__add(evsel, field, raw_trace); + } out: free(str); -- 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/