Received: by 10.223.164.221 with SMTP id h29csp938895wrb; Tue, 24 Oct 2017 11:58:53 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Tol4cqVLL1glDyBI4AnpPlA8SG0w9wyHqpSuZ3OjYb8SmgFXypWHrteuH1wlNYi9De0Dc7 X-Received: by 10.99.64.5 with SMTP id n5mr15391999pga.244.1508871533083; Tue, 24 Oct 2017 11:58:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508871533; cv=none; d=google.com; s=arc-20160816; b=SOshX8nwNfQnbxrxMmHlX59rVm5l8ydUvPTxKgyWlmQkjS1uzsnA4roIOfKeWjqDJ3 gzsKr4qZy2msJ4tgGrkI/CcWeX3DU6uOPV5GsVL3HsU8q9RxgmYWF6TVfJ8DX0b7Lr3D 9L1rfFFtO6tFQoMdPZOYAvFG+LIi320P6NJ6gcZqjHySE+PK+KM+wVd5jERD0JWrVaqv 54MP645XYyqiu+eeODQmNK6xU+t1zI4JFEpqr7QUUwPQnA4yRwP12pV7ep+CNHE5rlx+ qXB20pUzx9HP6EV4qC1aByGuW575VIQLsE1nN3Too6BJ8XtQfOBsP2A+Z+T9KLWGnSGW MA2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=fMwin90QnYg8a8ueFtAWAO8KwFp4f0MT5Q4ngXvq+A0=; b=M9ZkFP/sDdYIWWGKC5MKUsamkb30zkd38ap0UEEwt0NQSPk3PXQa+iAPvLYh/lxecr PKtDlnFUdOKBJ08OZ2Wb8vHfY51nd8i1DwZR57ookN4ClW0c+NtiXFJ+tMsMcBxs29vS 2+QYmOJBIbr/+fH9lMufTNeddIxssZ29AL3kXgX4E+z2yjRxWaxWmkrl/5BVnj4WHPT0 CkZhsJY2/5RhhSoh39k/803isQW9m+RxSSaJ35S1RUGKJSg1ScNy73CaGakkH5Oux3Ff 6PK/NS88KFyyCIPl6m4S3ggREcCtaCK8nhDdrpxF/JdT+eHQRIz89CVD65yvMrSGGqnF G/kg== 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 d10si538342pgo.497.2017.10.24.11.58.39; Tue, 24 Oct 2017 11:58: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 S932210AbdJXS5m (ORCPT + 99 others); Tue, 24 Oct 2017 14:57:42 -0400 Received: from mga09.intel.com ([134.134.136.24]:55073 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751591AbdJXS5g (ORCPT ); Tue, 24 Oct 2017 14:57:36 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Oct 2017 11:57:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,429,1503385200"; d="scan'208";a="1234752774" Received: from otc-lr-04.jf.intel.com ([10.54.39.15]) by fmsmga002.fm.intel.com with ESMTP; 24 Oct 2017 11:57:31 -0700 From: kan.liang@intel.com 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, Kan Liang Subject: [PATCH V3 1/5] perf/x86/intel/uncore: customized pmu event read for client IMC uncore Date: Tue, 24 Oct 2017 04:05:20 -0700 Message-Id: <1508843124-4081-1-git-send-email-kan.liang@intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang The client IMC uncore obscurely hack the generic uncore_perf_event_update to support the 'UNCORE_PMC_IDX_FIXED + 1' case. The code quality issue will bring problem when new counter index is introduced into generic code. For example, free running counter. Introduce customized pmu event_read function for client IMC uncore. The customized function is exactly copied from previous generic uncore_pmu_event_read. Correct the fixed counter checking code in uncore_perf_event_update. Signed-off-by: Kan Liang --- Change since V2: - New patch to fix event->hw.idx >= UNCORE_PMC_IDX_FIXED in generic code. Temporarily add customized pmu event_read function. Patch 5/5 will clean up the customized event_* functions for client IMC uncore arch/x86/events/intel/uncore.c | 2 +- arch/x86/events/intel/uncore_snb.c | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c index 1c5390f..3b8cd88 100644 --- a/arch/x86/events/intel/uncore.c +++ b/arch/x86/events/intel/uncore.c @@ -218,7 +218,7 @@ void uncore_perf_event_update(struct intel_uncore_box *box, struct perf_event *e u64 prev_count, new_count, delta; int shift; - if (event->hw.idx >= UNCORE_PMC_IDX_FIXED) + if (event->hw.idx == UNCORE_PMC_IDX_FIXED) shift = 64 - uncore_fixed_ctr_bits(box); else shift = 64 - uncore_perf_ctr_bits(box); diff --git a/arch/x86/events/intel/uncore_snb.c b/arch/x86/events/intel/uncore_snb.c index db1127c..9d5cd3f 100644 --- a/arch/x86/events/intel/uncore_snb.c +++ b/arch/x86/events/intel/uncore_snb.c @@ -498,6 +498,30 @@ static void snb_uncore_imc_event_del(struct perf_event *event, int flags) snb_uncore_imc_event_stop(event, PERF_EF_UPDATE); } +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; + + 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); +} + int snb_pci2phy_map_init(int devid) { struct pci_dev *dev = NULL; @@ -533,7 +557,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 From 1582976266940809418@xxx Thu Nov 02 17:30:09 +0000 2017 X-GM-THRID: 1582976266940809418 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread