/*
* 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 2006 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 _ncpu;
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);
}
/*
* Common routine for several walkers.
* Read lgroup from wsp->walk_addr and call wsp->walk_callback for it.
* Normally returns the result of the callback.
* Returns WALK_DONE if walk_addr is NULL and WALK_ERR if cannot read the
* lgroup.
*/
static int
{
return (WALK_DONE);
return (WALK_ERR);
}
}
/*
* Get one lgroup from the lgroup table and adjust lwd_iter to point to the next
* one.
*/
int
{
} else {
mdb_warn("NULL lgrp pointer in lgrp_table[%d]",
return (WALK_ERR);
}
}
}
return (status);
}
/*
* Initialize walker to traverse parents of lgroups. Nothing to do here.
*/
/* ARGSUSED */
int
{
return (WALK_NEXT);
}
/*
* Call wsp callback on current lgroup in wsp and replace the lgroup with its
* parent.
*/
int
{
int status;
return (WALK_DONE);
return (WALK_ERR);
}
return (status);
}
/*
* Given the set return the ID of the first member of the set.
* Returns LGRP_NONE if the set has no elements smaller than max_lgrp.
*/
static lgrp_id_t
{
if (set == (klgrpset_t)0)
return (LGRP_NONE);
;
return (id);
}
/*
* lgrp_set_walk_data is used to walk lgroups specified by a set.
* On every iteration one element is removed from the set.
*/
typedef struct lgrp_set_walk_data {
/*
* Initialize iterator for walkers over a set of lgroups
*/
static int
{
int nlgrps;
/* Nothing to do if the set is empty */
if (set == (klgrpset_t)0)
return (WALK_DONE);
/* Get the total number of lgroups */
mdb_warn("symbol 'lgrp_alloc_max' not found");
return (WALK_ERR);
}
if (nlgrps < 0) {
return (WALK_ERR);
}
nlgrps++;
/* Find ID of the first lgroup in the set */
return (WALK_ERR);
}
/* Read lgroup_table and copy it to lwsd_lgrp_tbl */
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);
}
/* Save the first lgroup from the set and remove it from the set */
return (WALK_NEXT);
}
/*
* Get current lgroup and advance the lgroup to the next one in the lwsd_set.
*/
int
{
} else {
/* Move to the next lgroup in the set */
/* Remove id from the set */
}
}
return (status);
}
/*
* Initialize resource walker for a given lgroup and resource. The lgroup
* address is specified in walk_addr.
*/
static int
{
return (WALK_ERR);
}
}
/*
* Initialize CPU resource walker
*/
int
{
}
/*
* Initialize memory resource walker
*/
int
{
}
/*
* Display bitmap as a list of integers
*/
/* ARGSUSED */
int
{
int i = 0;
if (!(flags & DCMD_ADDRSPEC)) {
return (DCMD_USAGE);
}
if (set == 0)
return (DCMD_OK);
mdb_printf("%d ", i);
}
}
mdb_printf("\n");
return (DCMD_OK);
}