Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp383417ybb; Fri, 20 Mar 2020 00:31:53 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvUE0R7K+JnzgNhy+6IcBM29jd5n4M7rxAXUok2dvVYAXnjF808HXvjpVJRy2ylstu/3qSo X-Received: by 2002:a9d:6a0b:: with SMTP id g11mr5279008otn.31.1584689513844; Fri, 20 Mar 2020 00:31:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584689513; cv=none; d=google.com; s=arc-20160816; b=dS5ydHOPXaPTc1CpVDUkUYVwjb1mOBrowkSY/ITzVbN2sjQGLjTT8BR77IILdVZAfu 0uu5KUZ4p8WtER/QMIU845SSqFLV/Rbu3eomz0hVfmGZX8MxcOqbJLVpyQb0zacw4csR HfgDmYYK8HQidzeTCgayK6ui2fC4iHXwuyWgrD/mCmxEE1pPDvB9nQP0i11vGfzgpi1X r70Smv8MDg9b83H7knUeGOy06q7ckwKRj75MmfWTPmvi8UP/c7ArZLj29/8L9pu28sJN CC+YDaFRwXz4e1zTf4pY/FvRP10quBT3SyyeaCxU8nhqp7/gNlFWukiurpnqxkJPzCap MVuw== 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 :ironport-sdr:ironport-sdr; bh=ZzwwU06i4Zc0NAZoBtETyi9JDHgn2XjC8kQFMJI0fKk=; b=KXg1uDrfwfoSoB+yAioJPMXQu5x6j2MNeJMjcaLa0i1f0amLnh9mpTCIRHA7y//Tg/ m0gnD/Q2a23CwBNax/tOmnMDgwd26iZboXbEFqr38gRkih8unnTXdGU0IZ/UWaUiFtDh QBPZklOvQ/gAFDdkR5vWETE9GjpaYKXPLy95hkuPglvuobaSq8JX3xnyvSYKVnWppYZ0 Ue4UNc4MwP6v/mx3y9wPZNkiHuxzFbCl81rlayf90SXGO0bQEz7BpCIle57hFSgmqPkA zWFCHeZAAFx8i1P5mjoX+UuEMesnyi+HGbOiWuBZNBuOH4g0WNpxlXH6dYdtDaPsdwVX iNQA== 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 s6si2417445oig.131.2020.03.20.00.31.41; Fri, 20 Mar 2020 00:31: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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726867AbgCTHbU (ORCPT + 99 others); Fri, 20 Mar 2020 03:31:20 -0400 Received: from mga01.intel.com ([192.55.52.88]:44358 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725802AbgCTHbU (ORCPT ); Fri, 20 Mar 2020 03:31:20 -0400 IronPort-SDR: 102bjdcHFkV2T2I9UCd8/1w2vmdjBE23Mm2AS23r6xOz1Xj1gn7QMGKC1WvcLNqrcH5pVKvXSz SLY21kcOFdzg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2020 00:31:19 -0700 IronPort-SDR: cy1hWFSXhfRiPfUMkBPoltvmi00Z3SP0fxLIkFxqA0Edl9RmrJ8r55+TJS/0AoUON03aULPUza MMMtSMrNCaSQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,283,1580803200"; d="scan'208";a="234429357" Received: from nntpdsd52-183.inn.intel.com ([10.125.52.183]) by orsmga007.jf.intel.com with ESMTP; 20 Mar 2020 00:31:15 -0700 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 v8 1/3] perf x86: Infrastructure for exposing an Uncore unit to PMON mapping Date: Fri, 20 Mar 2020 10:31:08 +0300 Message-Id: <20200320073110.4761-2-roman.sudarikov@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20200320073110.4761-1-roman.sudarikov@linux.intel.com> References: <20200320073110.4761-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: ls /sys/devices/uncore__/die* 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: Optional callbacks added to struct intel_uncore_type to discover and map Uncore units to PMONs: int (*set_mapping)(struct intel_uncore_type *type) void (*cleanup_mapping)(struct intel_uncore_type *type) 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 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 Reviewed-by: Kan Liang --- arch/x86/events/intel/uncore.c | 8 ++++++++ arch/x86/events/intel/uncore.h | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c index 86467f85c383..fb693608c223 100644 --- a/arch/x86/events/intel/uncore.c +++ b/arch/x86/events/intel/uncore.c @@ -843,10 +843,12 @@ static int uncore_pmu_register(struct intel_uncore_pmu *pmu) .read = uncore_pmu_event_read, .module = THIS_MODULE, .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .attr_update = pmu->type->attr_update, }; } else { pmu->pmu = *pmu->type->pmu; pmu->pmu.attr_groups = pmu->type->attr_groups; + pmu->pmu.attr_update = pmu->type->attr_update; } if (pmu->type->num_boxes == 1) { @@ -887,6 +889,9 @@ static void uncore_type_exit(struct intel_uncore_type *type) struct intel_uncore_pmu *pmu = type->pmus; int i; + if (type->cleanup_mapping) + type->cleanup_mapping(type); + if (pmu) { for (i = 0; i < type->num_boxes; i++, pmu++) { uncore_pmu_unregister(pmu); @@ -954,6 +959,9 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid) type->pmu_group = &uncore_pmu_attr_group; + if (type->set_mapping) + type->set_mapping(type); + return 0; err: diff --git a/arch/x86/events/intel/uncore.h b/arch/x86/events/intel/uncore.h index bbfdaa720b45..d41f8874adc5 100644 --- a/arch/x86/events/intel/uncore.h +++ b/arch/x86/events/intel/uncore.h @@ -72,7 +72,13 @@ struct intel_uncore_type { struct uncore_event_desc *event_descs; struct freerunning_counters *freerunning; const struct attribute_group *attr_groups[4]; + const struct attribute_group **attr_update; struct pmu *pmu; /* for custom pmu ops */ + /* PMON's topologies */ + u64 *topology; + /* mapping Uncore units to PMON ranges */ + int (*set_mapping)(struct intel_uncore_type *type); + void (*cleanup_mapping)(struct intel_uncore_type *type); }; #define pmu_group attr_groups[0] -- 2.19.1