1
linux/tools/perf/util/s390-cpumcf-kernel.h
Thomas Richter b539deafba perf report: Add s390 raw data interpretation for PAI counters
Commit 39d62336f5 ("s390/pai: add support for cryptography
counters") added support for Processor Activity Instrumentation Facility
(PAI) counters.  These counters values are added as raw data with the
perf sample during 'perf record'.

Now add support to display these counters in the 'perf report' command.

The counter number, its assigned name and value is now printed in
addition to the hexadecimal output.

Output before:

  # perf report -D

  6 514766399626050 0x7b058 [0x48]: PERF_RECORD_SAMPLE(IP, 0x1):
 				303977/303977: 0 period: 1 addr: 0
  ... thread: paitest:303977
  ...... dso: <not found>

  0x7b0a0@/root/perf.data.paicrypto [0x48]: event: 9
  .
  . ... raw event: size 72 bytes
  . 0000:  00 00 00 09 00 01 00 48 00 00 00 00 00 00 00 00  .......H........
  . 0010:  00 04 a3 69 00 04 a3 69 00 01 d4 2d 76 de a0 bb  ...i...i...-v...
  . 0020:  00 00 00 00 00 01 5c 53 00 00 00 06 00 00 00 00  ......\S........
  . 0030:  00 00 00 00 00 00 00 01 00 00 00 0c 00 07 00 00  ................
  . 0040:  00 00 00 53 96 af 00 00                          ...S....

Output after:

  # perf report -D

  6 514766399626050 0x7b058 [0x48]: PERF_RECORD_SAMPLE(IP, 0x1):
 				303977/303977: 0 period: 1 addr: 0
  ... thread: paitest:303977
  ...... dso: <not found>

  0x7b0a0@/root/perf.data.paicrypto [0x48]: event: 9
  .
  . ... raw event: size 72 bytes
  . 0000:  00 00 00 09 00 01 00 48 00 00 00 00 00 00 00 00  .......H........
  . 0010:  00 04 a3 69 00 04 a3 69 00 01 d4 2d 76 de a0 bb  ...i...i...-v...
  . 0020:  00 00 00 00 00 01 5c 53 00 00 00 06 00 00 00 00  ......\S........
  . 0030:  00 00 00 00 00 00 00 01 00 00 00 0c 00 07 00 00  ................
  . 0040:  00 00 00 53 96 af 00 00                          ...S....

        Counter:007 km_aes_128 Value:0x00000000005396af     <--- new

Committer notes:

Had to add ignore pragmas for that __packed function:

  +#pragma GCC diagnostic ignored "-Wpacked"
  +#pragma GCC diagnostic ignored "-Wattributes"

Otherwise this doesn't build in things like debian experimentao cross
building to mips64, etc.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Tested-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Link: https://lore.kernel.org/r/20231110110908.2312308-1-tmricht@linux.ibm.com
[ Corrected non-existent commit referred to the right one: 39d62336f5 ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2023-11-15 12:51:53 -05:00

66 lines
2.2 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
/*
* Support for s390 CPU measurement counter set diagnostic facility
*
* Copyright IBM Corp. 2019
Author(s): Hendrik Brueckner <brueckner@linux.ibm.com>
* Thomas Richter <tmricht@linux.ibm.com>
*/
#ifndef S390_CPUMCF_KERNEL_H
#define S390_CPUMCF_KERNEL_H
#define S390_CPUMCF_DIAG_DEF 0xfeef /* Counter diagnostic entry ID */
#define PERF_EVENT_CPUM_CF_DIAG 0xBC000 /* Event: Counter sets */
#define PERF_EVENT_CPUM_SF_DIAG 0xBD000 /* Event: Combined-sampling */
#define PERF_EVENT_PAI_CRYPTO_ALL 0x1000 /* Event: CRYPTO_ALL */
#define PERF_EVENT_PAI_NNPA_ALL 0x1800 /* Event: NNPA_ALL */
struct cf_ctrset_entry { /* CPU-M CF counter set entry (8 byte) */
unsigned int def:16; /* 0-15 Data Entry Format */
unsigned int set:16; /* 16-23 Counter set identifier */
unsigned int ctr:16; /* 24-39 Number of stored counters */
unsigned int res1:16; /* 40-63 Reserved */
};
struct cf_trailer_entry { /* CPU-M CF trailer for raw traces (64 byte) */
/* 0 - 7 */
union {
struct {
unsigned int clock_base:1; /* TOD clock base */
unsigned int speed:1; /* CPU speed */
/* Measurement alerts */
unsigned int mtda:1; /* Loss of MT ctr. data alert */
unsigned int caca:1; /* Counter auth. change alert */
unsigned int lcda:1; /* Loss of counter data alert */
};
unsigned long flags; /* 0-63 All indicators */
};
/* 8 - 15 */
unsigned int cfvn:16; /* 64-79 Ctr First Version */
unsigned int csvn:16; /* 80-95 Ctr Second Version */
unsigned int cpu_speed:32; /* 96-127 CPU speed */
/* 16 - 23 */
unsigned long timestamp; /* 128-191 Timestamp (TOD) */
/* 24 - 55 */
union {
struct {
unsigned long progusage1;
unsigned long progusage2;
unsigned long progusage3;
unsigned long tod_base;
};
unsigned long progusage[4];
};
/* 56 - 63 */
unsigned int mach_type:16; /* Machine type */
unsigned int res1:16; /* Reserved */
unsigned int res2:32; /* Reserved */
};
#define CPUMF_CTR_SET_BASIC 0 /* Basic Counter Set */
#define CPUMF_CTR_SET_USER 1 /* Problem-State Counter Set */
#define CPUMF_CTR_SET_CRYPTO 2 /* Crypto-Activity Counter Set */
#define CPUMF_CTR_SET_EXT 3 /* Extended Counter Set */
#define CPUMF_CTR_SET_MT_DIAG 4 /* MT-diagnostic Counter Set */
#endif