[Skiboot] [RFC PATCH 0/7] skiboot: OPAL support for IMA instrumentation

Hemant Kumar hemant at linux.vnet.ibm.com
Tue Oct 25 23:45:41 AEDT 2016


Patchset adds support for In Memory Accumulation instrumentation (IMA)
services in OPAL. The entire IMA infrastructure consists of two kinds
of Performance Monitoring Units (PMUs) : nest ima pmus (chip level)
and core ima pmus (core level).

Nest IMA PMUs are off core but on chip. And these can be accessed via
in-band scoms. Programming these counters and accumulating the counter
data to memory is done via microcode running in one of the OCC Engines.

This patchset is to add nest IMA instrumentation support in the OPAL
side.

"IMA_CATALOG" partition in PNOR contains multiple device tree binaries
(DTB) in a compressed form with PVR tag. So, when loading the IMA_CATALOG
partition, OPAL passes the system PVR as a "subid" to the load_resource
API. If a catalog dtb found for a given pvr, it is decompressed and
linked to the main device tree. 

Commit which adds the "IMA_CATALOG" partition to PNOR is :
https://github.com/open-power/pnor/commit/c940142c6dc64dd176096dc648f433c889919e84

Each event node in the device tree contains "event-name", "offset" and
some event nodes may also include "scale" and "unit" properties.

An excerpt from the dtb showing "mcs" pmu node and two of its event nodes:

/dts-v1/;

/ {
	name = "";
	compatible = "ibm,opal-in-memory-counters";
	ima-nest-offset = <0x00320000>
	ima-nest-size = <0x30000>
	#address-cells = <0x1>;
	#size-cells = <0x1>;

	mcs {
		compatible = "ibm,ima-counters-chip";
		ranges;
		#address-cells = <0x1>;
		#size-cells = <0x1>;

		mcs-01 at 118 {
			event-name = "PM_MCS_UP_128B_DATA_XFER_MC0";
			reg = <0x118 0x8>;
			unit = "MiB";
			scale = "1.2207e-4";
			desc = "Total Read Bandwidth seen on both MCS of MC0" ;
		};
		mcs-02 at 120 {
			event-name = "PM_MCS_UP_128B_DATA_XFER_MC1";
			reg = <0x120 0x8>;
			unit = "MiB";
			scale = "1.2207e-4";
			desc = "Total Read Bandwidth seen on both MCS of MC1" ;
		};

[SNIP]

So, from the OPAL side, we need to :
 - Find out the current processor's PVR.
 - Fetch the "IMA_CATALOG" partition.
 - Fetch the correct subpartition based on the current processor's PVR.
 - Decompress the blob taken from the subpartition.
 - Expand the (now uncompressed) device tree binary and attach it to the
   system's device tree, so that, it can now be discovered by the
   kernel.

Note that :
 - The Catalog team is working on upstreaming the DTS files.
 - The commit which adds the IMA_CATALOG partition to PNOR is mentioned
   above.
 - Since OPAL lacks a xz decompression library, an xz decompression
   library has been reused from the hostboot repo (link has been
   mentioned in patch 3/7).
 - This patchset is for base enablement for IMA and hence, only contains
   the nest IMA support.
 - The last patch in the series is to add "chip-id" to reserved homer
   region node in the device tree. This will give us the homer region's
   associated chip in the kernel (which will be needed to fetch the
   counter values from the required chip).

This Patchset does a couple of things :

1) At the time of boot, it detects the IMA_CATALOG resource. Based on
   the current processor's PVR value, it fetches the appropriate
   subpartition. The blob in this subpartition is then uncompressed and the
   flattened device tree is obtained. This dtb is then expanded and then
   linked to the system's device tree under
   "/proc/device-tree/ima-counters". The node "ima-counters" is a new node
   created in this patchset. The kernel can then discover this node based
   on its compatibility field.

2) It implements an opal call to control a microcode running in one of the
   OCC engines (responsible for nest IMA data collection) from kernel to
   start/stop Nest PMU counter data collection.

This patchset is based on the initial work for Nest Instrumentation done
by Madhavan Srinivasan, which can be found here :
(https://lists.ozlabs.org/pipermail/skiboot/2016-March/002999.html).

TODOs:
 - Add support for Core IMA.

Hemant Kumar (6):
  skiboot: Nest IMA macro definitions
  skiboot: Find the IMA catalog
  skiboot: Add a library for xz
  skiboot: Fetch the IMA dtb
  skiboot: Add opal call for nest IMA configuration
  skiboot: Add documentation for nest IMA opal call

Vasant Hegde (1):
  skiboot: Add chip id to HOMER reserved region

 Makefile.main                           |    5 +-
 core/flash.c                            |    1 +
 core/init.c                             |    7 +
 doc/opal-api/opal-nest-ima-counters.rst |   49 ++
 hw/Makefile.inc                         |    2 +-
 hw/homer.c                              |   30 +
 hw/ima.c                                |  210 ++++++
 include/ima.h                           |   91 +++
 include/opal-api.h                      |    3 +-
 include/platform.h                      |    1 +
 include/skiboot.h                       |    1 +
 libxz/Makefile.inc                      |    7 +
 libxz/xz.h                              |  312 ++++++++
 libxz/xz_config.h                       |  133 ++++
 libxz/xz_crc32.c                        |   67 ++
 libxz/xz_dec_lzma2.c                    | 1183 +++++++++++++++++++++++++++++++
 libxz/xz_dec_stream.c                   |  855 ++++++++++++++++++++++
 libxz/xz_lzma2.h                        |  212 ++++++
 libxz/xz_private.h                      |  164 +++++
 libxz/xz_stream.h                       |   70 ++
 20 files changed, 3399 insertions(+), 4 deletions(-)
 create mode 100644 doc/opal-api/opal-nest-ima-counters.rst
 create mode 100644 hw/ima.c
 create mode 100644 include/ima.h
 create mode 100644 libxz/Makefile.inc
 create mode 100644 libxz/xz.h
 create mode 100644 libxz/xz_config.h
 create mode 100644 libxz/xz_crc32.c
 create mode 100644 libxz/xz_dec_lzma2.c
 create mode 100644 libxz/xz_dec_stream.c
 create mode 100644 libxz/xz_lzma2.h
 create mode 100644 libxz/xz_private.h
 create mode 100644 libxz/xz_stream.h

-- 
2.7.4



More information about the Skiboot mailing list