summaryrefslogtreecommitdiff
path: root/usr/src/lib/libcpc
diff options
context:
space:
mode:
authorJonathan Haslam <Jonathan.Haslam@Sun.COM>2008-09-19 13:14:28 +0100
committerJonathan Haslam <Jonathan.Haslam@Sun.COM>2008-09-19 13:14:28 +0100
commitc7a079a873b863c236656bd0db7b2cf390841b4d (patch)
tree7812a50b4caaf22d35d6125731d648466c3239fa /usr/src/lib/libcpc
parente8e4e80fe335862e1a369070e9acaa2060866c90 (diff)
downloadillumos-joyent-c7a079a873b863c236656bd0db7b2cf390841b4d.tar.gz
PSARC 2008/334 CPU Performance Counter Generic Event Names
6689461 CPC Generic Events 6423769 cpustat system global_power_events for Xeon incorrect
Diffstat (limited to 'usr/src/lib/libcpc')
-rw-r--r--usr/src/lib/libcpc/common/libcpc.c125
-rw-r--r--usr/src/lib/libcpc/common/libcpc.h13
-rw-r--r--usr/src/lib/libcpc/common/mapfile-vers10
3 files changed, 136 insertions, 12 deletions
diff --git a/usr/src/lib/libcpc/common/libcpc.c b/usr/src/lib/libcpc/common/libcpc.c
index df431abcc4..ad9e288781 100644
--- a/usr/src/lib/libcpc/common/libcpc.c
+++ b/usr/src/lib/libcpc/common/libcpc.c
@@ -23,8 +23,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <libcpc.h>
#include <stdio.h>
#include <stdlib.h>
@@ -809,12 +807,73 @@ cpc_walk_events_all(cpc_t *cpc, void *arg,
p = list[i];
while ((e = strchr(p, ',')) != NULL) {
*e = '\0';
+
+ /* Skip any generic event names we find. */
+ if ((strncmp(p, "PAPI", 4)) == 0) {
+ p = e + 1;
+ continue;
+ }
+
if (__cpc_strhash_add(hash, p) == -1)
goto err;
p = e + 1;
}
- if (__cpc_strhash_add(hash, p) == -1)
+ if ((strncmp(p, "PAPI", 4)) != 0) {
+ if (__cpc_strhash_add(hash, p) == -1)
+ goto err;
+ }
+ }
+
+ while ((p = __cpc_strhash_next(hash)) != NULL)
+ action(arg, p);
+
+err:
+ __cpc_strhash_free(hash);
+ for (i = 0; i < ncounters; i++)
+ free(list[i]);
+ free(list);
+}
+
+/*ARGSUSED*/
+void
+cpc_walk_generic_events_all(cpc_t *cpc, void *arg,
+ void (*action)(void *arg, const char *event))
+{
+ char **list;
+ char *p, *e;
+ int i;
+ int ncounters = cpc_npic(cpc);
+ cpc_strhash_t *hash;
+
+ if ((list = malloc(ncounters * sizeof (char *))) == NULL)
+ return;
+
+ if ((hash = __cpc_strhash_alloc()) == NULL) {
+ free(list);
+ return;
+ }
+
+ for (i = 0; i < ncounters; i++) {
+ if ((list[i] = strdup(cpc->cpc_evlist[i])) == NULL)
goto err;
+ p = list[i];
+ while ((e = strchr(p, ',')) != NULL) {
+ *e = '\0';
+
+ /* Skip any platform specific event names we find. */
+ if ((strncmp(p, "PAPI", 4)) != 0) {
+ p = e + 1;
+ continue;
+ }
+
+ if (__cpc_strhash_add(hash, p) == -1)
+ goto err;
+ p = e + 1;
+ }
+ if ((strncmp(p, "PAPI", 4)) == 0) {
+ if (__cpc_strhash_add(hash, p) == -1)
+ goto err;
+ }
}
while ((p = __cpc_strhash_next(hash)) != NULL)
@@ -851,11 +910,67 @@ cpc_walk_events_pic(cpc_t *cpc, uint_t picno, void *arg,
p = list;
while ((e = strchr(p, ',')) != NULL) {
*e = '\0';
+
+ /* Skip any generic event names we find. */
+ if ((strncmp(p, "PAPI", 4)) == 0) {
+ p = e + 1;
+ continue;
+ }
+
action(arg, picno, p);
p = e + 1;
}
+
+ if ((strncmp(p, "PAPI", 4)) == 0)
+ goto out;
+
action(arg, picno, p);
+out:
+ free(list);
+}
+
+/*ARGSUSED*/
+void
+cpc_walk_generic_events_pic(cpc_t *cpc, uint_t picno, void *arg,
+ void (*action)(void *arg, uint_t picno, const char *event))
+{
+ char *p;
+ char *e;
+ char *list;
+
+ if (picno >= cpc->cpc_npic) {
+ errno = EINVAL;
+ return;
+ }
+
+ if ((list = strdup(cpc->cpc_evlist[picno])) == NULL)
+ return;
+
+ /*
+ * List now points to a comma-separated list of events supported by
+ * the designated pic.
+ */
+ p = list;
+ while ((e = strchr(p, ',')) != NULL) {
+ *e = '\0';
+
+ /* Skip any platform specific event names we find. */
+ if ((strncmp(p, "PAPI", 4)) != 0) {
+ p = e + 1;
+ continue;
+ }
+
+ action(arg, picno, p);
+ p = e + 1;
+ }
+
+ if ((strncmp(p, "PAPI", 4)) != 0)
+ goto out;
+
+ action(arg, picno, p);
+
+out:
free(list);
}
@@ -1081,6 +1196,10 @@ cpc_valid_event(cpc_t *cpc, uint_t pic, const char *ev)
if (pr.found)
return (1);
+ cpc_walk_generic_events_pic(cpc, pic, &pr, ev_walker);
+ if (pr.found)
+ return (1);
+
/*
* Before assuming this is an invalid event, see if we have been given
* a raw event code. An event code of '0' is not recognized, as it
diff --git a/usr/src/lib/libcpc/common/libcpc.h b/usr/src/lib/libcpc/common/libcpc.h
index 547cb62319..384474a76c 100644
--- a/usr/src/lib/libcpc/common/libcpc.h
+++ b/usr/src/lib/libcpc/common/libcpc.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,15 +19,13 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _LIBCPC_H
#define _LIBCPC_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/types.h>
#include <sys/cpc_impl.h>
#include <inttypes.h>
@@ -154,8 +151,12 @@ extern void cpc_walk_requests(cpc_t *cpc, cpc_set_t *set, void *arg,
extern void cpc_walk_events_all(cpc_t *cpc, void *arg,
void (*action)(void *arg, const char *event));
+extern void cpc_walk_generic_events_all(cpc_t *cpc, void *arg,
+ void (*action)(void *arg, const char *event));
extern void cpc_walk_events_pic(cpc_t *cpc, uint_t picno, void *arg,
void (*action)(void *arg, uint_t picno, const char *event));
+extern void cpc_walk_generic_events_pic(cpc_t *cpc, uint_t picno, void *arg,
+ void (*action)(void *arg, uint_t picno, const char *event));
extern void cpc_walk_attrs(cpc_t *cpc, void *arg,
void (*action)(void *arg, const char *attr));
diff --git a/usr/src/lib/libcpc/common/mapfile-vers b/usr/src/lib/libcpc/common/mapfile-vers
index f4403fa877..2f812b76a6 100644
--- a/usr/src/lib/libcpc/common/mapfile-vers
+++ b/usr/src/lib/libcpc/common/mapfile-vers
@@ -19,11 +19,15 @@
# CDDL HEADER END
#
#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
-#
+
+SUNW_1.3 {
+ global:
+ cpc_walk_generic_events_pic;
+ cpc_walk_generic_events_all;
+} SUNW_1.2;
SUNW_1.2 {
global: