From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753670AbbIPVkl (ORCPT ); Wed, 16 Sep 2015 17:40:41 -0400 Received: from mga14.intel.com ([192.55.52.115]:7315 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752809AbbIPViF (ORCPT ); Wed, 16 Sep 2015 17:38:05 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,541,1437462000"; d="scan'208";a="770539372" From: kan.liang@intel.com To: acme@kernel.org, jolsa@kernel.org Cc: a.p.zijlstra@chello.nl, luto@kernel.org, mingo@redhat.com, eranian@google.com, ak@linux.intel.com, mark.rutland@arm.com, adrian.hunter@intel.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, Kan Liang Subject: [PATCH V10 7/8] perf,tools: Introduce HPP__SINGLE_PRINT_FNS support Date: Wed, 16 Sep 2015 10:21:55 -0400 Message-Id: <1442413316-33518-8-git-send-email-kan.liang@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1442413316-33518-1-git-send-email-kan.liang@intel.com> References: <1442413316-33518-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 Normally, with group option set, all the events in the same group will be print one by one. So the group header width is the sum of all events width. However, for freqi/cpu%/CORE_BUSY% print, group events share the same value. So only single event width is enough. Signed-off-by: Kan Liang --- tools/perf/ui/hist.c | 43 ++++++++++++++++++++++++++++++++++++++++++- tools/perf/util/hist.h | 3 +++ tools/perf/util/sort.c | 3 +++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index c37aa6f..ba95ee2 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c @@ -235,6 +235,25 @@ static int hpp__header_fn(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, return scnprintf(hpp->buf, hpp->size, "%*s", len, fmt->name); } +static int hpp__single_width_fn(struct perf_hpp_fmt *fmt, + struct perf_hpp *hpp __maybe_unused, + struct perf_evsel *evsel __maybe_unused) +{ + int len = fmt->user_len ?: fmt->len; + + if (len < (int)strlen(fmt->name)) + len = strlen(fmt->name); + + return len; +} + +static int hpp__single_header_fn(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, + struct perf_evsel *evsel) +{ + int len = hpp__single_width_fn(fmt, hpp, evsel); + return scnprintf(hpp->buf, hpp->size, "%*s", len, fmt->name); +} + static int hpp_color_scnprintf(struct perf_hpp *hpp, const char *fmt, ...) { va_list args; @@ -364,6 +383,9 @@ HPP_PERCENT_ACC_FNS(overhead_acc, period) HPP_RAW_FNS(samples, nr_events) HPP_RAW_FNS(period, period) +HPP_RAW_FNS(freq, freq) +HPP_RAW_FNS(cpu_util, cpu_util) +HPP_RAW_FNS(core_busy, core_busy) static int64_t hpp__nop_cmp(struct perf_hpp_fmt *fmt __maybe_unused, struct hist_entry *a __maybe_unused, @@ -407,6 +429,17 @@ static int64_t hpp__nop_cmp(struct perf_hpp_fmt *fmt __maybe_unused, .sort = hpp__sort_ ## _fn, \ } +#define HPP__SINGLE_PRINT_FNS(_name, _fn) \ + { \ + .name = _name, \ + .header = hpp__single_header_fn, \ + .width = hpp__single_width_fn, \ + .entry = hpp__entry_ ## _fn, \ + .cmp = hpp__nop_cmp, \ + .collapse = hpp__nop_cmp, \ + .sort = hpp__sort_ ## _fn, \ + } + struct perf_hpp_fmt perf_hpp__format[] = { HPP__COLOR_PRINT_FNS("Overhead", overhead), HPP__COLOR_PRINT_FNS("sys", overhead_sys), @@ -415,7 +448,10 @@ struct perf_hpp_fmt perf_hpp__format[] = { HPP__COLOR_PRINT_FNS("guest usr", overhead_guest_us), HPP__COLOR_ACC_PRINT_FNS("Children", overhead_acc), HPP__PRINT_FNS("Samples", samples), - HPP__PRINT_FNS("Period", period) + HPP__PRINT_FNS("Period", period), + HPP__SINGLE_PRINT_FNS("FREQ MHz", freq), + HPP__SINGLE_PRINT_FNS("CPU%", cpu_util), + HPP__SINGLE_PRINT_FNS("CORE_BUSY%", core_busy) }; LIST_HEAD(perf_hpp__list); @@ -653,6 +689,9 @@ void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists) return; switch (idx) { + case PERF_HPP__CPU_UTIL: + fmt->len = 5; + break; case PERF_HPP__OVERHEAD: case PERF_HPP__OVERHEAD_SYS: case PERF_HPP__OVERHEAD_US: @@ -662,6 +701,8 @@ void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists) case PERF_HPP__OVERHEAD_GUEST_SYS: case PERF_HPP__OVERHEAD_GUEST_US: + case PERF_HPP__FREQ: + case PERF_HPP__CORE_BUSY: fmt->len = 9; break; diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 4d6aa1d..664b34d 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -241,6 +241,9 @@ enum { PERF_HPP__OVERHEAD_ACC, PERF_HPP__SAMPLES, PERF_HPP__PERIOD, + PERF_HPP__FREQ, + PERF_HPP__CPU_UTIL, + PERF_HPP__CORE_BUSY, PERF_HPP__MAX_INDEX }; diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 6b9556d..1647802 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -1326,6 +1326,9 @@ static struct hpp_dimension hpp_sort_dimensions[] = { DIM(PERF_HPP__OVERHEAD_ACC, "overhead_children"), DIM(PERF_HPP__SAMPLES, "sample"), DIM(PERF_HPP__PERIOD, "period"), + DIM(PERF_HPP__FREQ, "freq"), + DIM(PERF_HPP__CPU_UTIL, "cpu_u"), + DIM(PERF_HPP__CORE_BUSY, "core_busy"), }; #undef DIM -- 1.8.3.1