Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752778AbbGQUZz (ORCPT ); Fri, 17 Jul 2015 16:25:55 -0400 Received: from mga02.intel.com ([134.134.136.20]:61233 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752347AbbGQUZy (ORCPT ); Fri, 17 Jul 2015 16:25:54 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,497,1432623600"; d="scan'208";a="764758065" Date: Fri, 17 Jul 2015 13:25:53 -0700 From: Andi Kleen To: kan.liang@intel.com Cc: a.p.zijlstra@chello.nl, mingo@redhat.com, acme@kernel.org, eranian@google.com, mark.rutland@arm.com, adrian.hunter@intel.com, dsahern@gmail.com, jolsa@kernel.org, namhyung@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 8/9] perf,tools: caculate and save tsc/avg/bzy freq in he_stat Message-ID: <20150717202553.GG7380@tassilo.jf.intel.com> References: <1437078831-10152-1-git-send-email-kan.liang@intel.com> <1437078831-10152-9-git-send-email-kan.liang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1437078831-10152-9-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: 947 Lines: 22 > + if (sample->read.time_running > 0) { > + freq.tsc_freq = (1000 * sample->tsc) / sample->read.time_running; > + freq.avg_freq = (1000 * sample->aperf) / sample->read.time_running; > + if (sample->aperf > 0) > + freq.bzy_freq = freq.tsc_freq * sample->mperf / sample->aperf; Sorry didn't notice that earlier. The formula is not correct. aperf/mperf is not necessarily the frequency, it is essentially a load average of the CPU. It should be reported as such. Also only the ratio is architecturally defined. The right way to compute frequency is cycles / ref-cycles TSC can be used to accurately compute CPU utilization tsc / ref-cycles It would be useful to report all three metrics. -Andi -- 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/