mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
cpacfstats: Add unauthorized state to CPU-MF counters
Introduce the new state 'unauthorized' to the three already existing states disabled, enabled, and unsupported to CPU-MF counters. CPU-MF counters are only available on LPARs. The intent is to differentiate whether a system simply does not support the CPU-MF counters like a z/VM guest or if they are supported like on LPAR but have to be authorized via HMC/SE. Signed-off-by: Finn Callies <fcallies@linux.ibm.com> Reviewed-by: Harald Freudenberger <freude@linux.ibm.com> [hoeppner@linux.ibm.com: Adapt commit message] Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
591eb30854
commit
5b909a40cb
@@ -179,6 +179,12 @@ the errno value.
|
|||||||
ECC counters are only available since z15. cpacfstats will show the
|
ECC counters are only available since z15. cpacfstats will show the
|
||||||
counters as \fIunsupported\fR if the hardware does not support ECC
|
counters as \fIunsupported\fR if the hardware does not support ECC
|
||||||
counters.
|
counters.
|
||||||
|
|
||||||
|
CPU-MF counters have to be authorized on HMC or SE to be available and are
|
||||||
|
otherwise shown as \fIunauthorized\fR. On the HMC or SE, authorize the LPAR
|
||||||
|
for each counter set you want to use. Customize the LPAR activation profile
|
||||||
|
and modify the Counter Facility Security Options. You need to activate the
|
||||||
|
\fICrypto activity counter set authorization control\fR checkbox.
|
||||||
.
|
.
|
||||||
.SH APPENDIX
|
.SH APPENDIX
|
||||||
The detailed pai counter names are:
|
The detailed pai counter names are:
|
||||||
|
|||||||
@@ -177,7 +177,8 @@ static void print_virtual_counter_answer(int s,
|
|||||||
static const char *const states[] = {
|
static const char *const states[] = {
|
||||||
[DISABLED] = "disabled",
|
[DISABLED] = "disabled",
|
||||||
[ENABLED] = "enabled",
|
[ENABLED] = "enabled",
|
||||||
[UNSUPPORTED] = "unsupported"
|
[UNSUPPORTED] = "unsupported",
|
||||||
|
[UNAUTHORIZED] = "unauthorized"
|
||||||
};
|
};
|
||||||
int paictr = 0, paistate = 0, ec;
|
int paictr = 0, paistate = 0, ec;
|
||||||
uint64_t i, paivalue = 0;
|
uint64_t i, paivalue = 0;
|
||||||
@@ -242,6 +243,8 @@ static void print_answer(int s, int ctr, int state, uint64_t value)
|
|||||||
printf(" %s counter: disabled\n", counter_str[ctr]);
|
printf(" %s counter: disabled\n", counter_str[ctr]);
|
||||||
else if (state == UNSUPPORTED)
|
else if (state == UNSUPPORTED)
|
||||||
printf(" %s counter: unsupported\n", counter_str[ctr]);
|
printf(" %s counter: unsupported\n", counter_str[ctr]);
|
||||||
|
else if (state == UNAUTHORIZED)
|
||||||
|
printf(" %s counter: unauthorized\n", counter_str[ctr]);
|
||||||
else
|
else
|
||||||
printf(" %s counter: %lu\n", counter_str[ctr], value);
|
printf(" %s counter: %lu\n", counter_str[ctr], value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,8 @@ enum cmd_e {
|
|||||||
enum state_e {
|
enum state_e {
|
||||||
DISABLED = 0,
|
DISABLED = 0,
|
||||||
ENABLED,
|
ENABLED,
|
||||||
UNSUPPORTED
|
UNSUPPORTED,
|
||||||
|
UNAUTHORIZED
|
||||||
};
|
};
|
||||||
|
|
||||||
enum counter_type {
|
enum counter_type {
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ static int do_enable(int s, enum ctr_e ctr, unsigned int *supported_counters)
|
|||||||
}
|
}
|
||||||
state = ENABLED;
|
state = ENABLED;
|
||||||
}
|
}
|
||||||
if (state != UNSUPPORTED) {
|
if (state != UNSUPPORTED && state != UNAUTHORIZED) {
|
||||||
rc = perf_read_ctr(i, &value, supported_counters);
|
rc = perf_read_ctr(i, &value, supported_counters);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
send_answer(s, i, rc, 0);
|
send_answer(s, i, rc, 0);
|
||||||
|
|||||||
@@ -141,6 +141,10 @@ static int perf_counter_supported(const char *pmu, const char *counter)
|
|||||||
return !access(buf, R_OK);
|
return !access(buf, R_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 1 if counters are authorized, -1 if counters are unauthorized,
|
||||||
|
* and 0 otherwise which indicates that the counters are unsupported
|
||||||
|
*/
|
||||||
static int cpumf_authorized(void)
|
static int cpumf_authorized(void)
|
||||||
{
|
{
|
||||||
unsigned vermin, vermax, auth;
|
unsigned vermin, vermax, auth;
|
||||||
@@ -159,10 +163,12 @@ static int cpumf_authorized(void)
|
|||||||
if (sscanf(line,
|
if (sscanf(line,
|
||||||
"CPU-MF: Counter facility: version=%d.%d authorization=%x",
|
"CPU-MF: Counter facility: version=%d.%d authorization=%x",
|
||||||
&vermin, &vermax, &auth) == 3) {
|
&vermin, &vermax, &auth) == 3) {
|
||||||
if (auth & 0x8)
|
if (auth & 0x8) {
|
||||||
res = 1;
|
res = 1;
|
||||||
else
|
} else {
|
||||||
eprint("CPU-MF counters not authorized.\n");
|
eprint("CPU-MF counters not authorized.\n");
|
||||||
|
res = -1;
|
||||||
|
}
|
||||||
found = 1;
|
found = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -233,7 +239,7 @@ static int activatecpu(unsigned int cpu, unsigned int *supported_counters)
|
|||||||
}
|
}
|
||||||
/* activate CPU-MF */
|
/* activate CPU-MF */
|
||||||
for (i = 0; i < ALL_COUNTER; ++i) {
|
for (i = 0; i < ALL_COUNTER; ++i) {
|
||||||
if (ctr_state[i] == UNSUPPORTED)
|
if (ctr_state[i] == UNSUPPORTED || ctr_state[i] == UNAUTHORIZED)
|
||||||
continue;
|
continue;
|
||||||
memset(&pfm_event, 0, sizeof(pfm_event));
|
memset(&pfm_event, 0, sizeof(pfm_event));
|
||||||
pfm_event.size = sizeof(pfm_event);
|
pfm_event.size = sizeof(pfm_event);
|
||||||
@@ -398,7 +404,7 @@ static int perf_load_counter_data(void)
|
|||||||
int i, res = 0;
|
int i, res = 0;
|
||||||
|
|
||||||
for (i = 0; i < ALL_COUNTER; ++i) {
|
for (i = 0; i < ALL_COUNTER; ++i) {
|
||||||
if (ctr_state[i] != UNSUPPORTED)
|
if (ctr_state[i] != UNSUPPORTED && ctr_state[i] != UNAUTHORIZED)
|
||||||
res |= perf_event_encode(&pmf_counter_data[i].pmutype,
|
res |= perf_event_encode(&pmf_counter_data[i].pmutype,
|
||||||
&pmf_counter_data[i].eventid,
|
&pmf_counter_data[i].eventid,
|
||||||
pmf_counter_name[i].pmu,
|
pmf_counter_name[i].pmu,
|
||||||
@@ -474,6 +480,7 @@ int perf_init(unsigned int *supported_counters)
|
|||||||
};
|
};
|
||||||
unsigned long maxfd;
|
unsigned long maxfd;
|
||||||
struct rlimit rlim;
|
struct rlimit rlim;
|
||||||
|
int cpumf_state;
|
||||||
int i, num;
|
int i, num;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
@@ -487,10 +494,15 @@ int perf_init(unsigned int *supported_counters)
|
|||||||
* counters for PAI. */
|
* counters for PAI. */
|
||||||
num = ALL_COUNTER + 2;
|
num = ALL_COUNTER + 2;
|
||||||
|
|
||||||
if (!cpumf_authorized()) {
|
cpumf_state = cpumf_authorized();
|
||||||
|
if (cpumf_state == 0) {
|
||||||
for (i = 0; i < ALL_COUNTER; ++i)
|
for (i = 0; i < ALL_COUNTER; ++i)
|
||||||
ctr_state[i] = UNSUPPORTED;
|
ctr_state[i] = UNSUPPORTED;
|
||||||
num -= ALL_COUNTER;
|
num -= ALL_COUNTER;
|
||||||
|
} else if (cpumf_state == -1) {
|
||||||
|
for (i = 0; i < ALL_COUNTER; ++i)
|
||||||
|
ctr_state[i] = UNAUTHORIZED;
|
||||||
|
num -= ALL_COUNTER;
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < ALL_COUNTER; i++) {
|
for (i = 0; i < ALL_COUNTER; i++) {
|
||||||
if (!perf_counter_supported("cpum_cf", cpum_cf[i])) {
|
if (!perf_counter_supported("cpum_cf", cpum_cf[i])) {
|
||||||
|
|||||||
Reference in New Issue
Block a user