IMC Instrumentation Support
v3 cover IMC Instrumentation Support
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>;
};[...]
Quoted 1 line
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).
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
Signature · 1 line
2.7.4
PATCH v3 1/6 powerpc/powernv: Data structure and macros definitions
Create new header file "imc-pmu.h" to add the data structures and macros needed for IMC pmu support.
--- arch/powerpc/include/asm/imc-pmu.h | 73 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 arch/powerpc/include/asm/imc-pmu.h
arch/powerpc/include/asm/imc-pmu.h new file +73 -0
@@ -0,0 +1,73 @@ +#ifndef PPC_POWERNV_IMC_PMU_DEF_H +#define PPC_POWERNV_IMC_PMU_DEF_H + +/* +* IMC Nest Performance Monitor counter support. +* +* Copyright (C) 2016 Madhavan Srinivasan, IBM Corporation. +* (C) 2016 Hemant K Shaw, IBM Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published +* by the Free Software Foundation. +*/ + +#include <linux/perf_event.h> +#include <linux/slab.h> +#include <linux/of.h> +#include <linux/io.h> +#include <asm/opal.h> + +#define IMC_MAX_CHIPS 32 +#define IMC_MAX_PMUS 32 +#define IMC_MAX_PMU_NAME_LEN 256 + +#define NEST_IMC_ENGINE_START 1 +#define NEST_IMC_ENGINE_STOP 0 +#define NEST_MAX_PAGES 16 + +#define NEST_IMC_PRODUCTION_MODE 1 + +#define IMC_DTB_COMPAT "ibm,opal-in-memory-counters" +#define IMC_DTB_NEST_COMPAT "ibm,imc-counters-chip" + +/* +* Structure to hold per chip specific memory address +* information for nest pmus. Nest Counter data are exported +* in per-chip reserved memory region by the PORE Engine. +*/ +struct perchip_nest_info { +u32 chip_id; +u64 pbase; +u64 vbase[NEST_MAX_PAGES ]; +u64 size; +}; + +/* +* Place holder for nest pmu events and values. +*/ +struct imc_events { +char *ev_name; +char *ev_value; +}; + +/* +* Device tree parser code detects IMC pmu support and +* registers new IMC pmus. This structure will +* hold the pmu functions and attrs for each imc pmu and +* will be referenced at the time of pmu registration. +*/ +struct imc_pmu { +struct pmu pmu; +int domain; +const struct attribute_group *attr_groups[4 ]; +}; + +/* +* Domains for IMC PMUs +*/ +#define IMC_DOMAIN_NEST 1 + +#define UNKNOWN_DOMAIN -1 + +#endif /* PPC_POWERNV_IMC_PMU_DEF_H */
Signature · 1 line
2.7.4
PATCH v3 2/6 powerpc/powernv: Autoload IMC device driver module
In reply to Hemant KumarThis patch does three things :
- Enables "opal.c" to create a platform device for the IMC interface according to the appropriate compatibility string.
- Find the reserved-memory region details from the system device tree and get the base address of HOMER region address for each chip.
- We also get the Nest PMU counter data offsets (in the HOMER region) and their sizes. The offsets for the counters' data are fixed and won't change from chip to chip.
The device tree parsing logic is separated from the PMU creation functions (which is done in subsequent patches). Right now, only Nest units are taken care of.
--- arch/powerpc/platforms/powernv/Makefile | 2 +- arch/powerpc/platforms/powernv/opal-imc.c | 117 ++++++++++++++++++++++++++++++ arch/powerpc/platforms/powernv/opal.c | 13 ++++ 3 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/platforms/powernv/opal-imc.c
arch/powerpc/platforms/powernv/Makefile +1 -1
@@ -2,7 +2,7 @@ obj-y += setup.o opal-wrappers.o opal.o opal-async.o idle.o obj-y += opal-rtc.o opal-nvram.o opal-lpc.o opal-flash.o obj-y += rng.o opal-elog.o opal-dump.o opal-sysparam.o opal-sensor.o obj-y += opal-msglog.o opal-hmi.o opal-power.o opal-irqchip.o -obj-y += opal-kmsg.o +obj-y += opal-kmsg.o opal-imc.o obj-$(CONFIG_SMP) += smp.o subcore.o subcore-asm.o obj-$(CONFIG_PCI) += pci.o pci-ioda.o npu-dma.o
arch/powerpc/platforms/powernv/opal-imc.c new file +117 -0
117 lines not on this page · raw message
arch/powerpc/platforms/powernv/opal.c +13 -0
@@ -30,6 +30,7 @@#include <asm/opal.h> #include <asm/firmware.h> #include <asm/mce.h> +#include <asm/imc-pmu.h> #include "powernv.h"
@@ -650,6 +651,15 @@ static void opal_i2c_create_devs(void)of_platform_device_create (np,NULL ,NULL ); } +static void opal_imc_init_dev (void ) +{ +struct device_node *np; + + np =of_find_compatible_node (NULL ,NULL ,IMC_DTB_COMPAT ); +if (np) +of_platform_device_create (np,NULL ,NULL ); +} +static int kopald (void *unused) {unsigned long timeout =msecs_to_jiffies (opal_heartbeat) +1 ;
@@ -723,6 +733,9 @@ static int __init opal_init(void)/* Setup a heatbeat thread if requested by OPAL */ opal_init_heartbeat (); +/* Detect IMC pmu counters support and create PMUs */ +opal_imc_init_dev (); +/* Create leds platform devices */ leds =of_find_node_by_path ("/ibm,opal/leds" );if (leds) {
Signature · 1 line
2.7.4
PATCH v3 3/6 powerpc/powernv: Detect supported IMC units and its events
In reply to Hemant KumarParse device tree to detect IMC units. Traverse through each IMC unit node to find supported events and corresponding unit/scale files (if any).
Right now, only nest IMC units are supported.
The nest IMC unit event node from device tree will contain the offset in the reserved memory region to get the counter data for a given event. The offsets for the nest events are contained in the "reg" property of the event "node".
Kernel code uses this offset as event configuration value.
Device tree parser code also looks for scale/unit property in the event node and passes on the value as an event attr for perf interface to use in the post processing by the perf tool. Some PMUs may have common scale and unit properties which implies that all events supported by this PMU inherit the scale and unit properties of the PMU itself. For those events, we need to set the common unit and scale values.
For failure to initialize any unit or any event, disable that unit and continue setting up the rest of them.
--- arch/powerpc/platforms/powernv/opal-imc.c | 332 ++++++++++++++++++++++++++++++ 1 file changed, 332 insertions(+)
arch/powerpc/platforms/powernv/opal-imc.c +332 -0
@@ -32,6 +32,337 @@#include <asm/imc-pmu.h> struct perchip_nest_info nest_perchip_info[IMC_MAX_CHIPS ]; +struct imc_pmu *per_nest_pmu_arr[IMC_MAX_PMUS ]; + +static int imc_event_info (char *name,struct imc_events *events) +{ +char *buf; + +/* memory for content */ + buf =kzalloc (IMC_MAX_PMU_NAME_LEN ,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + + events->ev_name = name; + events->ev_value = buf; +return 0 ; +} + +static int imc_event_info_str (struct property *pp,char *name, +struct imc_events *events) +{ +int ret; + + ret =imc_event_info (name, events); +if (ret) +return ret; + +if (!pp->value || (strnlen (pp->value, pp->length) == pp->length) || + (pp->length >IMC_MAX_PMU_NAME_LEN )) +return -EINVAL ; +strncpy (events->ev_value, (const char *)pp->value, pp->length); + +return 0 ; +} + +static int imc_event_info_val (char *name,u32 val, +struct imc_events *events) +{ +int ret; + + ret =imc_event_info (name, events); +if (ret) +return ret; +sprintf (events->ev_value,"event=0x%x" , val); + +return 0 ; +} + +static int set_event_property (struct property *pp,char *event_prop, +struct imc_events *events,char *ev_name) +{ +char *buf; +int ret; + + buf =kzalloc (IMC_MAX_PMU_NAME_LEN ,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + +sprintf (buf,"%s.%s" , ev_name, event_prop); + ret =imc_event_info_str (pp, buf, events); +if (ret) { +kfree (events->ev_name); +kfree (events->ev_value); + } + +return ret; +} + +/* +* imc_events_node_parser: Parse the event node "dev" and assign the parsed +* information to event "events". +* +* Parses the "reg" property of this event. "reg" gives us the event offset. +* Also, parse the "scale" and "unit" properties, if any. +*/ +static int imc_events_node_parser (struct device_node *dev, +struct imc_events *events, +struct property *event_scale, +struct property *event_unit) +{ +struct property *name, *pp; +char *ev_name; +u32 val; +int idx =0 , ret; + +if (!dev) +return -EINVAL ; + +/* +* Loop through each property of an event node +*/ + name =of_find_property (dev,"event-name" ,NULL ); +if (!name) +return -ENODEV ; + +if (!name->value || + (strnlen (name->value, name->length) == name->length) || + (name->length >IMC_MAX_PMU_NAME_LEN )) +return -EINVAL ; + + ev_name =kzalloc (IMC_MAX_PMU_NAME_LEN ,GFP_KERNEL ); +if (!ev_name) +return -ENOMEM ; + +strncpy (ev_name, name->value, name->length); + +/* +* Parse each property of this event node "dev". Property "reg" has +* the offset which is assigned to the event name. Other properties +* like "scale" and "unit" are assigned to event.scale and event.unit +* accordingly. +*/ +for_each_property_of_node (dev, pp) { +/* +* If there is an issue in parsing a single property of +* this event, we just clean up the buffers, but we still +* continue to parse. +*/ +if (strncmp (pp->name,"reg" ,3 ) ==0 ) { +of_property_read_u32 (dev, pp->name, &val); + ret =imc_event_info_val (ev_name, val, &events[idx]); +if (ret) { +kfree (events[idx].ev_name); +kfree (events[idx].ev_value); +continue ; + } +/* +* If the common scale and unit properties available, +* then, assign them to this event +*/ +if (event_scale) { + idx++; + ret =set_event_property (event_scale,"scale" , + &events[idx], + ev_name); +if (ret) +continue ; + idx++; + } +if (event_unit) { + ret =set_event_property (event_unit,"unit" , + &events[idx], + ev_name); +if (ret) +continue ; + } + idx++; + }else if (strncmp (pp->name,"unit" ,4 ) ==0 ) { + ret =set_event_property (pp,"unit" , &events[idx], + ev_name); +if (ret) +continue ; + idx++; + }else if (strncmp (pp->name,"scale" ,5 ) ==0 ) { + ret =set_event_property (pp,"scale" , &events[idx], + ev_name); +if (ret) +continue ; + idx++; + } + } + +return idx; +} + +/* +* imc_get_domain : Returns the domain for pmu "pmu_dev". +*/ +int imc_get_domain (struct device_node *pmu_dev) +{ +if (of_device_is_compatible (pmu_dev,IMC_DTB_NEST_COMPAT )) +return IMC_DOMAIN_NEST ; +else +return UNKNOWN_DOMAIN ; +} + +/* +* get_nr_children : Returns the number of children for a pmu device node. +*/ +static int get_nr_children (struct device_node *pmu_node) +{ +struct device_node *child; +int i =0 ; + +for_each_child_of_node (pmu_node, child) + i++; +return i; +} + +/* +* imc_free_events : Cleanup the "events" list having "nr_entries" entries. +*/ +static void imc_free_events (struct imc_events *events,int nr_entries) +{ +int i; + +/* Nothing to clean, return */ +if (!events) +return ; +for (i =0 ; i < nr_entries; i++) { +kfree (events[i].ev_name); +kfree (events[i].ev_value); + } + +kfree (events); +} + +/* +* imc_pmu_create : Takes the parent device which is the pmu unit and a +* pmu_index as the inputs. +* Allocates memory for the pmu, sets up its domain (NEST or CORE), and +* allocates memory for the events supported by this pmu. Assigns a name for +* the pmu. Calls imc_events_node_parser() to setup the individual events. +* If everything goes fine, it calls, init_imc_pmu() to setup the pmu device +* and register it. +*/ +static int imc_pmu_create (struct device_node *parent,int pmu_index) +{ +struct device_node *ev_node; +struct imc_events *events; +struct imc_pmu *pmu_ptr; +struct property *pp, *scale_pp, *unit_pp; +char *buf; +int idx =0 , ret, nr_children =0 ; + +if (!parent) +return -EINVAL ; + +/* memory for pmu */ + pmu_ptr =kzalloc (sizeof (struct imc_pmu ),GFP_KERNEL ); +if (!pmu_ptr) +return -ENOMEM ; + + pmu_ptr->domain =imc_get_domain (parent); +if (pmu_ptr->domain ==UNKNOWN_DOMAIN ) + goto free_pmu; + +/* Needed for hotplug/migration */ + per_nest_pmu_arr[pmu_index] = pmu_ptr; + +/* +* Get the maximum no. of events in this node. +* Multiply by 3 to account for .scale and .unit properties +* This number suggests the amount of memory needed to setup the +* events for this pmu. +*/ + nr_children =get_nr_children (parent) *3 ; + +/* memory for pmu events */ + events =kzalloc ((sizeof (struct imc_events ) * nr_children), +GFP_KERNEL ); +if (!events) { + ret = -ENOMEM ; + goto free_pmu; + } + + pp =of_find_property (parent,"name" ,NULL ); +if (!pp) { + ret = -ENODEV ; + goto free_events; + } + +if (!pp->value || + (strnlen (pp->value, pp->length) == pp->length) || + (pp->length >IMC_MAX_PMU_NAME_LEN )) { + ret = -EINVAL ; + goto free_events; + } + + buf =kzalloc (IMC_MAX_PMU_NAME_LEN ,GFP_KERNEL ); +if (!buf) { + ret = -ENOMEM ; + goto free_events; + } + +/* Save the name to register it later */ +sprintf (buf,"nest_%s" , (char *)pp->value); + pmu_ptr->pmu.name = (char *)buf; + +/* +* Check if there is a common "scale" and "unit" properties inside +* the PMU node for all the events supported by this PMU. +*/ + scale_pp =of_find_property (parent,"scale" ,NULL ); + unit_pp =of_find_property (parent,"unit" ,NULL ); + +/* Loop through event nodes */ +for_each_child_of_node (parent, ev_node) { + ret =imc_events_node_parser (ev_node, &events[idx], scale_pp, + unit_pp); +if (ret <0 ) { +/* Unable to parse this event */ +if (ret == -ENOMEM ) + goto free_events; +continue ; + } + +/* +* imc_event_node_parser will return number of +* event entries created for this. This could include +* event scale and unit files also. +*/ + idx += ret; + } + +return 0 ; + +free_events: +imc_free_events (events, idx); +free_pmu: +kfree (pmu_ptr); +return ret; +} + +/* +* imc_pmu_setup : Setup the IMC PMUs (children of "parent"). +*/ +static void imc_pmu_setup (struct device_node *parent) +{ +struct device_node *child; +int pmu_count =0 , rc =0 ; + +if (!parent) +return ; + +/* Setup all the IMC pmus */ +for_each_child_of_node (parent, child) { +imc_pmu_create (child, pmu_count); +if (rc) +return ; + pmu_count++; + } +}static int opal_imc_counters_probe (struct platform_device *pdev) {
@@ -93,6 +424,7 @@ static int opal_imc_counters_probe(struct platform_device *pdev) }while (i < (pcni->size /PAGE_SIZE )); } +imc_pmu_setup (imc_dev);return 0 ; err:return -ENODEV ;
Signature · 1 line
2.7.4
PATCH v3 4/6 powerpc/perf: Add event attribute and group to IMC pmus
In reply to Hemant KumarDevice tree IMC driver code parses the IMC units and their events. It passes the information to IMC pmu code which is placed in powerpc/perf as "imc-pmu.c".
This patch creates only event attributes and attribute groups for the IMC pmus.
--- arch/powerpc/perf/Makefile | 6 +- arch/powerpc/perf/imc-pmu.c | 96 +++++++++++++++++++++++++++++++ arch/powerpc/platforms/powernv/opal-imc.c | 12 +++- 3 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 arch/powerpc/perf/imc-pmu.c
arch/powerpc/perf/Makefile +5 -1
@@ -2,10 +2,14 @@ subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror obj-$(CONFIG_PERF_EVENTS) += callchain.o perf_regs.o +imc-$(CONFIG_PPC_POWERNV) += imc-pmu.o + obj-$(CONFIG_PPC_PERF_CTRS) += core-book3s.o bhrb.o obj64-$(CONFIG_PPC_PERF_CTRS) += power4-pmu.o ppc970-pmu.o power5-pmu.o \ power5+-pmu.o power6-pmu.o power7-pmu.o \ - isa207-common.o power8-pmu.o power9-pmu.o + isa207-common.o power8-pmu.o power9-pmu.o \ + $(imc-y) + obj32-$(CONFIG_PPC_PERF_CTRS) += mpc7450-pmu.o obj-$(CONFIG_FSL_EMB_PERF_EVENT) += core-fsl-emb.o
arch/powerpc/perf/imc-pmu.c new file +96 -0
96 lines not on this page · raw message
arch/powerpc/platforms/powernv/opal-imc.c +10 -2
@@ -31,8 +31,11 @@#include <asm/cputable.h> #include <asm/imc-pmu.h> -struct perchip_nest_info nest_perchip_info[IMC_MAX_CHIPS ]; -struct imc_pmu *per_nest_pmu_arr[IMC_MAX_PMUS ]; +extern struct perchip_nest_info nest_perchip_info[IMC_MAX_CHIPS ]; +extern struct imc_pmu *per_nest_pmu_arr[IMC_MAX_PMUS ]; + +extern int init_imc_pmu (struct imc_events *events, +int idx,struct imc_pmu *pmu_ptr);static int imc_event_info (char *name,struct imc_events *events) {
@@ -335,6 +338,11 @@ static int imc_pmu_create(struct device_node *parent, int pmu_index) idx += ret; } + ret =init_imc_pmu (events, idx, pmu_ptr); +if (ret) { +pr_err ("IMC PMU %s Register failed\n" , pmu_ptr->pmu.name); + goto free_events; + }return 0 ; free_events:
Signature · 1 line
2.7.4
PATCH v3 5/6 powerpc/perf: Generic imc pmu event functions
In reply to Hemant KumarSince, the IMC counters' data are periodically fed to a memory location, the functions to read/update, start/stop, add/del can be generic and can be used by all IMC PMU units.
This patch adds a set of generic imc pmu related event functions to be used by each imc pmu unit. Add code to setup format attribute and to register imc pmus. Add a event_init function for nest_imc events.
--- arch/powerpc/include/asm/imc-pmu.h | 1 + arch/powerpc/perf/imc-pmu.c | 122 ++++++++++++++++++++++++++++++ arch/powerpc/platforms/powernv/opal-imc.c | 29 ++++++- 3 files changed, 148 insertions(+), 4 deletions(-)
arch/powerpc/include/asm/imc-pmu.h +1 -0
@@ -70,4 +70,5 @@ struct imc_pmu {#define UNKNOWN_DOMAIN -1 +int imc_get_domain (struct device_node *pmu_dev);#endif /* PPC_POWERNV_IMC_PMU_DEF_H */
arch/powerpc/perf/imc-pmu.c +122 -0
134 lines not on this page · raw message
arch/powerpc/platforms/powernv/opal-imc.c +25 -4
@@ -36,6 +36,7 @@ extern struct imc_pmu *per_nest_pmu_arr[IMC_MAX_PMUS];extern int init_imc_pmu (struct imc_events *events,int idx,struct imc_pmu *pmu_ptr); +u64 nest_max_offset;static int imc_event_info (char *name,struct imc_events *events) {
@@ -68,8 +69,25 @@ static int imc_event_info_str(struct property *pp, char *name,return 0 ; } +/* +* Updates the maximum offset for an event in the pmu with domain +* "pmu_domain". Right now, only nest domain is supported. +*/ +static void update_max_value (u32 value,int pmu_domain) +{ +switch (pmu_domain) { +case IMC_DOMAIN_NEST : +if (nest_max_offset < value) + nest_max_offset = value; +break ; +default : +/* Unknown domain, return */ +return ; + } +} +static int imc_event_info_val (char *name,u32 val, -struct imc_events *events) +struct imc_events *events,int pmu_domain) {int ret;
@@ -77,6 +95,7 @@ static int imc_event_info_val(char *name, u32 val,if (ret)return ret;sprintf (events->ev_value,"event=0x%x" , val); +update_max_value (val, pmu_domain);return 0 ; }
@@ -111,7 +130,8 @@ static int set_event_property(struct property *pp, char *event_prop,static int imc_events_node_parser (struct device_node *dev,struct imc_events *events,struct property *event_scale, -struct property *event_unit) +struct property *event_unit, +int pmu_domain) {struct property *name, *pp;char *ev_name;
@@ -153,7 +173,8 @@ static int imc_events_node_parser(struct device_node *dev,*/ if (strncmp (pp->name,"reg" ,3 ) ==0 ) {of_property_read_u32 (dev, pp->name, &val); - ret =imc_event_info_val (ev_name, val, &events[idx]); + ret =imc_event_info_val (ev_name, val, &events[idx], + pmu_domain);if (ret) {kfree (events[idx].ev_name);kfree (events[idx].ev_value);
@@ -322,7 +343,7 @@ static int imc_pmu_create(struct device_node *parent, int pmu_index)/* Loop through event nodes */ for_each_child_of_node (parent, ev_node) { ret =imc_events_node_parser (ev_node, &events[idx], scale_pp, - unit_pp); + unit_pp, pmu_ptr->domain);if (ret <0 ) {/* Unable to parse this event */ if (ret == -ENOMEM )
Signature · 1 line
2.7.4
PATCH v3 6/6 powerpc/perf: IMC pmu cpumask and cpu hotplug support
In reply to Hemant KumarAdds cpumask attribute to be used by each IMC pmu. Only one cpu (any online CPU) from each chip for nest PMUs is designated to read counters.
On CPU hotplug, dying CPU is checked to see whether it is one of the designated cpus, if yes, next online cpu from the same chip (for nest units) is designated as new cpu to read counters.
--- arch/powerpc/include/asm/opal-api.h | 3 +- arch/powerpc/include/asm/opal.h | 2 + arch/powerpc/perf/imc-pmu.c | 167 ++++++++++++++++++++++++- arch/powerpc/platforms/powernv/opal-wrappers.S | 1 + 4 files changed, 171 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/opal-api.h +2 -1
@@ -167,7 +167,8 @@#define OPAL_INT_EOI 124#define OPAL_INT_SET_MFRR 125#define OPAL_PCI_TCE_KILL 126 -#define OPAL_LAST 126 +#define OPAL_NEST_IMC_COUNTERS_CONTROL 128 +#define OPAL_LAST 128/* Device tree flags */
arch/powerpc/include/asm/opal.h +2 -0
@@ -229,6 +229,8 @@ int64_t opal_pci_tce_kill(uint64_t phb_id, uint32_t kill_type,int64_t opal_rm_pci_tce_kill (uint64_t phb_id,uint32_t kill_type,uint32_t pe_num,uint32_t tce_size,uint64_t dma_addr,uint32_t npages); +int64_t opal_nest_imc_counters_control (uint64_t mode,uint64_t value1, +uint64_t value2,uint64_t value3);/* Internal functions */ extern int early_init_dt_scan_opal(unsigned long node, const char *uname,
arch/powerpc/perf/imc-pmu.c +166 -1
197 lines not on this page · raw message
arch/powerpc/platforms/powernv/opal-wrappers.S +1 -0
@@ -309,3 +309,4 @@ OPAL_CALL(opal_int_eoi, OPAL_INT_EOI); OPAL_CALL(opal_int_set_mfrr, OPAL_INT_SET_MFRR); OPAL_CALL(opal_pci_tce_kill, OPAL_PCI_TCE_KILL); OPAL_CALL_REAL(opal_rm_pci_tce_kill, OPAL_PCI_TCE_KILL); +OPAL_CALL(opal_nest_imc_counters_control, OPAL_NEST_IMC_COUNTERS_CONTROL);
Signature · 1 line
2.7.4