Received: by 10.213.65.68 with SMTP id h4csp506340imn; Fri, 16 Mar 2018 09:49:53 -0700 (PDT) X-Google-Smtp-Source: AG47ELvJwPpeWojVO7dBwN5vr1HBJgowtGugslfOb19YP/Xwv7wEBiXzk4RU7sDzBepaRcLPwmSs X-Received: by 2002:a17:902:6984:: with SMTP id l4-v6mr2928074plk.61.1521218993218; Fri, 16 Mar 2018 09:49:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521218993; cv=none; d=google.com; s=arc-20160816; b=S1BBPl4wxDmNJ8WJOw3AZNofXx8NKSSRT4JamD+T63p2rbW7gR2VRNyRk+t4CCXI2A ZKKraiF+oxyvn+m/sqhBk5tcw1KvAdi2KVUFRujuKNm3rrkeWsyyz7Ryi8bUrhlDJUDo 0v98exwXvn1/jObM5QCoht/ElRkQlUea2JM69Erj/nNvxSiD8wOQ+iTo0LDU1QQ/T5Jl Q4RFbiOsgFCkw7g2fQYacZ6luh1AXmFW+YKc1bYCoZoECw3dFuCcj3DiCZ14dwiXhQ6T iXMoJVCXp6eRQhG2g50Hx7fhCcvQnE29dyjqyg8yW6M0SqWXe5qc7kM1lYRDzOXUSTd9 6ifg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:arc-authentication-results; bh=XYfSNblRVYFffpSVfVjhEGNnwdrZ30cqNiVEj+4a1+s=; b=gJpr5gH1xrLwNABiG/BEafEWF+W5HQXh6tvMbFRp7btSaAKngl6YnxaHzsJTV8xrkw DS8tPLUwpe/m/lDtQfnMYZ1xkkUrFpJPVPoVMzOEq3eCKqb/xTjQKwugD7HasriDxdux f1Y47UAzwtFSnbv5TyAthiX9Aryy0NIRwfHGOYHqNyVd3EDuFs0unKripXXSEeFZz3AF r6GHdTfo4MeQEmT/yFLJZrOcfFO2xFv/vWzJjuODspJq6rwJydZZb7Wrk2WqqUvq+rOz rCCfeC9/kpwgdP6hXfzHLvWoQMF6vjcG1aL18t6lh1VqhIet5Y3jCsseJ1uXi4meBqVh DDzA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t10-v6si1996352plq.531.2018.03.16.09.49.39; Fri, 16 Mar 2018 09:49:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753396AbeCPQs0 convert rfc822-to-8bit (ORCPT + 99 others); Fri, 16 Mar 2018 12:48:26 -0400 Received: from mga02.intel.com ([134.134.136.20]:11000 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751623AbeCPQsX (ORCPT ); Fri, 16 Mar 2018 12:48:23 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Mar 2018 09:48:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,316,1517904000"; d="scan'208";a="35628619" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga003.jf.intel.com with ESMTP; 16 Mar 2018 09:48:20 -0700 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 16 Mar 2018 09:48:20 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 16 Mar 2018 09:48:20 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.235]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.166]) with mapi id 14.03.0319.002; Sat, 17 Mar 2018 00:48:16 +0800 From: "Liang, Kan" To: "tglx@linutronix.de" , "peterz@infradead.org" , "mingo@redhat.com" , "linux-kernel@vger.kernel.org" CC: "acme@kernel.org" , "eranian@google.com" , "ak@linux.intel.com" Subject: RE: [PATCH V6 1/8] perf/x86/intel/uncore: customized event_read for client IMC uncore Thread-Topic: [PATCH V6 1/8] perf/x86/intel/uncore: customized event_read for client IMC uncore Thread-Index: AQHTlhkaoCoTgM88UUO7Y8nj83N3G6PTYERw Date: Fri, 16 Mar 2018 16:48:16 +0000 Message-ID: <37D7C6CF3E00A74B8858931C1DB2F07753854C10@SHSMSX103.ccr.corp.intel.com> References: <1516911228-5293-1-git-send-email-kan.liang@intel.com> In-Reply-To: <1516911228-5293-1-git-send-email-kan.liang@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTE3NWM1YzItM2Q1Ni00NzI2LTg1ODMtNjE3Mzc0ZDk0ZjE0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6InhWVDcwMDliOXlOZVlRXC9HRVFcL2d5SGd2bEZqRjlpNFdRYVVvcmpwWWFHaz0ifQ== x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Peter, Any comments for the patch set? Thanks, Kan > > From: Kan Liang > > There are two free running counters for client IMC uncore. The custom > event_init() function hardcode their index to 'UNCORE_PMC_IDX_FIXED' and > 'UNCORE_PMC_IDX_FIXED + 1'. To support the 'UNCORE_PMC_IDX_FIXED + > 1' > case, the generic uncore_perf_event_update is obscurely hacked. > The code quality issue will bring problem when new counter index is > introduced into generic code. For example, free running counter index. > > Introduce customized event_read function for client IMC uncore. > The customized function is exactly copied from previous generic > uncore_pmu_event_read. > The 'UNCORE_PMC_IDX_FIXED + 1' case will be isolated for client IMC uncore > only. > > Reviewed-by: Thomas Gleixner > Signed-off-by: Kan Liang > --- > > Change since V5: > - Add reviewed-by > > arch/x86/events/intel/uncore_snb.c | 33 > +++++++++++++++++++++++++++++++-- > 1 file changed, 31 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/events/intel/uncore_snb.c > b/arch/x86/events/intel/uncore_snb.c > index aee5e84..df53521 100644 > --- a/arch/x86/events/intel/uncore_snb.c > +++ b/arch/x86/events/intel/uncore_snb.c > @@ -450,6 +450,35 @@ static void snb_uncore_imc_event_start(struct > perf_event *event, int flags) > uncore_pmu_start_hrtimer(box); > } > > +static void snb_uncore_imc_event_read(struct perf_event *event) { > + struct intel_uncore_box *box = uncore_event_to_box(event); > + u64 prev_count, new_count, delta; > + int shift; > + > + /* > + * There are two free running counters in IMC. > + * The index for the second one is hardcoded to > + * UNCORE_PMC_IDX_FIXED + 1. > + */ > + if (event->hw.idx >= UNCORE_PMC_IDX_FIXED) > + shift = 64 - uncore_fixed_ctr_bits(box); > + else > + shift = 64 - uncore_perf_ctr_bits(box); > + > + /* the hrtimer might modify the previous event value */ > +again: > + prev_count = local64_read(&event->hw.prev_count); > + new_count = uncore_read_counter(box, event); > + if (local64_xchg(&event->hw.prev_count, new_count) != prev_count) > + goto again; > + > + delta = (new_count << shift) - (prev_count << shift); > + delta >>= shift; > + > + local64_add(delta, &event->count); > +} > + > static void snb_uncore_imc_event_stop(struct perf_event *event, int flags) { > struct intel_uncore_box *box = uncore_event_to_box(event); @@ - > 472,7 +501,7 @@ static void snb_uncore_imc_event_stop(struct perf_event > *event, int flags) > * Drain the remaining delta count out of a event > * that we are disabling: > */ > - uncore_perf_event_update(box, event); > + snb_uncore_imc_event_read(event); > hwc->state |= PERF_HES_UPTODATE; > } > } > @@ -534,7 +563,7 @@ static struct pmu snb_uncore_imc_pmu = { > .del = snb_uncore_imc_event_del, > .start = snb_uncore_imc_event_start, > .stop = snb_uncore_imc_event_stop, > - .read = uncore_pmu_event_read, > + .read = snb_uncore_imc_event_read, > }; > > static struct intel_uncore_ops snb_uncore_imc_ops = { > -- > 2.7.4