-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[S390] perf: add support for s390x CPU counters
Add a perf PMU to access the CPU-measurement counter facility CPUM CF. CPUM CF provides multiple counter sets for measuring generic, problem-state, and crypto activaties. Also an extended counter set for the IBM System z10 and IBM z196 mainframes is available. Counters from the basic and problem-state counter set are mapped to generic perf hardware events. Other counters are accessible through raw events. For a list of available counter sets and counters, see: - The Load-Program-Parameter and the CPU-Measurement Facilities (SA23-2260) - The CPU-Measurement Facility Extended Counters Definition for z10 and z196 (SA23-2261) Reviewed-by: Jan Glauber <jang@linux.vnet.ibm.com> Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
- Loading branch information
Hendrik Brueckner
authored and
Martin Schwidefsky
committed
Mar 23, 2012
1 parent
b03d541
commit 212188a
Showing
5 changed files
with
912 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,95 @@ | ||
/* | ||
* CPU-measurement facilities | ||
* | ||
* Copyright IBM Corp. 2012 | ||
* Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com> | ||
* Jan Glauber <jang@linux.vnet.ibm.com> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License (version 2 only) | ||
* as published by the Free Software Foundation. | ||
*/ | ||
#ifndef _ASM_S390_CPU_MF_H | ||
#define _ASM_S390_CPU_MF_H | ||
|
||
#define CPU_MF_INT_SF_MASK 0xffc00000 | ||
|
||
#define CPU_MF_INT_SF_IAE (1 << 31) /* invalid entry address */ | ||
#define CPU_MF_INT_SF_ISE (1 << 30) /* incorrect SDBT entry */ | ||
#define CPU_MF_INT_SF_PRA (1 << 29) /* program request alert */ | ||
#define CPU_MF_INT_SF_SACA (1 << 23) /* sampler auth. change alert */ | ||
#define CPU_MF_INT_SF_LSDA (1 << 22) /* loss of sample data alert */ | ||
#define CPU_MF_INT_CF_CACA (1 << 7) /* counter auth. change alert */ | ||
#define CPU_MF_INT_CF_LCDA (1 << 6) /* loss of counter data alert */ | ||
|
||
#define CPU_MF_INT_CF_MASK (CPU_MF_INT_CF_CACA|CPU_MF_INT_CF_LCDA) | ||
#define CPU_MF_INT_SF_MASK (CPU_MF_INT_SF_IAE|CPU_MF_INT_SF_ISE| \ | ||
CPU_MF_INT_SF_PRA|CPU_MF_INT_SF_SACA| \ | ||
CPU_MF_INT_SF_LSDA) | ||
|
||
/* CPU measurement facility support */ | ||
static inline int cpum_cf_avail(void) | ||
{ | ||
return MACHINE_HAS_SPP && test_facility(67); | ||
} | ||
|
||
static inline int cpum_sf_avail(void) | ||
{ | ||
return MACHINE_HAS_SPP && test_facility(68); | ||
} | ||
|
||
|
||
struct cpumf_ctr_info { | ||
u16 cfvn; | ||
u16 auth_ctl; | ||
u16 enable_ctl; | ||
u16 act_ctl; | ||
u16 max_cpu; | ||
u16 csvn; | ||
u16 max_cg; | ||
u16 reserved1; | ||
u32 reserved2[12]; | ||
} __packed; | ||
|
||
/* Query counter information */ | ||
static inline int qctri(struct cpumf_ctr_info *info) | ||
{ | ||
int rc = -EINVAL; | ||
|
||
asm volatile ( | ||
"0: .insn s,0xb28e0000,%1\n" | ||
"1: lhi %0,0\n" | ||
"2:\n" | ||
EX_TABLE(1b, 2b) | ||
: "+d" (rc), "=Q" (*info)); | ||
return rc; | ||
} | ||
|
||
/* Load CPU-counter-set controls */ | ||
static inline int lcctl(u64 ctl) | ||
{ | ||
int cc; | ||
|
||
asm volatile ( | ||
" .insn s,0xb2840000,%1\n" | ||
" ipm %0\n" | ||
" srl %0,28\n" | ||
: "=d" (cc) : "m" (ctl) : "cc"); | ||
return cc; | ||
} | ||
|
||
/* Extract CPU counter */ | ||
static inline int ecctr(u64 ctr, u64 *val) | ||
{ | ||
register u64 content asm("4") = 0; | ||
int cc; | ||
|
||
asm volatile ( | ||
" .insn rre,0xb2e40000,%0,%2\n" | ||
" ipm %1\n" | ||
" srl %1,28\n" | ||
: "=d" (content), "=d" (cc) : "d" (ctr) : "cc"); | ||
if (!cc) | ||
*val = content; | ||
return cc; | ||
} | ||
|
||
#endif | ||
#endif /* _ASM_S390_CPU_MF_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
/* | ||
* Performance event support - s390 specific definitions. | ||
* | ||
* Copyright 2009 Martin Schwidefsky, IBM Corporation. | ||
* Copyright IBM Corp. 2009, 2012 | ||
* Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> | ||
* Hendrik Brueckner <brueckner@linux.vnet.ibm.com> | ||
*/ | ||
|
||
/* Empty, just to avoid compiling error */ | ||
#include <asm/cpu_mf.h> | ||
|
||
/* CPU-measurement counter facility */ | ||
#define PERF_CPUM_CF_MAX_CTR 160 | ||
|
||
/* Per-CPU flags for PMU states */ | ||
#define PMU_F_RESERVED 0x1000 | ||
#define PMU_F_ENABLED 0x2000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.