Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753577AbbG2NgE (ORCPT ); Wed, 29 Jul 2015 09:36:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56385 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752541AbbG2NgB (ORCPT ); Wed, 29 Jul 2015 09:36:01 -0400 Date: Wed, 29 Jul 2015 15:13:00 +0200 From: Jiri Olsa To: kan.liang@intel.com Cc: a.p.zijlstra@chello.nl, acme@kernel.org, luto@kernel.org, mingo@redhat.com, eranian@google.com, ak@linux.intel.com, mark.rutland@arm.com, adrian.hunter@intel.com, jolsa@kernel.org, namhyung@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V3 3/5] perf,tools: Dump per-sample freq/CPU%/CORE_BUSY% in report -D Message-ID: <20150729131300.GI9606@krava.brq.redhat.com> References: <1438082975-47730-1-git-send-email-kan.liang@intel.com> <1438082975-47730-4-git-send-email-kan.liang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1438082975-47730-4-git-send-email-kan.liang@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2842 Lines: 85 On Tue, Jul 28, 2015 at 07:29:33AM -0400, kan.liang@intel.com wrote: SNIP > > static void event_swap(union perf_event *event, bool sample_id_all) > diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h > index b44afc7..e6e408b 100644 > --- a/tools/perf/util/session.h > +++ b/tools/perf/util/session.h > @@ -42,6 +42,53 @@ struct perf_session { > #define PRINT_IP_OPT_ONELINE (1<<4) > #define PRINT_IP_OPT_SRCLINE (1<<5) > > +#define PERF_MSR_TSC 0 > +#define PERF_MSR_APERF 1 > +#define PERF_MSR_MPERF 2 > + > +enum perf_freq_perf_index { > + FREQ_PERF_TSC = 0, > + FREQ_PERF_APERF = 1, > + FREQ_PERF_MPERF = 2, > + FREQ_PERF_CYCLES = 3, > + FREQ_PERF_REF_CYCLES = 4, > + > + FREQ_PERF_MAX > +}; hum, rather than adding macros over anonymous array, how about add perf_freq_t like: typedef int perf_freq_t[FREQ_PERF_MAX]; and turn macros below into functions like: SET_FREQ_PERF_VALUE perf_freq__init HAS_FREQ perf_freq__has_freq GET_FREQ perf_freq__get_freq HAS_CPU_UTIL perf_freq__has_cpu_util GET_CPU_UTIL perf_freq__get_cpu_util HAS_CORE_BUSY perf_freq__has_core_busy GET_CORE_BUSY perf_freq__get_core_busy jirka > + > +#define SET_FREQ_PERF_VALUE(msr_pmu_type, event, array, value) \ > +{ \ > + if (event->attr.type == msr_pmu_type) { \ > + if (event->attr.config == PERF_MSR_TSC) \ > + array[FREQ_PERF_TSC] = value; \ > + if (event->attr.config == PERF_MSR_APERF) \ > + array[FREQ_PERF_APERF] = value; \ > + if (event->attr.config == PERF_MSR_MPERF) \ > + array[FREQ_PERF_MPERF] = value; \ > + } \ > + if (event->attr.type == PERF_TYPE_HARDWARE) { \ > + if (event->attr.config == PERF_COUNT_HW_CPU_CYCLES) \ > + array[FREQ_PERF_CYCLES] = value; \ > + if (event->attr.config == PERF_COUNT_HW_REF_CPU_CYCLES) \ > + array[FREQ_PERF_REF_CYCLES] = value; \ > + } \ > +} > + > +#define HAS_FREQ(array) \ > + ((array[FREQ_PERF_CYCLES] > 0) && (array[FREQ_PERF_REF_CYCLES] > 0)) > +#define GET_FREQ(array, cpu_max_freq) \ > + ((array[FREQ_PERF_CYCLES] * cpu_max_freq) / array[FREQ_PERF_REF_CYCLES]) > + > +#define HAS_CPU_UTIL(array) \ > + ((array[FREQ_PERF_TSC] > 0) && (array[FREQ_PERF_REF_CYCLES] > 0)) > +#define GET_CPU_UTIL(array) \ > + ((100 * array[FREQ_PERF_REF_CYCLES]) / array[FREQ_PERF_TSC]) > + > +#define HAS_CORE_BUSY(array) \ > + ((array[FREQ_PERF_APERF] > 0) && (array[FREQ_PERF_MPERF] > 0)) > +#define GET_CORE_BUSY(array) \ > + ((100 * array[FREQ_PERF_APERF]) / array[FREQ_PERF_MPERF]) SNIP -- 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/