lgrp.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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "lgrp.h"
#include <mdb/mdb_modapi.h>
int
{
int count;
char tmp;
char *format;
/* Unfortunately, mdb_printf returns void */
} else {
}
return (count);
}
void
{
int i, j;
ulong_t m;
int in = 0;
int start;
int end;
int count = 0;
int sep = 0;
for (i = 0; i < words; i++)
if (cs[i] & m) {
if (in == 0) {
in = 1;
}
} else {
if (in == 1) {
sep = 1;
in = 0;
}
}
if (in == 1) {
}
/*
* print width - count spaces
*/
}
typedef struct lgrp_cpu_walk {
int lcw_cpusleft;
int
{
return (WALK_ERR);
}
return (WALK_NEXT);
}
int
{
int status;
if (lcw->lcw_cpusleft-- == 0)
return (WALK_DONE);
return (WALK_ERR);
}
return (status);
mdb_warn("number of cpus in lgroup cpu != lgroup cpucnt\n");
return (WALK_ERR);
}
return (WALK_NEXT);
}
typedef struct lgrp_cpuwalk_cbdata {
int *lcc_loadavg;
/* ARGSUSED */
static int
{
int offset = 0;
/*
* if opt_p is set, we're going to break up info for
* each lgrp by processor set.
*/
if (opt_p != 0) {
mdb_warn("cannot read cpu partition at %p",
return (WALK_ERR);
}
goto found;
}
"number of cpu partitions changed during walk");
return (WALK_ERR);
}
== -1) {
return (WALK_ERR);
}
}
return (WALK_NEXT);
}
/* ARGSUSED */
int
{
int cpusetsize;
int lcpu; /* cpus in lgrp */
int _ncpu;
int opt_p = 0; /* display partition fraction loads */
int opt_q = 0; /* display only address. */
int i;
int filters = 0;
if (!(flags & DCMD_ADDRSPEC)) {
mdb_warn("can't walk 'lgrps'");
return (DCMD_ERR);
}
return (DCMD_OK);
}
return (DCMD_USAGE);
filters++;
filters++;
filters++;
if (flags & DCMD_PIPE_OUT)
else
}
if (opt_p == 0)
mdb_printf("%9s %?s %?s %?s %9s %9s\n",
"LGRPID",
"ADDR",
"PARENT",
"PLATHAND",
"#CPU",
"CPUS");
else
mdb_printf("%9s %9s %9s %9s %9s\n",
"LGRPID",
"PSRSETID",
"LOAD",
"#CPU",
"CPUS");
}
return (DCMD_ERR);
}
/*
* Do not report free lgrp unless specifically asked for.
*/
return (DCMD_OK);
/*
* If lgrp doesn't pass filtering criteria, don't print anything and
* just return.
*/
if (filters) {
return (DCMD_OK);
return (DCMD_OK);
return (DCMD_OK);
}
if (opt_q) {
return (DCMD_OK);
}
/*
* figure out what cpus we've got
*/
mdb_warn("symbol '_ncpu' not found");
return (DCMD_ERR);
}
/*
* allocate enough space for set of longs to hold cpuid bitfield
*/
if (opt_p)
else
lcpu = 1;
for (i = 0; i < lcpu; i++)
addr) == -1) {
mdb_warn("unable to walk lgrp_cpulist");
}
if (opt_p == 0) {
mdb_printf("%9d %?p %?p %?s %9d ",
addr,
"NULL",
mdb_printf("%9d %?p %?p %?s %9d ",
addr,
"DEFAULT",
} else {
mdb_printf("%9d %?p %?p %?p %9d ",
addr,
}
if (lgrp.lgrp_cpucnt != 0) {
cpusetsize/sizeof (ulong_t), 0);
}
mdb_printf("\n");
} else {
mdb_printf("%9d %9d %9d %9d ",
lcc.lcc_psrsetid[i],
lcc.lcc_loadavg[i],
lcc.lcc_cpucnt[i]);
if (lcc.lcc_cpucnt[i])
cpusetsize/sizeof (ulong_t), 0);
mdb_printf("\n");
}
}
return (DCMD_OK);
}
typedef struct lgrp_walk_data {
int lwd_nlgrps;
int lwd_iter;
int
{
"lgrp_alloc_max") == -1) {
mdb_warn("symbol 'lgrp_alloc_max' not found");
return (WALK_ERR);
}
if (lwd->lwd_nlgrps < 0) {
return (WALK_ERR);
}
lwd->lwd_nlgrps++;
mdb_warn("failed to find 'lgrp_table'");
return (WALK_ERR);
}
/* Get number of valid entries in lgrp_table */
mdb_warn("lgrp_table size inconsistent with lgrp_alloc_max");
return (WALK_ERR);
}
"lgrp_table") == -1) {
mdb_warn("unable to read lgrp_table");
return (WALK_ERR);
}
return (WALK_NEXT);
}
int
{
int status;
mdb_warn("unable to read lgrp at %p",
return (WALK_ERR);
}
wsp->walk_cbdata);
return (status);
return (WALK_DONE);
mdb_warn("NULL lgrp pointer in lgrp_table[%d]",
return (WALK_ERR);
}
return (WALK_NEXT);
}