From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934077AbbIDWCc (ORCPT ); Fri, 4 Sep 2015 18:02:32 -0400 Received: from mga09.intel.com ([134.134.136.24]:26263 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933725AbbIDWB1 (ORCPT ); Fri, 4 Sep 2015 18:01:27 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,470,1437462000"; d="scan'208";a="798098743" From: kan.liang@intel.com To: acme@kernel.org Cc: jolsa@kernel.org, namhyung@kernel.org, adrian.hunter@intel.com, eranian@google.com, ak@linux.intel.com, linux-kernel@vger.kernel.org, Kan Liang Subject: [PATCH 2/5] perf,tools: Support new sort type --socket Date: Fri, 4 Sep 2015 10:45:43 -0400 Message-Id: <1441377946-44429-2-git-send-email-kan.liang@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1441377946-44429-1-git-send-email-kan.liang@intel.com> References: <1441377946-44429-1-git-send-email-kan.liang@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang This patch enable perf report to sort by processor socket $ perf report --stdio --sort socket,comm,dso,symbol # To display the perf.data header info, please use --header/--header-only options. # # # Total Lost Samples: 0 # # Samples: 686 of event 'cycles' # Event count (approx.): 349215462 # # Overhead SOCKET Command Shared Object Symbol # ........ ...... ......... ................ ................................. # 97.05% 000 test test [.] plusB_c 0.98% 000 test test [.] plusA_c 0.93% 001 perf [kernel.vmlinux] [k] smp_call_function_single 0.19% 001 perf [kernel.vmlinux] [k] page_fault 0.19% 001 swapper [kernel.vmlinux] [k] pm_qos_request 0.16% 000 test [kernel.vmlinux] [k] add_mm_counter_fast Signed-off-by: Kan Liang --- tools/perf/Documentation/perf-report.txt | 3 ++- tools/perf/util/hist.h | 1 + tools/perf/util/sort.c | 22 ++++++++++++++++++++++ tools/perf/util/sort.h | 1 + 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt index 9c7981b..92361a7 100644 --- a/tools/perf/Documentation/perf-report.txt +++ b/tools/perf/Documentation/perf-report.txt @@ -68,7 +68,7 @@ OPTIONS --sort=:: Sort histogram entries by given key(s) - multiple keys can be specified in CSV format. Following sort keys are available: - pid, comm, dso, symbol, parent, cpu, srcline, weight, local_weight. + pid, comm, dso, symbol, parent, cpu, socket, srcline, weight, local_weight. Each key has following meaning: @@ -79,6 +79,7 @@ OPTIONS - parent: name of function matched to the parent regex filter. Unmatched entries are displayed as "[other]". - cpu: cpu number the task ran at the time of sample + - socket: processor socket number the task ran at the time of sample - srcline: filename and line number executed at the time of sample. The DWARF debugging info must be provided. - srcfile: file name of the source file of the same. Requires dwarf diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index de6d58e..5d04d28 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -29,6 +29,7 @@ enum hist_column { HISTC_COMM, HISTC_PARENT, HISTC_CPU, + HISTC_SOCKET, HISTC_SRCLINE, HISTC_SRCFILE, HISTC_MISPREDICT, diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index a97bcee..c4a32b9 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -421,6 +421,27 @@ struct sort_entry sort_cpu = { .se_width_idx = HISTC_CPU, }; +/* --sort socket */ + +static int64_t +sort__socket_cmp(struct hist_entry *left, struct hist_entry *right) +{ + return right->socket - left->socket; +} + +static int hist_entry__socket_snprintf(struct hist_entry *he, char *bf, + size_t size, unsigned int width) +{ + return repsep_snprintf(bf, size, "%*.*d", width, width-3, he->socket); +} + +struct sort_entry sort_socket = { + .se_header = "SOCKET", + .se_cmp = sort__socket_cmp, + .se_snprintf = hist_entry__socket_snprintf, + .se_width_idx = HISTC_SOCKET, +}; + /* sort keys for branch stacks */ static int64_t @@ -1248,6 +1269,7 @@ static struct sort_dimension common_sort_dimensions[] = { DIM(SORT_SYM, "symbol", sort_sym), DIM(SORT_PARENT, "parent", sort_parent), DIM(SORT_CPU, "cpu", sort_cpu), + DIM(SORT_SOCKET, "socket", sort_socket), DIM(SORT_SRCLINE, "srcline", sort_srcline), DIM(SORT_SRCFILE, "srcfile", sort_srcfile), DIM(SORT_LOCAL_WEIGHT, "local_weight", sort_local_weight), diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 7cf1cf7..654ac8a 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -173,6 +173,7 @@ enum sort_type { SORT_SYM, SORT_PARENT, SORT_CPU, + SORT_SOCKET, SORT_SRCLINE, SORT_SRCFILE, SORT_LOCAL_WEIGHT, -- 1.8.3.1