Received: by 10.223.164.221 with SMTP id h29csp2586452wrb; Thu, 2 Nov 2017 13:34:54 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QgUocDr8zQb7VPyQGrHcV/Dkd0hAkdaiVrByX2sUXEbV1dTjOPpVXvuz7XIr0UjNnt+kp+ X-Received: by 10.101.78.201 with SMTP id w9mr4732422pgq.402.1509654894282; Thu, 02 Nov 2017 13:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509654894; cv=none; d=google.com; s=arc-20160816; b=V45ujekNRFzSLpBH6tkmKtTBj7eX2eFnbjIa6UA5sewbNhWcfg2r2L24l00ghJk99A EF1Z5FWH6BHk2GGk1NSaVUHw2oy2tudbBF3l6eTDmyn4QM7akymsR1yl/RSjVfWaXSbq J+Llm4GlXg51khbAEMFBm6FZVKFN3P3GFjtSD0/Ftfu1/ImWand0V+FvMFthClRzLmo0 AhOeqyJpWt6nldAoY/H6BBrPYkxYMWtJXny4VnXPTbY362u75yo9lKBjeP+oTDhEvnvU bkU9kbCYpx1BEqike5gkXZwcXri3Gfzv+ymEtLk/ResGxmNoGaZqdI8fbBxNQDSJkFFx NiNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=VURZt7PqvLv6MbJXOqp5uwGpzO4ypeYzcLc0qSOsmdM=; b=UNjEJWfSffNevcmI+/VBivJ9BZknvbs+DH6aiUr6aOrnfZOpbjxXRtPg3d5BQ+PS4o EQalcpWvSDtbnXgAhrgR1rotQjfnOQbxUqEMhIYUoqlD8gwDNC9twUBQvzXHUqyhkduM VPECejdAKVL9UZumWGr9oEQiMksSJbiA60//apRabj1ZgrXWISuf3p7D0NIcBJBq3vtJ CU6puYz9XzOXYOfo8EoUwP1bXuTpZ9/1NLozOdN2J2Rci2OkqLJrZXFHiXvtowU/8zud Pv+NsiAIS0EyqJJUVn+qweLGdpg+H4Dj7ciIGDBLD2QQfHKhSKHw4pjRGkocfD6Q5qne 6HOw== 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 j16si4368155pga.622.2017.11.02.13.34.40; Thu, 02 Nov 2017 13:34:54 -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 S934471AbdKBUbb (ORCPT + 99 others); Thu, 2 Nov 2017 16:31:31 -0400 Received: from mga11.intel.com ([192.55.52.93]:31294 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932241AbdKBUaZ (ORCPT ); Thu, 2 Nov 2017 16:30:25 -0400 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Nov 2017 13:30:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,335,1505804400"; d="scan'208";a="145287057" Received: from otc-lr-04.jf.intel.com ([10.54.39.138]) by orsmga004.jf.intel.com with ESMTP; 02 Nov 2017 13:30:22 -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 V4 8/8] perf/x86/intel/uncore: clean up client IMC uncore Date: Thu, 2 Nov 2017 13:29:53 -0700 Message-Id: <1509654593-4446-8-git-send-email-kan.liang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509654593-4446-1-git-send-email-kan.liang@intel.com> References: <1509654593-4446-1-git-send-email-kan.liang@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang The counters in client IMC uncore are free running counters, not fixed counters. It should be corrected. The new infrastructure for free running counter should be applied. Introduce free running counter type SNB_PCI_UNCORE_IMC_DATA for data read and data write counters. Keep the custom event_init() function compatible with old event encoding. Clean up other custom event_* functions. Signed-off-by: Kan Liang --- No changes since V3 arch/x86/events/intel/uncore_snb.c | 132 ++++++------------------------------- 1 file changed, 20 insertions(+), 112 deletions(-) diff --git a/arch/x86/events/intel/uncore_snb.c b/arch/x86/events/intel/uncore_snb.c index b6d0d72..29473e9 100644 --- a/arch/x86/events/intel/uncore_snb.c +++ b/arch/x86/events/intel/uncore_snb.c @@ -284,6 +284,15 @@ static struct uncore_event_desc snb_uncore_imc_events[] = { #define SNB_UNCORE_PCI_IMC_DATA_WRITES_BASE 0x5054 #define SNB_UNCORE_PCI_IMC_CTR_BASE SNB_UNCORE_PCI_IMC_DATA_READS_BASE +enum perf_snb_uncore_imc_freerunning_types { + SNB_PCI_UNCORE_IMC_DATA = 0, + SNB_PCI_UNCORE_IMC_FREERUNNING_TYPE_MAX, +}; + +static struct freerunning_counters snb_uncore_imc_freerunning[] = { + [SNB_PCI_UNCORE_IMC_DATA] = { SNB_UNCORE_PCI_IMC_DATA_READS_BASE, 0x4, 0x0, 2, 32 }, +}; + static struct attribute *snb_uncore_imc_formats_attr[] = { &format_attr_event.attr, NULL, @@ -340,9 +349,8 @@ static u64 snb_uncore_imc_read_counter(struct intel_uncore_box *box, struct perf } /* - * custom event_init() function because we define our own fixed, free - * running counters, so we do not want to conflict with generic uncore - * logic. Also simplifies processing + * Keep the custom event_init() function compatible with old event + * encoding for free running counters. */ static int snb_uncore_imc_event_init(struct perf_event *event) { @@ -404,11 +412,11 @@ static int snb_uncore_imc_event_init(struct perf_event *event) switch (cfg) { case SNB_UNCORE_PCI_IMC_DATA_READS: base = SNB_UNCORE_PCI_IMC_DATA_READS_BASE; - idx = UNCORE_PMC_IDX_FIXED; + idx = UNCORE_PMC_IDX_FREERUNNING; break; case SNB_UNCORE_PCI_IMC_DATA_WRITES: base = SNB_UNCORE_PCI_IMC_DATA_WRITES_BASE; - idx = UNCORE_PMC_IDX_FIXED + 1; + idx = UNCORE_PMC_IDX_FREERUNNING; break; default: return -EINVAL; @@ -429,104 +437,6 @@ static int snb_uncore_imc_hw_config(struct intel_uncore_box *box, struct perf_ev return 0; } -static void snb_uncore_imc_event_start(struct perf_event *event, int flags) -{ - struct intel_uncore_box *box = uncore_event_to_box(event); - u64 count; - - if (WARN_ON_ONCE(!(event->hw.state & PERF_HES_STOPPED))) - return; - - event->hw.state = 0; - box->n_active++; - - list_add_tail(&event->active_entry, &box->active_list); - - count = snb_uncore_imc_read_counter(box, event); - local64_set(&event->hw.prev_count, count); - - if (box->n_active == 1) - 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); - struct hw_perf_event *hwc = &event->hw; - - if (!(hwc->state & PERF_HES_STOPPED)) { - box->n_active--; - - WARN_ON_ONCE(hwc->state & PERF_HES_STOPPED); - hwc->state |= PERF_HES_STOPPED; - - list_del(&event->active_entry); - - if (box->n_active == 0) - uncore_pmu_cancel_hrtimer(box); - } - - if ((flags & PERF_EF_UPDATE) && !(hwc->state & PERF_HES_UPTODATE)) { - /* - * Drain the remaining delta count out of a event - * that we are disabling: - */ - snb_uncore_imc_event_read(event); - hwc->state |= PERF_HES_UPTODATE; - } -} - -static int snb_uncore_imc_event_add(struct perf_event *event, int flags) -{ - struct intel_uncore_box *box = uncore_event_to_box(event); - struct hw_perf_event *hwc = &event->hw; - - if (!box) - return -ENODEV; - - hwc->state = PERF_HES_UPTODATE | PERF_HES_STOPPED; - if (!(flags & PERF_EF_START)) - hwc->state |= PERF_HES_ARCH; - - snb_uncore_imc_event_start(event, 0); - - return 0; -} - -static void snb_uncore_imc_event_del(struct perf_event *event, int flags) -{ - snb_uncore_imc_event_stop(event, PERF_EF_UPDATE); -} - int snb_pci2phy_map_init(int devid) { struct pci_dev *dev = NULL; @@ -558,11 +468,11 @@ int snb_pci2phy_map_init(int devid) static struct pmu snb_uncore_imc_pmu = { .task_ctx_nr = perf_invalid_context, .event_init = snb_uncore_imc_event_init, - .add = snb_uncore_imc_event_add, - .del = snb_uncore_imc_event_del, - .start = snb_uncore_imc_event_start, - .stop = snb_uncore_imc_event_stop, - .read = snb_uncore_imc_event_read, + .add = uncore_pmu_event_add, + .del = uncore_pmu_event_del, + .start = uncore_pmu_event_start, + .stop = uncore_pmu_event_stop, + .read = uncore_pmu_event_read, }; static struct intel_uncore_ops snb_uncore_imc_ops = { @@ -580,12 +490,10 @@ static struct intel_uncore_type snb_uncore_imc = { .name = "imc", .num_counters = 2, .num_boxes = 1, - .fixed_ctr_bits = 32, - .fixed_ctr = SNB_UNCORE_PCI_IMC_CTR_BASE, + .num_freerunning_types = SNB_PCI_UNCORE_IMC_FREERUNNING_TYPE_MAX, + .freerunning = snb_uncore_imc_freerunning, .event_descs = snb_uncore_imc_events, .format_group = &snb_uncore_imc_format_group, - .perf_ctr = SNB_UNCORE_PCI_IMC_DATA_READS_BASE, - .event_mask = SNB_UNCORE_PCI_IMC_EVENT_MASK, .ops = &snb_uncore_imc_ops, .pmu = &snb_uncore_imc_pmu, }; -- 2.7.4 From 1582935040401037333@xxx Thu Nov 02 06:34:52 +0000 2017 X-GM-THRID: 1576438722398356278 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread