Received: by 10.213.65.68 with SMTP id h4csp368124imn; Tue, 20 Mar 2018 05:36:01 -0700 (PDT) X-Google-Smtp-Source: AG47ELsKxyBhqwxceFJ39ulO2nOJYqn/wYYreg5y+xC1/J4LNxMV4gQkLNKxHG4NrLa4a9T3HZXF X-Received: by 2002:a17:902:bc88:: with SMTP id bb8-v6mr4627039plb.214.1521549361880; Tue, 20 Mar 2018 05:36:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521549361; cv=none; d=google.com; s=arc-20160816; b=KDNbXK9437+qFN3rlJeYNpeFhYskHxArFJoMOeG/N78j2fhGpvnfmipJbJMbkG3u+3 0lRM/FNQZdYm6cABC3MQnm2tpuXP0SxPdFSeZHx/9JPEIU9CbewUATFpdyTba8LaTA0l 9gaqmgXLxEFTQVwaFgSXCifftVe0Off+P7k4Cw+1SVidkpzHDSTwWJt7ga7oOcKXkwFl KfRVZM4OMdZQ6sY9s1FT9Cd7PwJsyDP+sPczMmSojPoCTjMxjqfrp3RJ38fMldRe8geX aYTKsAbZNmwg1YfELecwaZXVULhz8a1yLtrP5e/7GKBvEsK5RPTvo5zUY/kqbw6JW9kV 07QQ== 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=2w1EE4Z3cv20ok+Az9v2BcrnPHyYdD3uYfcT+jrHuKA=; b=z/0e0dvLUBDsDf83ePIpwW00Og/8QPy25GzDOXeT0ekg7qhDMKXxELbRkZP8FgqLRO 0u68Hahu7WVl+a1kfctXXLK5lV1/CKsev9/oa89Kji37x7eFrLFu5QJDm41WYpWmBZMt scqleULs9uHK/bjW1NTz7tQfsgOVIZIzAKw6yxXxx1cvTRGbvDqsTewkDoqFIGoQtZLe AjcEYU5coXpk3dBC2dy2VCpK+POSEBmec5BzZSeNGM01vnOP8Gfj0ePdq+8o8l35Q2k3 bSGBuyrnzlf3DULNUGBUONmSHjiTuMnO8hJpTJLsidtoKGxPtcejJvk9J6ED3ZppSiel kP/Q== 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 w130si1166481pfd.280.2018.03.20.05.35.47; Tue, 20 Mar 2018 05:36:01 -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 S1753346AbeCTMeP (ORCPT + 99 others); Tue, 20 Mar 2018 08:34:15 -0400 Received: from mga18.intel.com ([134.134.136.126]:3060 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753263AbeCTMd3 (ORCPT ); Tue, 20 Mar 2018 08:33:29 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Mar 2018 05:33:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,335,1517904000"; d="scan'208";a="209781518" Received: from otc-lr-04.jf.intel.com ([10.54.39.128]) by orsmga005.jf.intel.com with ESMTP; 20 Mar 2018 05:33:28 -0700 From: kan.liang@intel.com To: peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: acme@kernel.org, eranian@google.com, ak@linux.intel.com, Kan Liang Subject: [PATCH V7 6/8] perf/x86/intel/uncore: Support IIO free running counters on SKX Date: Tue, 20 Mar 2018 05:32:43 -0700 Message-Id: <1521549165-6216-6-git-send-email-kan.liang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521549165-6216-1-git-send-email-kan.liang@intel.com> References: <1521549165-6216-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 As of Skylake Server, there are a number of free-running counters in each IIO Box that collect counts for per box IO clocks and per Port Input/Output x BW/Utilization. Add a new PMU for these free-running counters. Don't let them share with the GP counters of IIO box. Otherwise, it will result in some (probably) unexpected scheduling artifacts. The free running counter is read-only and always active. Counting will be suspended only when the IIO Box is powered down. There are three types of IIO free running counters on Skylake server, IO CLOCKS counter, BANDWIDTH counters and UTILIZATION counters. IO CLOCKS counter is to count IO clocks. BANDWIDTH counters are to count inbound(PCIe->CPU)/outbound(CPU->PCIe) bandwidth. UTILIZATION counters are to count input/output utilization. The bit width of the free running counters is 36-bits. Signed-off-by: Kan Liang --- Changes since V6: - Add a new PMU for IIO free-running counters. arch/x86/events/intel/uncore_snbep.c | 82 ++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index 22ec65b..d6b302e 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -3484,6 +3484,87 @@ static struct intel_uncore_type skx_uncore_iio = { .format_group = &skx_uncore_iio_format_group, }; +enum perf_uncore_iio_freerunning_type_id { + SKX_IIO_MSR_IOCLK = 0, + SKX_IIO_MSR_BW = 1, + SKX_IIO_MSR_UTIL = 2, + + SKX_IIO_FREERUNNING_TYPE_MAX, +}; + + +static struct freerunning_counters skx_iio_freerunning[] = { + [SKX_IIO_MSR_IOCLK] = { 0xa45, 0x1, 0x20, 1, 36 }, + [SKX_IIO_MSR_BW] = { 0xb00, 0x1, 0x10, 8, 36 }, + [SKX_IIO_MSR_UTIL] = { 0xb08, 0x1, 0x10, 8, 36 }, +}; + +static struct uncore_event_desc skx_uncore_iio_freerunning_events[] = { + /* Free-Running IO CLOCKS Counter */ + INTEL_UNCORE_EVENT_DESC(ioclk, "event=0xff,umask=0x10"), + /* Free-Running IIO BANDWIDTH Counters */ + INTEL_UNCORE_EVENT_DESC(bw_in_port0, "event=0xff,umask=0x20"), + INTEL_UNCORE_EVENT_DESC(bw_in_port0.scale, "3.814697266e-6"), + INTEL_UNCORE_EVENT_DESC(bw_in_port0.unit, "MiB"), + INTEL_UNCORE_EVENT_DESC(bw_in_port1, "event=0xff,umask=0x21"), + INTEL_UNCORE_EVENT_DESC(bw_in_port1.scale, "3.814697266e-6"), + INTEL_UNCORE_EVENT_DESC(bw_in_port1.unit, "MiB"), + INTEL_UNCORE_EVENT_DESC(bw_in_port2, "event=0xff,umask=0x22"), + INTEL_UNCORE_EVENT_DESC(bw_in_port2.scale, "3.814697266e-6"), + INTEL_UNCORE_EVENT_DESC(bw_in_port2.unit, "MiB"), + INTEL_UNCORE_EVENT_DESC(bw_in_port3, "event=0xff,umask=0x23"), + INTEL_UNCORE_EVENT_DESC(bw_in_port3.scale, "3.814697266e-6"), + INTEL_UNCORE_EVENT_DESC(bw_in_port3.unit, "MiB"), + INTEL_UNCORE_EVENT_DESC(bw_out_port0, "event=0xff,umask=0x24"), + INTEL_UNCORE_EVENT_DESC(bw_out_port0.scale, "3.814697266e-6"), + INTEL_UNCORE_EVENT_DESC(bw_out_port0.unit, "MiB"), + INTEL_UNCORE_EVENT_DESC(bw_out_port1, "event=0xff,umask=0x25"), + INTEL_UNCORE_EVENT_DESC(bw_out_port1.scale, "3.814697266e-6"), + INTEL_UNCORE_EVENT_DESC(bw_out_port1.unit, "MiB"), + INTEL_UNCORE_EVENT_DESC(bw_out_port2, "event=0xff,umask=0x26"), + INTEL_UNCORE_EVENT_DESC(bw_out_port2.scale, "3.814697266e-6"), + INTEL_UNCORE_EVENT_DESC(bw_out_port2.unit, "MiB"), + INTEL_UNCORE_EVENT_DESC(bw_out_port3, "event=0xff,umask=0x27"), + INTEL_UNCORE_EVENT_DESC(bw_out_port3.scale, "3.814697266e-6"), + INTEL_UNCORE_EVENT_DESC(bw_out_port3.unit, "MiB"), + /* Free-running IIO UTILIZATION Counters */ + INTEL_UNCORE_EVENT_DESC(util_in_port0, "event=0xff,umask=0x30"), + INTEL_UNCORE_EVENT_DESC(util_out_port0, "event=0xff,umask=0x31"), + INTEL_UNCORE_EVENT_DESC(util_in_port1, "event=0xff,umask=0x32"), + INTEL_UNCORE_EVENT_DESC(util_out_port1, "event=0xff,umask=0x33"), + INTEL_UNCORE_EVENT_DESC(util_in_port2, "event=0xff,umask=0x34"), + INTEL_UNCORE_EVENT_DESC(util_out_port2, "event=0xff,umask=0x35"), + INTEL_UNCORE_EVENT_DESC(util_in_port3, "event=0xff,umask=0x36"), + INTEL_UNCORE_EVENT_DESC(util_out_port3, "event=0xff,umask=0x37"), + { /* end: all zeroes */ }, +}; + +static struct intel_uncore_ops skx_uncore_iio_freerunning_ops = { + .read_counter = uncore_msr_read_counter, +}; + +static struct attribute *skx_uncore_iio_freerunning_formats_attr[] = { + &format_attr_event.attr, + &format_attr_umask.attr, + NULL, +}; + +static const struct attribute_group skx_uncore_iio_freerunning_format_group = { + .name = "format", + .attrs = skx_uncore_iio_freerunning_formats_attr, +}; + +static struct intel_uncore_type skx_uncore_iio_free_running = { + .name = "iio_free_running", + .num_counters = 17, + .num_boxes = 6, + .num_freerunning_types = SKX_IIO_FREERUNNING_TYPE_MAX, + .freerunning = skx_iio_freerunning, + .ops = &skx_uncore_iio_freerunning_ops, + .event_descs = skx_uncore_iio_freerunning_events, + .format_group = &skx_uncore_iio_freerunning_format_group, +}; + static struct attribute *skx_uncore_formats_attr[] = { &format_attr_event.attr, &format_attr_umask.attr, @@ -3557,6 +3638,7 @@ static struct intel_uncore_type *skx_msr_uncores[] = { &skx_uncore_ubox, &skx_uncore_chabox, &skx_uncore_iio, + &skx_uncore_iio_free_running, &skx_uncore_irp, &skx_uncore_pcu, NULL, -- 2.7.4