Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761360AbcLTGk3 (ORCPT ); Tue, 20 Dec 2016 01:40:29 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34497 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754818AbcLTGk0 (ORCPT ); Tue, 20 Dec 2016 01:40:26 -0500 From: Hemant Kumar To: linuxppc-dev@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, Hemant Kumar , Madhavan Srinivasan , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Anton Blanchard , Sukadev Bhattiprolu , Michael Neuling , Stewart Smith , Daniel Axtens , Stephane Eranian Subject: [PATCH v3 0/6] IMC Instrumentation Support Date: Tue, 20 Dec 2016 12:09:40 +0530 X-Mailer: git-send-email 2.7.4 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16122006-0040-0000-0000-000002D9ECCC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16122006-0041-0000-0000-00000BEC2DC0 Message-Id: <1482215986-11783-1-git-send-email-hemant@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-12-20_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1612200104 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5752 Lines: 151 Power 9 has In-Memory-Collection (IMC) infrastructure which contains various Performance Monitoring Units (PMUs) at Nest level (these are on-chip but off-core). These Nest PMU counters are handled by a Nest IMC microcode. This microcode runs in the OCC (On-Chip Controller) complex and its purpose is to program the nest counters, collect the counter data and move the counter data to memory. The IMC infrastructure encapsulates nest (per-chip), core and thread level counters. While the nest IMC PMUs are handled by the nest IMC microcode, the core and thread level PMUs are handled by the Core-HPMC engine. This patchset enables the nest IMC PMUs and is based on the initial work done by Madhavan Srinivasan. "Nest Instrumentation Support" : https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-August/132078.html v1 for this patchset can be found here : https://lwn.net/Articles/705475/ Nest events: Per-chip nest instrumentation provides various per-chip metrics such as memory, powerbus, Xlink and Alink bandwidth. PMU Events' Information: OPAL obtains the Nest PMU and event information from the IMC Catalog and passes on to the kernel via the device tree. The events' information contains : - Event name - Event Offset - Event description and, maybe : - Event scale - Event unit Some PMUs may have a common scale and unit values for all their supported events. For those cases, the scale and unit properties for those events must be inherited from the PMU. The event offset in the memory is where the counter data gets accumulated. The OPAL-side patches are posted upstream : https://lists.ozlabs.org/pipermail/skiboot/2016-November/005552.html The kernel discovers the IMC counters information in the device tree at the "imc-counters" device node which has a compatible field "ibm,opal-in-memory-counters". Parsing of the Events' information: To parse the IMC PMUs and events information, the kernel has to discover the "imc-counters" node and walk through the pmu and event nodes. Here is an excerpt of the dt showing the imc-counters and mcs node: /dts-v1/; [...] imc-counters { imc-nest-offset = <0x320000>; compatible = "ibm,opal-in-memory-counters"; imc-nest-size = <0x30000>; #address-cells = <0x1>; #size-cells = <0x1>; phandle = <0x10000238>; version-id = [00]; mcs0 { compatible = "ibm,imc-counters-chip"; ranges; #address-cells = <0x1>; #size-cells = <0x1>; phandle = <0x10000279>; scale = "1.2207e-4"; unit = "MiB"; event@528 { event-name = "PM_MCS_UP_128B_DATA_XFER_MC0" ; desc = "Total Read Bandwidth seen on both MCS of MC0"; phandle = <0x1000028c>; reg = <0x118 0x8>; }; [...] >From the device tree, the kernel parses the PMUs and their events' information. After parsing the nest IMC PMUs and their events, the PMUs and their attributes are registered in the kernel. Example Usage : # perf list [...] nest_mcs0/PM_MCS_DOWN_128B_DATA_XFER_MC0/ [Kernel PMU event] nest_mcs0/PM_MCS_DOWN_128B_DATA_XFER_MC0_LAST_SAMPLE/ [Kernel PMU event] [...] # perf stat -e "nest_mcs0/PM_MCS_DOWN_128B_DATA_XFER_MC0/" -a --per-socket TODOs: - Add support for Core IMC. - Add support for thread IMC. Comments/feedback/suggestions are welcome. Changelog: v2 -> v3 : - Changed all references for IMA (In-Memory Accumulation) to IMC (In-Memory Collection). v1 -> v2 : - Account for the cases where a PMU can have a common scale and unit values for all its supported events (Patch 3/6). - Fixed a Build error (for maple_defconfig) by enabling imc_pmu.o only for CONFIG_PPC_POWERNV=y (Patch 4/6) - Read from the "event-name" property instead of "name" for an event node (Patch 3/6). Cc: Madhavan Srinivasan Cc: Michael Ellerman Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Anton Blanchard Cc: Sukadev Bhattiprolu Cc: Michael Neuling Cc: Stewart Smith Cc: Daniel Axtens Cc: Stephane Eranian Signed-off-by: Hemant Kumar Hemant Kumar (6): powerpc/powernv: Data structure and macros definitions powerpc/powernv: Autoload IMC device driver module powerpc/powernv: Detect supported IMC units and its events powerpc/perf: Add event attribute and group to IMC pmus powerpc/perf: Generic imc pmu event functions powerpc/perf: IMC pmu cpumask and cpu hotplug support arch/powerpc/include/asm/imc-pmu.h | 74 ++++ arch/powerpc/include/asm/opal-api.h | 3 +- arch/powerpc/include/asm/opal.h | 2 + arch/powerpc/perf/Makefile | 6 +- arch/powerpc/perf/imc-pmu.c | 383 ++++++++++++++++++++ arch/powerpc/platforms/powernv/Makefile | 2 +- arch/powerpc/platforms/powernv/opal-imc.c | 478 +++++++++++++++++++++++++ arch/powerpc/platforms/powernv/opal-wrappers.S | 1 + arch/powerpc/platforms/powernv/opal.c | 13 + 9 files changed, 959 insertions(+), 3 deletions(-) create mode 100644 arch/powerpc/include/asm/imc-pmu.h create mode 100644 arch/powerpc/perf/imc-pmu.c create mode 100644 arch/powerpc/platforms/powernv/opal-imc.c -- 2.7.4