From: Jiri Olsa <jolsa@redhat.com>
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
Date: Wed, 29 Jul 2015 15:13:00 +0200 [thread overview]
Message-ID: <20150729131300.GI9606@krava.brq.redhat.com> (raw)
In-Reply-To: <1438082975-47730-4-git-send-email-kan.liang@intel.com>
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
next prev parent reply other threads:[~2015-07-29 13:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-28 11:29 [PATCH V3 0/5] Freq/CPU%/CORE_BUSY% support kan.liang
2015-07-28 11:29 ` [PATCH V3 1/5] perf,tools: introduce generic FEAT for CPU attributes kan.liang
2015-07-29 12:31 ` Jiri Olsa
2015-07-28 11:29 ` [PATCH V3 2/5] perf,tools: read msr pmu type from header kan.liang
2015-07-28 11:29 ` [PATCH V3 3/5] perf,tools: Dump per-sample freq/CPU%/CORE_BUSY% in report -D kan.liang
2015-07-29 12:52 ` Jiri Olsa
2015-07-29 15:12 ` Arnaldo Carvalho de Melo
2015-07-29 12:53 ` Jiri Olsa
2015-07-29 15:43 ` Arnaldo Carvalho de Melo
2015-07-29 16:12 ` Arnaldo Carvalho de Melo
2015-08-04 17:07 ` Liang, Kan
2015-08-04 17:53 ` Arnaldo Carvalho de Melo
2015-07-29 13:13 ` Jiri Olsa [this message]
2015-07-29 13:14 ` Jiri Olsa
2015-07-28 11:29 ` [PATCH V3 4/5] perf,tools: caculate and save freq/CPU%/CORE_BUSY% in he_stat kan.liang
2015-07-28 11:29 ` [PATCH V3 5/5] perf,tools: Show freq/CPU%/CORE_BUSY% in perf report --stdio kan.liang
2015-07-29 13:22 ` Jiri Olsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150729131300.GI9606@krava.brq.redhat.com \
--to=jolsa@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=eranian@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®