acquire.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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.
*
* 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "statcommon.h"
#include "dsr.h"
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <strings.h>
#include <errno.h>
#include <poll.h>
#define ARRAY_SIZE(a) (sizeof (a) / sizeof (*a))
/*
* The time we delay before retrying after an allocation
* failure, in milliseconds
*/
#define RETRY_DELAY 200
static char *cpu_states[] = {
"cpu_ticks_idle",
"cpu_ticks_user",
"cpu_ticks_kernel",
"cpu_ticks_wait"
};
extern char cmdname[];
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
{
struct pset_snapshot *ps;
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);
}
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
}
if (types & SNAP_FLUSHES) {
fail(0, "This machine does not have "
"a virtual address cache");
}
}
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);
}
/*PRINTFLIKE2*/
void
{
int save_errno = errno;
if (do_perror)
exit(2);
}
void *
{
void *ptr;
else
}
return (ptr);
}
char *
safe_strdup(char *str)
{
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);
}