lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 29 Jul 2015 15:13:00 +0200
From:	Jiri Olsa <jolsa@...hat.com>
To:	kan.liang@...el.com
Cc:	a.p.zijlstra@...llo.nl, acme@...nel.org, luto@...nel.org,
	mingo@...hat.com, eranian@...gle.com, ak@...ux.intel.com,
	mark.rutland@....com, adrian.hunter@...el.com, jolsa@...nel.org,
	namhyung@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH V3 3/5] perf,tools: Dump per-sample freq/CPU%/CORE_BUSY%
 in report -D

On Tue, Jul 28, 2015 at 07:29:33AM -0400, kan.liang@...el.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@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ