Skip to content

Commit c432fef

Browse files
Thomas RichterVasily Gorbik
authored andcommitted
s390/pai: Add support for PAI Extension 1 NNPA counters
PMU device driver perf_paiext supports Processor Activity Instrumentation Extension (PAIE1), available with IBM z16: - maps a 512 byte block to lowcore address 0x1508 called PAIE1 control block. - maps a 1024 byte block at PAIE1 control block entry with index 2. - uses control register bit 14 to enable PAIE1 control block lookup. - turn PAIE1 nnpa counting on and off by setting bit 63 in PAIE1 control block entry with index 2. - creates a sample with raw data on each context switch out when at context switch some mapped counters have a value of nonzero. This device driver only supports CPU wide context, no task context is allowed. Support for counting: - one or more counters can be specified using perf stat -e pai_ext/xxx/ where xxx stands for the counter event name. Multiple invocation of this command is possible. The counter names are listed in /sys/devices/pai_ext/events directory. - one special counters can be specified using perf stat -e pai_ext/NNPA_ALL/ which returns the sum of all incremented nnpa counters. - multiple counting events can run in parallel. Support for Sampling: - one event pai_ext/NNPA_ALL/ is reserved for sampling. The event collects data at context switch out and saves them in the ring buffer. - no multiple invocations are possible. The PAIE1 nnpa counter events are system wide. No task context is supported. Therefore some restrictions documented in function paiext_busy() apply. Extend qpaci assembly instruction to query supported memory mapped nnpa counters. It returns the number of counters (no holes allowed in that range). PAIE1 nnpa counter events can not be created when a CPU hot plug add is processed. This means a CPU hot plug add does not get the necessary PAIE1 event to record PAIE1 nnpa counter increments on the newly added CPU. CPU hot plug remove removes the event and terminates the counting of PAIE1 counters immediately. Signed-off-by: Thomas Richter <[email protected]> Reviewed-by: Sumanth Korikkar <[email protected]> Reviewed-by: Sven Schnelle <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
1 parent 9267bdd commit c432fef

File tree

5 files changed

+682
-4
lines changed

5 files changed

+682
-4
lines changed

arch/s390/include/asm/ctl_reg.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ union ctlreg0 {
9595
Interruption-Filtering Override */
9696
unsigned long : 3;
9797
unsigned long ccc : 1; /* Cryptography counter control */
98-
unsigned long : 18;
98+
unsigned long pec : 1; /* PAI extension control */
99+
unsigned long : 17;
99100
unsigned long : 3;
100101
unsigned long lap : 1; /* Low-address-protection control */
101102
unsigned long : 4;

arch/s390/include/asm/lowcore.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ struct lowcore {
203203
__u8 pad_0x1400[0x1500-0x1400]; /* 0x1400 */
204204
/* Cryptography-counter designation */
205205
__u64 ccd; /* 0x1500 */
206-
__u8 pad_0x1508[0x1800-0x1508]; /* 0x1508 */
206+
/* AI-extension counter designation */
207+
__u64 aicd; /* 0x1508 */
208+
__u8 pad_0x1510[0x1800-0x1510]; /* 0x1510 */
207209

208210
/* Transaction abort diagnostic block */
209211
struct pgm_tdb pgm_tdb; /* 0x1800 */

arch/s390/include/asm/pai.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ struct qpaci_info_block {
1717
struct {
1818
u64 : 8;
1919
u64 num_cc : 8; /* # of supported crypto counters */
20-
u64 : 48;
20+
u64 : 9;
21+
u64 num_nnpa : 7; /* # of supported NNPA counters */
22+
u64 : 32;
2123
};
2224
};
2325

@@ -42,6 +44,8 @@ static inline int qpaci(struct qpaci_info_block *info)
4244
#define PAI_CRYPTO_BASE 0x1000 /* First event number */
4345
#define PAI_CRYPTO_MAXCTR 256 /* Max # of event counters */
4446
#define PAI_CRYPTO_KERNEL_OFFSET 2048
47+
#define PAI_NNPA_BASE 0x1800 /* First event number */
48+
#define PAI_NNPA_MAXCTR 128 /* Max # of event counters */
4549

4650
DECLARE_STATIC_KEY_FALSE(pai_key);
4751

arch/s390/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ obj-$(CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT) += ima_arch.o
7272
obj-$(CONFIG_PERF_EVENTS) += perf_event.o perf_cpum_cf_common.o
7373
obj-$(CONFIG_PERF_EVENTS) += perf_cpum_cf.o perf_cpum_sf.o
7474
obj-$(CONFIG_PERF_EVENTS) += perf_cpum_cf_events.o perf_regs.o
75-
obj-$(CONFIG_PERF_EVENTS) += perf_pai_crypto.o
75+
obj-$(CONFIG_PERF_EVENTS) += perf_pai_crypto.o perf_pai_ext.o
7676

7777
obj-$(CONFIG_TRACEPOINTS) += trace.o
7878
obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE)) += uv.o

0 commit comments

Comments
 (0)