From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936084AbdEVVvS (ORCPT ); Mon, 22 May 2017 17:51:18 -0400 Received: from mga06.intel.com ([134.134.136.31]:2818 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934097AbdEVVvQ (ORCPT ); Mon, 22 May 2017 17:51:16 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,379,1491289200"; d="scan'208";a="1172905059" From: "Liang, Kan" To: Stephane Eranian , Peter Zijlstra CC: "mingo@redhat.com" , "linux-kernel@vger.kernel.org" , "alexander.shishkin@linux.intel.com" , "acme@redhat.com" , "jolsa@redhat.com" , "torvalds@linux-foundation.org" , "tglx@linutronix.de" , "vincent.weaver@maine.edu" , "ak@linux.intel.com" Subject: RE: [PATCH 1/2] perf/x86/intel: enable CPU ref_cycles for GP counter Thread-Topic: [PATCH 1/2] perf/x86/intel: enable CPU ref_cycles for GP counter Thread-Index: AQHS0MiHfyjRMknVHkW8awSHhRlbV6H/kUoAgAEBC1D//6fNgIAAAVsAgACq4/A= Date: Mon, 22 May 2017 21:51:11 +0000 Message-ID: <37D7C6CF3E00A74B8858931C1DB2F077536F08F9@SHSMSX103.ccr.corp.intel.com> References: <1495213582-3635-1-git-send-email-kan.liang@intel.com> <20170522091916.3gydvflk4fnqkzw5@hirez.programming.kicks-ass.net> <37D7C6CF3E00A74B8858931C1DB2F077536F079F@SHSMSX103.ccr.corp.intel.com> <20170522192335.v4gvhz24ix2jeihg@hirez.programming.kicks-ass.net> In-Reply-To: Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZDUwMTQyNDMtMDY0MS00ZTliLWE3ZGMtYTJkNzc2NGNkMGQzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IjBLNVJTa0RoWWdEdnpXRVwvWjdjcjIxNzZPeXFXaUhZMnF0WWE4d3RuV0E4PSJ9 x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v4MLpRaJ019900 > > On Mon, May 22, 2017 at 12:23 PM, Peter Zijlstra > wrote: > > On Mon, May 22, 2017 at 04:55:47PM +0000, Liang, Kan wrote: > >> > >> > >> > On Fri, May 19, 2017 at 10:06:21AM -0700, kan.liang@intel.com wrote: > >> > > diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c > >> > > index > >> > > 580b60f..e8b2326 100644 > >> > > --- a/arch/x86/events/core.c > >> > > +++ b/arch/x86/events/core.c > >> > > @@ -101,6 +101,10 @@ u64 x86_perf_event_update(struct > perf_event > >> > *event) > >> > > delta = (new_raw_count << shift) - (prev_raw_count << shift); > >> > > delta >>= shift; > >> > > > >> > > + /* Correct the count number if applying ref_cycles replacement > >> > > + */ if (!is_sampling_event(event) && > >> > > + (hwc->flags & PERF_X86_EVENT_REF_CYCLES_REP)) > >> > > + delta *= x86_pmu.ref_cycles_factor; > >> > > >> > That condition seems wrong, why only correct for !sampling events? > >> > > >> > >> For sampling, it's either fixed freq mode or fixed period mode. > >> - In the fixed freq mode, we should do nothing, because the adaptive > >> frequency algorithm will handle it. > >> - In the fixed period mode, we have already adjusted the period in > >> ref_cycles_rep(). > >> Therefore, we should only handle !sampling events here. > > > > How so? For sampling events the actual event count should also be > > accurate. > > Yes, it must be. Because you can reconstruct the total number of occurrences > of the event by adding all the periods recorded in each sample. So the period > in each sample must reflect user event and not kernel event. Peter and Stephane, you are right. After adjusting the period, I can only make sure the number of samples for the bus_cycles event is the same as that for ref cycles event. I still need to adjust the number of occurrences of the event accordingly, to make it accurate. I will change it in next version. Thanks, Kan