Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5158141ybl; Tue, 10 Dec 2019 01:17:17 -0800 (PST) X-Google-Smtp-Source: APXvYqzw0nfPtzwAOyFZIgSEdI0QvMINf8aRFJQujrTK2sZZq24vTHBRggjiE6dYcnZgCg8DAoRI X-Received: by 2002:aca:554d:: with SMTP id j74mr3237216oib.92.1575969437573; Tue, 10 Dec 2019 01:17:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575969437; cv=none; d=google.com; s=arc-20160816; b=Ly3DR0FxCEQjau+WebBK93VJ8RxlgfzZXPVlj+XGvD1CCv4TE74deulAhrEqMcwGc9 EHhfEGDJAKFpvpV6jB9IHkQcIrLm0VKv/0oHlswX10WIksiJbMlC+XcKK5tP3OcxBi+v mkcchD2kTyJBwAArj2sg3xJxYOxfkBJDBmdGQIh3tKIbuhS2cicsIjNGDZyY4F/OCs2V YKfNBqJNXJ9lDWGyxuZ4/BbwGA1zEJfk7O2eKSthS9MK1s0ZpoI0xHx47Ntpk2hvVUfd mZbmrm7ShiJQ+IMOaUYvkr5n24/xSIcHufCbC/ho6G9ybGDJBQHMQI52xyVpPJsI6C2J wggA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=+JRv0lqKfodrFxO57Tn+HR/pvUFWVi89UHwbhj29020=; b=eBHo7tvQMQIt4tNPw4apgZZ8GBbs+VlG+8L8Y9fpxze0f498I+3swcrWRtf0INoGLq KNzMJiUAVowMmkE5ywH7g9UzuGVMq5i8goWHWMXO+MuGoDKzciM1xEG9RCfR1516VzPE U9zF1D5QufatEA1zWk4R1SaJZGRs7EfZJDOPphdzPzZsDWI8SGRpC5VnApPguE8Sm1op zCf4OIhY4R4Jc5bQSD+fknHIFRJepVgxUnT06Q6Ok89Aozq7gxGnkNiSeDAgWE33wtui e/GLX1DtlHDjr0ugZvwVVX8vE7awn9bqpvrIDzauvWJnxceGM6XouVQ/uFY1lh/Tc/uq KJeQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v141si1620565oif.161.2019.12.10.01.17.05; Tue, 10 Dec 2019 01:17:17 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727351AbfLJJPA (ORCPT + 99 others); Tue, 10 Dec 2019 04:15:00 -0500 Received: from mga12.intel.com ([192.55.52.136]:29109 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727329AbfLJJO7 (ORCPT ); Tue, 10 Dec 2019 04:14:59 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Dec 2019 01:14:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,299,1571727600"; d="scan'208";a="244777905" Received: from nntpdsd52-183.inn.intel.com ([10.125.52.183]) by fmsmga002.fm.intel.com with ESMTP; 10 Dec 2019 01:14:55 -0800 From: roman.sudarikov@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, eranian@google.com, bgregg@netflix.com, ak@linux.intel.com, kan.liang@linux.intel.com Cc: alexander.antonov@intel.com, roman.sudarikov@linux.intel.com Subject: [PATCH v2 1/3] perf x86: Infrastructure for exposing an Uncore unit to PMON mapping Date: Tue, 10 Dec 2019 12:14:49 +0300 Message-Id: <20191210091451.6054-2-roman.sudarikov@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20191210091451.6054-1-roman.sudarikov@linux.intel.com> References: <20191210091451.6054-1-roman.sudarikov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roman Sudarikov Intel® Xeon® Scalable processor family (code name Skylake-SP) makes significant changes in the integrated I/O (IIO) architecture. The new solution introduces IIO stacks which are responsible for managing traffic between the PCIe domain and the Mesh domain. Each IIO stack has its own PMON block and can handle either DMI port, x16 PCIe root port, MCP-Link or various built-in accelerators. IIO PMON blocks allow concurrent monitoring of I/O flows up to 4 x4 bifurcation within each IIO stack. Software is supposed to program required perf counters within each IIO stack and gather performance data. The tricky thing here is that IIO PMON reports data per IIO stack but users have no idea what IIO stacks are - they only know devices which are connected to the platform. Understanding IIO stack concept to find which IIO stack that particular IO device is connected to, or to identify an IIO PMON block to program for monitoring specific IIO stack assumes a lot of implicit knowledge about given Intel server platform architecture. Usage example: /sys/devices/uncore__/platform_mapping Each Uncore unit type, by its nature, can be mapped to its own context, for example: 1. CHA - each uncore_cha_ is assigned to manage a distinct slice of LLC capacity; 2. UPI - each uncore_upi_ is assigned to manage one link of Intel UPI Subsystem; 3. IIO - each uncore_iio_ is assigned to manage one stack of the IIO module; 4. IMC - each uncore_imc_ is assigned to manage one channel of Memory Controller. Implementation details: Two callbacks added to struct intel_uncore_type to discover and map Uncore units to PMONs: int (*get_topology)(void) int (*set_mapping)(struct intel_uncore_pmu *pmu) Details of IIO Uncore unit mapping to IIO PMON: Each IIO stack is either DMI port, x16 PCIe root port, MCP-Link or various built-in accelerators. For Uncore IIO Unit type, the platform_mapping file holds bus numbers of devices, which can be monitored by that IIO PMON block on each die. Co-developed-by: Alexander Antonov Signed-off-by: Alexander Antonov Signed-off-by: Roman Sudarikov --- arch/x86/events/intel/uncore.c | 26 ++++++++++++++++++++++++++ arch/x86/events/intel/uncore.h | 9 ++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c index 86467f85c383..24e120289018 100644 --- a/arch/x86/events/intel/uncore.c +++ b/arch/x86/events/intel/uncore.c @@ -816,6 +816,15 @@ static ssize_t uncore_get_attr_cpumask(struct device *dev, static DEVICE_ATTR(cpumask, S_IRUGO, uncore_get_attr_cpumask, NULL); +static ssize_t platform_mapping_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct intel_uncore_pmu *pmu = dev_get_drvdata(dev); + + return snprintf(buf, PAGE_SIZE - 1, "%s\n", (char *)pmu->mapping); +} +static DEVICE_ATTR_RO(platform_mapping); + static struct attribute *uncore_pmu_attrs[] = { &dev_attr_cpumask.attr, NULL, @@ -825,6 +834,15 @@ static const struct attribute_group uncore_pmu_attr_group = { .attrs = uncore_pmu_attrs, }; +static struct attribute *mapping_attrs[] = { + &dev_attr_platform_mapping.attr, + NULL, +}; + +static const struct attribute_group uncore_mapping_group = { + .attrs = mapping_attrs, +}; + static int uncore_pmu_register(struct intel_uncore_pmu *pmu) { int ret; @@ -954,6 +972,14 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid) type->pmu_group = &uncore_pmu_attr_group; + /* + * Exposing mapping of Uncore units to corresponding Uncore PMUs + * through /sys/devices/uncore__/platform_mapping + */ + if (type->get_topology && type->set_mapping) + if (!type->get_topology(type) && !type->set_mapping(type)) + type->mapping_group = &uncore_mapping_group; + return 0; err: diff --git a/arch/x86/events/intel/uncore.h b/arch/x86/events/intel/uncore.h index bbfdaa720b45..31008e5cea57 100644 --- a/arch/x86/events/intel/uncore.h +++ b/arch/x86/events/intel/uncore.h @@ -71,13 +71,19 @@ struct intel_uncore_type { struct intel_uncore_ops *ops; struct uncore_event_desc *event_descs; struct freerunning_counters *freerunning; - const struct attribute_group *attr_groups[4]; + const struct attribute_group *attr_groups[5]; struct pmu *pmu; /* for custom pmu ops */ + u64 *topology; + /* finding Uncore units */ + int (*get_topology)(struct intel_uncore_type *type); + /* mapping Uncore units to PMON ranges */ + int (*set_mapping)(struct intel_uncore_type *type); }; #define pmu_group attr_groups[0] #define format_group attr_groups[1] #define events_group attr_groups[2] +#define mapping_group attr_groups[3] struct intel_uncore_ops { void (*init_box)(struct intel_uncore_box *); @@ -99,6 +105,7 @@ struct intel_uncore_pmu { int pmu_idx; int func_id; bool registered; + void *mapping; atomic_t activeboxes; struct intel_uncore_type *type; struct intel_uncore_box **boxes; -- 2.19.1