Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754699AbbGQU5q (ORCPT ); Fri, 17 Jul 2015 16:57:46 -0400 Received: from mga14.intel.com ([192.55.52.115]:41113 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754624AbbGQU5o convert rfc822-to-8bit (ORCPT ); Fri, 17 Jul 2015 16:57:44 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,497,1432623600"; d="scan'208";a="766562275" From: "Liang, Kan" To: Andi Kleen CC: "a.p.zijlstra@chello.nl" , "mingo@redhat.com" , "acme@kernel.org" , "eranian@google.com" , "mark.rutland@arm.com" , "Hunter, Adrian" , "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 Thread-Topic: [PATCH 8/9] perf,tools: caculate and save tsc/avg/bzy freq in he_stat Thread-Index: AQHQwEN6iUiY6nlnK0q9ecE4lDPymJ3fluqAgACKmbA= Date: Fri, 17 Jul 2015 20:57:36 +0000 Message-ID: <37D7C6CF3E00A74B8858931C1DB2F0770188E169@SHSMSX103.ccr.corp.intel.com> References: <1437078831-10152-1-git-send-email-kan.liang@intel.com> <1437078831-10152-9-git-send-email-kan.liang@intel.com> <20150717202553.GG7380@tassilo.jf.intel.com> In-Reply-To: <20150717202553.GG7380@tassilo.jf.intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1721 Lines: 48 > > > + 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 concept of tsc, avg and bzy are from turbostat. Here is the definition from turbostat readme. - AVG_MHz = APERF_delta/measurement_interval. This is the actual number of elapsed cycles divided by the entire sample interval - TSC_MHz = TSC_delta/measurement_interval. On a system with an invariant TSC, this value will be constant and will closely match the base frequency value - Bzy_MHz = TSC_delta/APERF_delta/MPERF_delta/measurement_interval Only the Bzy_MHz is wrong and has a typo error. Other formula should be correct. If it's confusion, I will change the name and make it consistent as turbostat. > The right way to compute frequency is cycles / ref-cycles TSC can be used > to accurately compute CPU utilization tsc / ref-cycles I think I can add the support for frequency and CPU% calculation, and show them in --stdio. Thanks, Kan > > 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/