f77d3fa4084e1f365224746e0aacc5a2737eb523rs * CDDL HEADER START
f77d3fa4084e1f365224746e0aacc5a2737eb523rs * The contents of this file are subject to the terms of the
f77d3fa4084e1f365224746e0aacc5a2737eb523rs * Common Development and Distribution License (the "License").
f77d3fa4084e1f365224746e0aacc5a2737eb523rs * You may not use this file except in compliance with the License.
f77d3fa4084e1f365224746e0aacc5a2737eb523rs * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
f77d3fa4084e1f365224746e0aacc5a2737eb523rs * See the License for the specific language governing permissions
f77d3fa4084e1f365224746e0aacc5a2737eb523rs * and limitations under the License.
f77d3fa4084e1f365224746e0aacc5a2737eb523rs * When distributing Covered Code, include this CDDL HEADER in each
f77d3fa4084e1f365224746e0aacc5a2737eb523rs * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f77d3fa4084e1f365224746e0aacc5a2737eb523rs * If applicable, add the following below this CDDL HEADER, with the
f77d3fa4084e1f365224746e0aacc5a2737eb523rs * fields enclosed by brackets "[]" replaced with your own identifying
f77d3fa4084e1f365224746e0aacc5a2737eb523rs * information: Portions Copyright [yyyy] [name of copyright owner]
f77d3fa4084e1f365224746e0aacc5a2737eb523rs * CDDL HEADER END
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * Use is subject to license terms.
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs#pragma ident "%Z%%M% %I% %E% SMI"
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * Atom structure, used to reference count string atoms.
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rstypedef struct {
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * The _internal_lock is used to lock the state of libpool during
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * internal initialisation operations.
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * Various useful constant strings which are often encountered
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * prop_is_type() checks the supplied property and returns PO_TRUE if the
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * property value is set for the property else PO_FALSE
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rsstatic int resource_get_common(const pool_resource_t *, const char *,
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rsstatic int64_t elem_get_expected_int64(const pool_elem_t *, const char *);
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * The following returns a malloc'ed string which must be free'd by the
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rsstatic char *elem_get_expected_string(const pool_elem_t *, const char *);
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * Each element class/sub-class has a set of properties and behaviours
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * which are used to create the element with appropriate property
800deabc19a7cc91f3643168d5e09f9bf718efa9cm * values and to ensure correct property manipulations. The details
800deabc19a7cc91f3643168d5e09f9bf718efa9cm * are all stored in the following arrays.
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rsstatic int elem_no_set(pool_elem_t *, const pool_value_t *);
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rsstatic int elem_set_name(pool_elem_t *, const pool_value_t *);
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rsstatic int elem_get_type(const pool_elem_t *, pool_value_t *);
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rsstatic int elem_set_string(pool_elem_t *, const pool_value_t *);
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rsstatic int elem_set_bool(pool_elem_t *, const pool_value_t *);
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rsstatic int elem_set_uint(pool_elem_t *, const pool_value_t *);
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rsstatic int system_set_allocate(pool_elem_t *, const pool_value_t *);
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rsstatic int pool_set_scheduler(pool_elem_t *, const pool_value_t *);
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rsstatic int pool_set_active(pool_elem_t *, const pool_value_t *);
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rsstatic int res_set_max(pool_elem_t *, const pool_value_t *);
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rsstatic int res_set_min(pool_elem_t *, const pool_value_t *);
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rsstatic int cpu_set_status(pool_elem_t *, const pool_value_t *);
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs "invalid",
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs "component resource",
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs "aggregate resource",
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs "component"
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * This must be kept in sync with the pool_resource_elem_ctl array and
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * the "enum pool_resource_elem_class" type.
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs "invalid",
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs "invalid",
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs { "system.name", POOL_VALUE_INITIALIZER, PP_STORED, NULL,
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs PP_HIDDEN | PP_STORED | PP_READ, NULL, { NULL, elem_no_set } },
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs { "system.comment", POOL_VALUE_INITIALIZER, PP_STORED, NULL, NULL },
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs PP_STORED | PP_OPTIONAL, NULL, { NULL, system_set_allocate } },
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs PP_STORED | PP_OPTIONAL, NULL, { NULL, elem_set_string } },
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs PP_STORED | PP_OPTIONAL, NULL, { NULL, elem_set_string } },
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs { "system.poold.monitor-interval", POOL_VALUE_INITIALIZER,
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs PP_STORED | PP_OPTIONAL, NULL, { NULL, elem_set_uint } },
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs PP_STORED | PP_OPTIONAL, NULL, { NULL, elem_set_string } },
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs PP_STORED | PP_OPTIONAL, NULL, { NULL, elem_set_string } },
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs PP_STORED | PP_INIT, elem_name_init, { NULL, elem_set_name } },
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs PP_HIDDEN | PP_STORED | PP_READ, NULL, { NULL, elem_no_set } },
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs PP_HIDDEN | PP_STORED | PP_READ, NULL, { NULL, elem_no_set } },
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs { "pool.active", POOL_VALUE_INITIALIZER, PP_STORED | PP_INIT,
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs { "pool.importance", POOL_VALUE_INITIALIZER, PP_STORED | PP_INIT,
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs { "pool.comment", POOL_VALUE_INITIALIZER, PP_STORED | PP_INIT,
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs { "type", POOL_VALUE_INITIALIZER, PP_HIDDEN | PP_STORED | PP_READ, NULL,
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs PP_STORED | PP_INIT, elem_name_init, { NULL, elem_set_name } },
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs PP_HIDDEN | PP_STORED | PP_READ, NULL, { NULL, elem_no_set } },
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs { "pset.min", POOL_VALUE_INITIALIZER, PP_STORED | PP_INIT, res_min_init,
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs { "pset.max", POOL_VALUE_INITIALIZER, PP_STORED | PP_INIT, res_max_init,
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs { "pset.load", POOL_VALUE_INITIALIZER, PP_READ | PP_INIT,
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs { "pset.size", POOL_VALUE_INITIALIZER, PP_STORED | PP_INIT | PP_READ,
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs { "pset.comment", POOL_VALUE_INITIALIZER, PP_STORED | PP_INIT,
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs PP_STORED | PP_OPTIONAL, NULL, { NULL, elem_set_string } },
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs { "type", POOL_VALUE_INITIALIZER, PP_HIDDEN | PP_STORED | PP_READ, NULL,
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs { "cpu.sys_id", POOL_VALUE_INITIALIZER, PP_STORED | PP_READ, NULL,
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs PP_HIDDEN | PP_STORED | PP_READ, NULL, { NULL, elem_no_set } },
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs { "cpu.comment", POOL_VALUE_INITIALIZER, PP_STORED | PP_INIT,
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs { "cpu.status", POOL_VALUE_INITIALIZER, PP_INIT, cpu_status_init,
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs { "cpu.pinned", POOL_VALUE_INITIALIZER, PP_STORED | PP_OPTIONAL, NULL,
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * This must be kept in sync with the pool_resource_elem_class_name array and
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * the "enum pool_resource_elem_class" type.
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rsstatic void
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * Initialize pool_value_t atom dictionary
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs if ((_pv_atoms = dict_new((int (*)(const void *, const void *))
3c70f4b3551665c6c69a19b24d598b8a9cb16a42cm * Initializer, called when the library is initialized.
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * Initialize all available property arrays.
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * Initialise each of the properties
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * These functions intialise the properties of this plugin. The only reason
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * they exist is because the ability to perform the static initialisation of
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * union members properly was only introduced in the C99 standard. i.e. if you
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * could do {.f = 1.0} like in the proposed C99 standard then that would
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * be the preferred way to do this as it keeps the data in the array and
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * minimises the scope for errors. However, until that time these functions
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * are the best way to minimise the scope for errors and to maximise
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * maintainability.
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * There is one function for each property, and the initial value for each
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * property is hard-coded into each function.
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * Individual property manipulation routines for use by the generic
3c70f4b3551665c6c69a19b24d598b8a9cb16a42cm * get/put property routines
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * Many properties cannot be modified. This function prevents property
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * modification.
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs/* ARGSUSED */
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * Duplicate names for a pool or resource type are illegal.
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rselem_set_name(pool_elem_t *elem, const pool_value_t *pval)
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda if (pool != NULL && pool != pool_elem_pool(elem)) {
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs * Ensure the type is a string.
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rs/* ARGSUSED */
8c4f8890c870d3bd16cbcaeed2dc4679d5e076b5rselem_set_string(pool_elem_t *elem, const pool_value_t *pval)
return (PO_SUCCESS);
return (PO_FAIL);
return (PO_SUCCESS);
return (PO_FAIL);
return (PO_SUCCESS);
return (PO_FAIL);
return (PO_FAIL);
return (PO_FAIL);
return (PO_SUCCESS);
return (PO_FAIL);
return (PO_FAIL);
return (PO_SUCCESS);
return (PO_FAIL);
return (PO_FAIL);
return (PO_SUCCESS);
return (PO_FAIL);
return (PO_SUCCESS);
return (PO_FAIL);
return (PO_FAIL);
return (PO_FAIL);
return (PO_FAIL);
return (PO_SUCCESS);
return (PO_FAIL);
return (PO_SUCCESS);
return (PO_FAIL);
return (PO_FAIL);
case PREC_PSET:
return (PO_FAIL);
return (PO_FAIL);
return (PO_FAIL);
return (PO_SUCCESS);
return (PO_FAIL);
return (PO_FAIL);
return (PO_SUCCESS);
return (PO_FAIL);
return (PO_SUCCESS);
return (PO_TRUE);
return (PO_FALSE);
return (PO_SUCCESS);
return (PO_SUCCESS);
return (PO_SUCCESS);
return (PO_SUCCESS);
* Returns PO_SUCCESS/PO_FAIL
for (i = 0; i < sizeof (pool_resource_elem_ctl) /
sizeof (pool_resource_elem_ctl[0]); i++) {
count++;
return (count);
const pool_prop_t *
switch (elem_class) {
case PEC_SYSTEM:
case PEC_POOL:
case PEC_RES_AGG:
case PEC_RES_COMP:
case PEC_COMP:
return (prop_list);
const pool_prop_t *
return (NULL);
return (&prop_list[i]);
return (NULL);
return (PO_FALSE);
return (PO_FALSE);
return ((int)requested);
*uval = 0;
#ifdef DEBUG
return (retval);
* Returns PO_SUCCESS/PO_FAIL
* Returns PO_SUCCESS/PO_FAIL
return (PO_FAIL);
*pinned = 0;
return (PO_SUCCESS);
* Returns PO_SUCCESS/PO_FAIL
* Returns PO_SUCCESS/PO_FAIL
const pool_resource_t *
static int64_t
return (POOL_SYSID_BAD);
return (val64);
return (NULL);
return (retval);
return (B_FALSE);
return (bval != 0);
const pool_elem_t *
return (NULL);
PO_SUCCESS) {
return (NULL);
return (NULL);
return (NULL);
return (NULL);
return (pe_default);
switch (class) {
case PEC_SYSTEM:
case PEC_POOL:
case PEC_RES_COMP:
case PEC_RES_AGG:
for (i = 0; i < sizeof (pool_resource_elem_class_name) /
sizeof (pool_resource_elem_class_name[0]); i++) {
return (pool_resource_elem_class_name[i]);
case PEC_COMP:
for (i = 0; i < sizeof (pool_component_elem_class_name) /
sizeof (pool_component_elem_class_name[0]); i++) {
return (pool_component_elem_class_name[i]);
return (NULL);
case PEC_SYSTEM:
case PEC_POOL:
case PEC_RES_COMP:
case PEC_RES_AGG:
return (pool_resource_elem_class_name
case PEC_COMP:
return (pool_component_elem_class_name
return (NULL);
return (NULL);
return (NULL);
return (NULL);
return (retval);
for (i = 0; i < sizeof (pool_elem_class_name) /
sizeof (pool_elem_class_name[0]); i++) {
if (i == sizeof (pool_elem_class_name) /
sizeof (pool_elem_class_name[0]))
return (PEC_INVALID);
return ((pool_elem_class_t)i);
for (i = 0; i < sizeof (pool_resource_elem_class_name) /
sizeof (pool_resource_elem_class_name[0]); i++) {
if (i == sizeof (pool_resource_elem_class_name) /
sizeof (pool_resource_elem_class_name[0]))
return (PREC_INVALID);
return ((pool_resource_elem_class_t)i);
for (i = 0; i < sizeof (pool_component_elem_class_name) /
sizeof (pool_component_elem_class_name[0]); i++) {
if (i == sizeof (pool_component_elem_class_name) /
sizeof (pool_component_elem_class_name[0]))
return (PCEC_INVALID);
return ((pool_component_elem_class_t)i);
if (types) {
for (i = 0, j = 0; i < sizeof (pool_resource_elem_ctl) /
return (PO_SUCCESS);
NULL) {
return (NULL);
return (NULL);
return (NULL);
pool_t *
return (NULL);
return (NULL);
return (NULL);
return (PO_FAIL);
return (PO_SUCCESS);
return (NULL);
return (NULL);
return (cb);
return (PO_FAIL);
return (PO_SUCCESS);
PO_SUCCESS) {
return (PO_FAIL);
return (PO_SUCCESS);
return (PO_FAIL);
available = 0;
return (PO_FAIL);
for (i = 0; i < nelem; i++) {
return (PO_FAIL);
return (PO_FAIL);
PO_SUCCESS) {
return (PO_FAIL);
NULL) {
return (PO_FAIL);
for (i = 0; i < nelem; i++) {
return (PO_FAIL);
return (PO_FAIL);
return (PO_FAIL);
return (PO_SUCCESS);
if (_libpool_debug) {
if (_libpool_debug) {
log_t *
log_t *l;
return (NULL);
== NULL) {
free(l);
return (NULL);
free(l);
* Returns PO_SUCCESS/PO_FAIL
return (PO_FAIL);
return (PO_SUCCESS);
* Returns PO_SUCCESS/PO_FAIL
return (PO_FAIL);
return (PO_SUCCESS);
size++;
return (size);
* Returns PO_SUCCESS/PO_FAIL
return (PO_FAIL);
return (PO_SUCCESS);
return (NULL);
return (li);
return (PO_SUCCESS);
atom_init();
return (NULL);
return (NULL);
#ifdef DEBUG