/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* 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
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include "statcommon.h"
#include "dsr.h"
#include <stdlib.h>
#include <unistd.h>
#include <strings.h>
#include <errno.h>
#include <limits.h>
#include <poll.h>
#define ARRAY_SIZE(a) (sizeof (a) / sizeof (*a))
/*
* The time we delay before retrying after an allocation
* failure, in milliseconds
*/
static char *cpu_states[] = {
"cpu_ticks_idle",
"cpu_ticks_user",
"cpu_ticks_kernel",
"cpu_ticks_wait"
};
static kstat_t *
{
return (NULL);
return (NULL);
return (ksp);
}
/*
* Note: the following helpers do not clean up on the failure case,
* because it is left to the free_snapshot() in the acquire_snapshot()
* failure path.
*/
static int
{
size_t i;
goto out;
/* If no valid CPU is present, move on to the next one */
continue;
goto out;
continue;
goto out;
goto out;
goto out;
goto out;
}
errno = 0;
out:
return (errno);
}
static int
{
size_t i, j;
/*
* Careful in this code. We have to use pset_list
* twice, but inbetween pids_nr can change at will.
* We delay the setting of s_nr_psets until we have
* the "final" value of pids_nr.
*/
return (errno);
goto out;
goto out;
goto out;
/* CPUs not in any actual pset */
goto out;
/* CPUs in a a pset */
goto out;
}
for (i = 0; i < ss->s_nr_psets; i++) {
continue;
continue;
}
}
errno = 0;
out:
return (errno);
}
static int
{
size_t i = 0;
/* clock interrupt */
ss->s_nr_intrs++;
}
return (errno);
goto out;
goto out;
i = 1;
int j;
continue;
goto out;
for (j = 0; j < KSTAT_NUM_INTRS; j++)
i++;
}
errno = 0;
out:
return (errno);
}
int
{
size_t i;
return (errno);
return (errno);
return (errno);
return (errno);
return (errno);
return (errno);
return (errno);
return (errno);
return (errno);
return (errno);
continue;
return (errno);
return (errno);
ss->s_nr_active_cpus++;
}
return (0);
}
struct snapshot *
{
int err;
err = 0;
/* ensure any partial resources are freed on a retry */
/* wait for a possibly up-to-date chain */
else
}
switch (err) {
case 0:
break;
case EAGAIN:
/* a kstat disappeared from under us */
/*FALLTHRU*/
case ENXIO:
case ENOENT:
goto retry;
default:
}
return (ss);
}
void
{
size_t i;
return;
}
}
}
for (i = 0; i < ss->s_nr_psets; i++)
}
}
open_kstat(void)
{
else
}
return (kc);
}
void *
{
void *ptr;
else
}
return (ptr);
}
char *
{
char *ret;
return (NULL);
else
}
return (ret);
}
{
}
}
int
{
return (-1);
} else {
dst->ks_data_size = 0;
}
return (0);
}
int
{
size_t i;
/* "addition" makes little sense for strings */
from++;
to++;
}
return (0);
}
{
size_t i;
for (i = 0; i < ARRAY_SIZE(cpu_states); i++)
return (ticks);
}
int
{
size_t i;
int count = 0;
count++;
}
return (count);
}
/*
* Return the number of ticks delta between two hrtime_t
* values. Attempt to cater for various kinds of overflow
* in hrtime_t - no matter how improbable.
*/
{
else {
/*
* We've overflowed the positive portion of an
* hrtime_t.
*/
if (new < 0L) {
/*
* The new value is negative. Handle the
* case where the old value is positive or
* negative.
*/
if (old > 0L)
else {
return (del);
}
} else {
/*
* Either we've just gone from being negative
* to positive *or* the last entry was positive
* and the new entry is also positive but *less*
* than the old entry. This implies we waited
* quite a few days on a very fast system between
* iostat displays.
*/
if (old < 0L) {
} else {
}
return (del);
}
}
}