From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932577Ab3CZMMf (ORCPT ); Tue, 26 Mar 2013 08:12:35 -0400 Received: from LGEMRELSE6Q.lge.com ([156.147.1.121]:43180 "EHLO LGEMRELSE6Q.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757947Ab3CZMMI (ORCPT ); Tue, 26 Mar 2013 08:12:08 -0400 X-AuditID: 9c930179-b7c78ae000000e4b-50-5151909575f1 From: Namhyung Kim To: Arnaldo Carvalho de Melo Cc: Peter Zijlstra , Paul Mackerras , Ingo Molnar , Namhyung Kim , LKML , Stephane Eranian Subject: [PATCH 2/3] perf sort: Add 'addr_to/from' sort key Date: Tue, 26 Mar 2013 21:11:57 +0900 Message-Id: <1364299918-31175-2-git-send-email-namhyung@kernel.org> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1364299918-31175-1-git-send-email-namhyung@kernel.org> References: <1364299918-31175-1-git-send-email-namhyung@kernel.org> X-Brightmail-Tracker: AAAAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Namhyung Kim New addr_{to,from} sort keys provide a way to sort the entries by the source/target symbol addresses. Cc: Stephane Eranian Signed-off-by: Namhyung Kim --- tools/perf/util/hist.c | 2 ++ tools/perf/util/hist.h | 2 ++ tools/perf/util/sort.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/sort.h | 2 ++ 4 files changed, 56 insertions(+) diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 82b7542db904..b951f4101d7e 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -54,6 +54,8 @@ void hists__reset_col_len(struct hists *hists) hists__set_col_len(hists, col, 0); hists__set_col_len(hists, HISTC_ADDR, BITS_PER_LONG / 4 + 2); + hists__set_col_len(hists, HISTC_ADDR_FROM, BITS_PER_LONG / 4 + 2); + hists__set_col_len(hists, HISTC_ADDR_TO, BITS_PER_LONG / 4 + 2); } static void hists__set_unres_dso_col_len(struct hists *hists, int dso) diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 72c75bef0c68..ad1462c87918 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -50,6 +50,8 @@ enum hist_column { HISTC_DSO_TO, HISTC_SRCLINE, HISTC_ADDR, + HISTC_ADDR_FROM, + HISTC_ADDR_TO, HISTC_NR_COLS, /* Last entry */ }; diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 27e55562cbbb..988d7ea3ecc2 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -428,6 +428,40 @@ static int hist_entry__sym_to_snprintf(struct hist_entry *self, char *bf, } +static int64_t +sort__addr_from_cmp(struct hist_entry *left, struct hist_entry *right) +{ + struct addr_map_symbol *from_l = &left->branch_info->from; + struct addr_map_symbol *from_r = &right->branch_info->from; + + return from_r->addr - from_l->addr; +} + +static int hist_entry__addr_from_snprintf(struct hist_entry *self, char *bf, + size_t size, unsigned int width) +{ + struct addr_map_symbol *from = &self->branch_info->from; + return repsep_snprintf(bf, size, "%#*"PRIx64, width, + (uint64_t)from->addr); +} + +static int64_t +sort__addr_to_cmp(struct hist_entry *left, struct hist_entry *right) +{ + struct addr_map_symbol *to_l = &left->branch_info->to; + struct addr_map_symbol *to_r = &right->branch_info->to; + + return to_r->addr - to_l->addr; +} + +static int hist_entry__addr_to_snprintf(struct hist_entry *self, char *bf, + size_t size, unsigned int width) +{ + struct addr_map_symbol *to = &self->branch_info->to; + return repsep_snprintf(bf, size, "%#*"PRIx64, width, + (uint64_t)to->addr); +} + struct sort_entry sort_dso_from = { .se_header = "Source Shared Object", .se_cmp = sort__dso_from_cmp, @@ -456,6 +490,20 @@ struct sort_entry sort_sym_to = { .se_width_idx = HISTC_SYMBOL_TO, }; +struct sort_entry sort_addr_from = { + .se_header = "Source Address", + .se_cmp = sort__addr_from_cmp, + .se_snprintf = hist_entry__addr_from_snprintf, + .se_width_idx = HISTC_ADDR_FROM, +}; + +struct sort_entry sort_addr_to = { + .se_header = "Target Address", + .se_cmp = sort__addr_to_cmp, + .se_snprintf = hist_entry__addr_to_snprintf, + .se_width_idx = HISTC_ADDR_TO, +}; + static int64_t sort__mispredict_cmp(struct hist_entry *left, struct hist_entry *right) { @@ -514,6 +562,8 @@ static struct sort_dimension bstack_sort_dimensions[] = { DIM(SORT_DSO_TO, "dso_to", sort_dso_to), DIM(SORT_SYM_FROM, "symbol_from", sort_sym_from), DIM(SORT_SYM_TO, "symbol_to", sort_sym_to), + DIM(SORT_ADDR_FROM, "addr_from", sort_addr_from), + DIM(SORT_ADDR_TO, "addr_to", sort_addr_to), DIM(SORT_MISPREDICT, "mispredict", sort_mispredict), }; diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index a24dba16cc8f..1c049cf58f34 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -138,6 +138,8 @@ enum sort_type { SORT_DSO_TO, SORT_SYM_FROM, SORT_SYM_TO, + SORT_ADDR_FROM, + SORT_ADDR_TO, SORT_MISPREDICT, }; -- 1.7.11.7