summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKuriakose Kuruvilla <Kuriakose.Kuruvilla@Sun.COM>2008-11-01 04:20:43 -0700
committerKuriakose Kuruvilla <Kuriakose.Kuruvilla@Sun.COM>2008-11-01 04:20:43 -0700
commit0185ddb4dc51321503424e4f04bd721a063fd5a2 (patch)
tree7cfc6d93e47bacc611d0c1f76df563434e306fc7
parent086a76ce5df138f74f5a4d5ffa30e13b3daaf30f (diff)
downloadillumos-joyent-0185ddb4dc51321503424e4f04bd721a063fd5a2.tar.gz
6331630 cputrack prints incorrect exit record with multiple counters
-rw-r--r--usr/src/cmd/cpc/common/cputrack.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/usr/src/cmd/cpc/common/cputrack.c b/usr/src/cmd/cpc/common/cputrack.c
index 9b334d0aeb..22ad2673e2 100644
--- a/usr/src/cmd/cpc/common/cputrack.c
+++ b/usr/src/cmd/cpc/common/cputrack.c
@@ -19,11 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/time.h>
#include <stdio.h>
@@ -351,8 +350,8 @@ pinit_lwp(pctx_t *pctx, pid_t pid, id_t lwpid, void *arg)
else
#endif
(void) fprintf(stderr, gettext(
- "%6d: init_lwp: can't bind perf counters "
- "to lwp%d - %s\n"), (int)pid, (int)lwpid,
+ "%6d: init_lwp: can't bind perf counters "
+ "to lwp%d - %s\n"), (int)pid, (int)lwpid,
errstr);
return (-1);
}
@@ -376,7 +375,23 @@ pfini_lwp(pctx_t *pctx, pid_t pid, id_t lwpid, void *arg)
set = cpc_setgrp_getset(sgrp);
nreq = cpc_setgrp_getbufs(sgrp, &data1, &data2, &scratch);
- if (cpc_set_sample(cpc, set, *data1) == 0) {
+ if (cpc_set_sample(cpc, set, *scratch) == 0) {
+ if (opts->nsets == 1) {
+ /*
+ * When we only have one set of counts, the sample
+ * gives us the accumulated count.
+ */
+ *data1 = *scratch;
+ } else {
+ /*
+ * When we have more than one set of counts, the
+ * sample gives us the count for the latest sample
+ * period. *data1 contains the accumulated count but
+ * does not include the count for the latest sample
+ * period for this set of counters.
+ */
+ cpc_buf_add(cpc, *data1, *data1, *scratch);
+ }
if (opts->verbose)
print_sample(pid, lwpid, "fini_lwp",
*data1, nreq, cpc_setgrp_getname(sgrp));
@@ -722,8 +737,8 @@ p4_ht_error(void)
(void) fprintf(stderr, "%s\n",
gettext("Pentium 4 processors with HyperThreading present.\nOffline"
- " all but one logical processor on each physical processor in"
- " order to use\ncputrack.\n"));
+ " all but one logical processor on each physical processor in"
+ " order to use\ncputrack.\n"));
if ((kc = kstat_open()) == NULL)